I used the have the following tmux shortcut function defined in a separate script and aliased, which worked fine but was messy. I decided to move it to my .zshrc where it naturally belongs, and encountered a problem I wasn't able to figure out.
function t () {re='^[0-9]+$'
if [ "$1" == "kill" ]
then
        tmux kill-session -t $2
elif [[ "$1" =~ "$re" ]]
then
        tmux attach-session -d -t $1
fi}
I source my .zshrc, call the function, and get:
t:1: = not found
I know the function is defined:
╭─bennett@Io [~] using
╰─○ which t
t () {
    re='^[0-9]+$'
    if [ "$1" == "kill" ]
    then
            tmux kill-session -t $2
    elif [[ "$1" =~ "$re" ]]
    then
            tmux attach-session -d -t $1
    fi
}
I'm assuming this is complaining about the first line of the function. I've tried shifting the first line of the function down several lines, which doesn't change anything except which line the error message refers to. Any clue what's going on? I haven't found anything relating to this specific issue on SO.
 
    