Currently I use Fish as my main shell on local and remote hosts.
I connect to remote hosts via ssh and sftp. I wanted to open or reuse a remote tmux whenever I connect, automatically, by default; so I added this to my ~/.ssh/config:
Host example.com
RemoteCommand tmux a; or tmux
RequestTTY yes
The problem is that now I cannot connect through sftp, nor can I run a direct command from my local CLI:
➤ ssh example.com ping localhost
Cannot execute command-line and remote command.
➤ sftp example.com
Cannot execute command-line and remote command.
Connection closed
So, my question is: How can I define a default command to be executed when opening a new interactive SSH session, but make it overridable?
$_. However, I can manually export a variable withset -x auto_tmux 1and change the match test to"[ 1 -eq $auto_tmux ]"– Yajo Jun 25 '18 at 09:04Match exec "[[ $(ps h o args p $PPID | wc -w) -eq 2 ]]". That exec is true when ssh is invoked as "sshHost with.example.com multiple.example.comand you wish to useMatchthis way, try curly braces:Match Host {with.example.com,multiple.example.com} exec "..."– rymo Dec 03 '19 at 23:08execportion:Match exec "[[ %n == @(pihole|router|athena|nas) && $(ps h o args p $PPID | wc -w) -eq 2 ]]". – Head Geek Jan 03 '20 at 16:36