Hacker News new | ask | show | jobs
by oalders 2249 days ago
How are you setting your tmux colours in different environments?
1 comments

I have this in my ~/.bashrc:

    declare -A TMUX_SSH_COLORS_TABLE                                                                                                
    TMUX_SSH_COLORS_TABLE=( \                                                                                                       
        ["server"]="fg=yellow bold,bg=black" \
        ["router"]="fg=red bold,bg=black" \                                                                                                                                                                                      
        ["desktop"]="fg=white bold,bg=black" \                                                                                      
    )                                                                                                                               
                                                                                                                                                                                                                                                                      
    function ssh {                                                                                                                  
        trap 'tmux select-pane -t:. -P "default"' RETURN                                                                            
        for arg; do                                                                                                                 
            local arg_value="${TMUX_SSH_COLORS_TABLE[$arg]}"                                                                        
            [[ -n "${arg_value}" ]] && tmux select-pane -t:. -P "${arg_value}"                                                      
            break                                                                                                                   
        done                                                                                                                        
        /usr/bin/ssh "$@"                                                                                                           
    }
On my laptop, `ssh desktop` will switch my tmux colors and then when ssh dies/quits/etc I go back to the default color scheme.
I hadn't thought of this approach. Thanks!