4

I'm currently setting tmux to update the window title to the name of the currently running command by doing the following:

set-option -g set-titles on
set-option -g set-titles-string '#S:#I.#P #W' # window number,program name,active (or not)
set-window-option -g automatic-rename on      # auto name

However, when no command is being executed, it just displays "N:zsh" (where N is the window number).

Is there a way to display the current last element of the path in the window title when no command is being executed? So, if the current path is /usr/src/linux, the window title should be "N:linux".

Thank you

3

I have a semi-solution to show both:

# window titles
set-window-option -g window-status-current-format ' #[fg=white]** #[fg=white,bold][#{window_index}] #[fg=green]#{pane_current_command} #[fg=cyan]#(pwd="#{pane_current_path}"; echo ${pwd####*/}) #[fg=white]**'
set-window-option -g window-status-format '#[fg=colour244,bold][#{window_index}] #[fg=colour244]#{pane_current_command} #[fg=colour244]#(pwd="#{pane_current_path}"; echo ${pwd####*/})'

Add these lines into your ~/.tmux.conf and would get:

enter image description here

| improve this answer | |

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.