3

I switched from bash to fish shell. I liked it and decided to use it on my servers also. How can I start tmux automatically on ssh connection? I followed this instruction for bash but fish shell is different and this recipe doesn't work without cardinal rewriting.

2

I rewrote script. The most tricky part was to disconnect from ssh by exiting from fish as exit inside ./.config/fish/config.fish didn't work.

It starts tmux only if parent of the fish is ssh.

Here is part of my ./.config/fish/config.fish file:

if status --is-login
    set PPID (echo (ps --pid %self -o ppid --no-headers) | xargs)
    if ps --pid $PPID | grep ssh
        tmux has-session -t remote; and tmux attach-session -t remote; or tmux new-session -s remote; and kill %self
        echo "tmux failed to start; using plain fish shell"
    end
end

More readable version can be found in my other question (thanks to ridiculous-fish, author of fish shell): How to use booleans in fish shell?

0

Byobu, a terminal multiplexer, based on tmux, offers an autostart feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.