gpakosz / .tmux

🇫🇷 Oh my tmux! My self-contained, pretty & versatile tmux configuration made with ❤️
MIT License
22.03k stars 3.37k forks source link

display local command or ssh hostname in window format #179

Open divansantana opened 6 years ago

divansantana commented 6 years ago

Now that #178 is sorted, a separate much more minor issue :grimacing:

How does one achieve something like this:

1 htop 2 remotehost1 3 remotehost2 4 zsh

IE display the command if local, else display the ssh hostname. This almost works.

tmux_conf_theme_window_status_format='#I #W #{hostname_ssh}'
tmux_conf_theme_window_status_current_format='#I #W #{hostname_ssh}'

The above results in something like this which is a little less ideal because of screen estate:

1 htop 2 ssh remotehost1 3 ssh remotehost2 4 zsh
gpakosz commented 6 years ago
$ tmux setw automatic-rename-format '#{?pane_in_mode,[tmux],#{?#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D),#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D),#{pane_current_command}}}#{?pane_dead,[dead],}'

This mostly does what you want but

I'm not sure how to achieve it efficiently for now

divansantana commented 6 years ago

@gpakosz Cool this is minor. It doesn't really bother me too much.

Thanks!

gpakosz commented 6 years ago

Hi @divansantana

The following should be less heavy

tmux setw -g automatic-rename-format "#{?pane_in_mode,[tmux],#{?#{m:*ssh,#{pane_current_command}},#(cut -c3- ~/.tmux.conf | sh -s _hostname #{pane_tty} true #D),#{pane_current_command}}}#{?pane_dead,[dead],}"
mattboy9921 commented 3 years ago

Hi @gpakosz, Can you tell me where to run this? I tried it just in bash on the machine running tmux and also putting it in my .tmux.conf.local file but it doesn't do anything for me.