0

When using csh I use this alias:

alias s autossh -M 0 -t \!:1 \"tmux -2 attach -t $USER\!:2 -d \|\| tmux -2 new -s $USER\!:2 \"

That can help me to ssh to a remote server by using something like:

s 10.11.12.3 X

Where X is the suffix $USERX of the remote tmux session the one I can attach or create in case it doesn't exists.

I am currently using zsh but would like to continue using the same alias, therefore I would like to know how to properly convert this alias to work under zsh.

Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146
nbari
  • 25,603
  • 10
  • 76
  • 131

1 Answers1

0

Use a shell function. csh uses aliases only because it doesn't have functions.

s () {
    autossh -M 0 -t "$1" "tmux -2 attach -t $USER$2 -d || tmux -2 new -s $USER$2 "
}

(I think I replaced the parameters correctly, but it's been a few decades since I used csh.)

chepner
  • 497,756
  • 71
  • 530
  • 681