This isn't due to the function, it's because you're chaining multiple commands on a line with ;
separating them. But &
is already a command separator, and using both without a command in between (as in ... port $2 & ; sleep 3 ...
) is a syntax error. Solution: either remove the redundant ;
:
runproject() { cd $HOME/projects/$1 ; workon $1 ; port $2 & sleep 3 ; google-chrome 127.0.0.1:$2 ;}
Or use line breaks as command separators, instead of ;
:
runproject() { cd $HOME/projects/$1 workon $1 port $2 & sleep 3 google-chrome 127.0.0.1:$2 }
...which I prefer, because I find it easier to read.