Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mosh log in automatically reattach tmux session

Tags:

tmux

mosh

I'm using Mosh with tmux

I want to run the command "tmux attach -t 0 -d" after mosh connects successfully.

How do I automatically call a command to reattach tmux when I successfully log via mosh?

like image 525
Lionel Avatar asked Jun 12 '12 05:06

Lionel


1 Answers

This works:

mosh $REMOTE tmux attach   # I didn't expect this to work

but neither of these do:

mosh $REMOTE "tmux attach -d"  # This should probably work
mosh $REMOTE tmux attach -d    # This correctly interprets -d as a mosh option

UPDATE: As Chris Johnson points out, you can use the '--' argument turn off option processing, so that the entire tmux command is sent to the remote server as a command:

mosh $REMOTE -- tmux attach -t 0 -d
like image 172
chepner Avatar answered Sep 22 '22 07:09

chepner