add-zsh-hook precmd prompt_precmd
-# When screen, xterm or rxvt is used set the name of the window to the
+# When screen, tmux, xterm or rxvt is used set the name of the window to the
# currently running program.
#
# When a program is started preexec() sets the window's name to it; when it
# stops precmd() resets the window's name to 'zsh'. 'fg' is supported and sets
# the window's name to the resumed job.
#
-# It works with screen, xterm and rxvt.
+# It works with screen, tmux, xterm and rxvt.
#
# If a command is run with sudo or if the shell is running as root then a ! is
# added at the beginning of the command to make this clear. If a command is
# running on a different computer with ssh a @ is added at the beginning. If
-# screen is running on the remote machine instead of @screen @:hostname
-# (hostname replaced by the machine's hostname) is displayed. This only works
-# if the .zshrc on the server also uses this command.
+# screen/tmux is running on the remote machine instead of @screen @:hostname
+# (or @tmux ..; hostname replaced by the machine's hostname) is displayed.
+# This only works if the .zshrc on the server also uses this command.
#
# screen* is necessary as `screen` uses screen.linux for example for a linux
# console.
# If screen is running in SSH then display "@:hostname" as title
# in the term/outer screen.
- if [[ $program_name == @screen ]]; then
+ if [[ $program_name == @screen || $program_name == @tmux ]]; then
program_name="@:${HOST//.*/}"
# Use "@:!hostname" for root screens.
- elif [[ $program_name == @!screen ]]; then
+ elif [[ $program_name == @!screen || $program_name == @!tmux ]]; then
program_name="@:!${HOST//.*/}"
fi
fi
window_reset=
}
- # Sets the window title. Works with screen, xterm and rxvt. (V) escapes
- # all non-printable characters. Thanks to Mikachu in #zsh on Freenode
- # (2010-08-07 17:09 CEST).
+ # Sets the window title. Works with screen, tmux (which uses screen as
+ # TERM), xterm and rxvt. (V) escapes all non-printable characters. Thanks
+ # to Mikachu in #zsh on Freenode (2010-08-07 17:09 CEST).
if [[ $TERM == screen* ]]; then
window_title() {
print -n "\ek${(V)1}\e\\"