Change tmux colors when running ssh

Menu

This post lists a function which changes tmux colors when connecting to another machine with ssh:

https://stackoverflow.com/questions/57205231/how-do-i-change-the-color-for-directories-with-ls-using-tmux

Extremely useful!

Here is my adaptation, where shairN is an alias for the remote machine I want to connect to:

function ssh_tmux_color () {
    if [ -n "$TMUX" ]; then
        case "$1" in
            shair0)
                tmux selectp -P 'fg=color117,bg=color237'
                ;;
            shair1)
                tmux selectp -P 'fg=color208,bg=color237'
                ;;
            shair2)
                tmux selectp -P 'fg=color11,bg=color237'
                ;;
        esac
    fi
    ssh "$@"
    tmux selectp -P default
}
alias ssh=ssh_tmux_color