如何将 csh 转换为需要参数的 zsh 别名

how to convert an csh to zsh alias that requires arguments

当使用 csh 时,我使用这个别名:

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

这可以帮助我使用类似以下内容的 ssh 连接到远程服务器:

s 10.11.12.3 X

其中 X 是远程 tmux 会话的后缀 $USERX,如果它不存在,我可以附加或创建它。

我目前正在使用 zsh 但想继续使用相同的别名,因此我想知道如何正确转换此别名以在 zsh 下工作。

使用shell函数。 csh 使用别名只是因为它没有功能。

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

(我觉得我把参数替换对了,但是我已经几十年没用了csh了。)