Mosh登录自动重新连接tmux会话

Lio*_*nel 13 tmux mosh

我正在使用Moshtmux

我希望在mosh连接成功后运行命令"tmux attach -t 0 -d".

当我通过mosh成功登录时,如何自动调用命令重新连接tmux?

che*_*ner 19

这有效:

mosh $REMOTE tmux attach   # I didn't expect this to work
Run Code Online (Sandbox Code Playgroud)

但这些都没有:

mosh $REMOTE "tmux attach -d"  # This should probably work
mosh $REMOTE tmux attach -d    # This correctly interprets -d as a mosh option
Run Code Online (Sandbox Code Playgroud)

更新:正如Chris Johnson指出的那样,您可以使用' - '参数关闭选项处理,以便将整个tmux命令作为命令发送到远程服务器:

mosh $REMOTE -- tmux attach -t 0 -d
Run Code Online (Sandbox Code Playgroud)

  • 我不是*mosh*用户,但是[*mosh*网页](http://mosh.mit.edu/#usage)表明适当的语法可能是`mosh $ REMOTE - attach -d`(或者`mosh - $ REMOTE attach -d`).*mosh*是一个使用[GetOpt :: Long](http://perldoc.perl.org/Getopt/Long.html)的Perl程序.它的文档描述了[如何` - `工作](http://perldoc.perl.org/Getopt/Long.html#Mixing-command-line-option-with-other-arguments).任何*mosh*选项必须在` - `之前. (2认同)