From: Simon Ruderich Date: Tue, 10 Mar 2009 16:07:26 +0000 (+0100) Subject: zsh: Set window title to current program in stumpwm. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=368bccd998cd8ae4aa843eac5f94513ce610a2a8;p=config%2Fdotfiles.git zsh: Set window title to current program in stumpwm. --- diff --git a/zsh/rc b/zsh/rc index ccd950f..02c13d1 100644 --- a/zsh/rc +++ b/zsh/rc @@ -128,10 +128,19 @@ fi # # When a program is started preexec() sets the window's name to it; when it # stops precmd() resets the windows' name to 'zsh'. +# +# It works with screen and xterm. If screen is running in X11 (DISPLAY is set) +# and stumpwm is used (it's tested if stumpish is available) then the window +# title is also set in stumpwm using stumpish. if [[ $TERM == screen || $TERM == xterm* ]]; then # Set to a non empty value to reset the window name in the next precmd() # call. window_reset=yes + # Set to a non empty value when the stump window manager is available. + which stumpwm &> /dev/null + if [[ $? -eq 0 ]]; then + window_stumpwm=yes + fi window_preexec() { # Get the program name with its arguments. @@ -187,6 +196,13 @@ if [[ $TERM == screen || $TERM == xterm* ]]; then window_title() { if [[ $TERM == screen ]]; then print -n "\ek$1\e\\" + + # Update window name in stumpwm if running screen in X11 and when + # stumpwm is used. + if [[ -n $DISPLAY && -n $window_stumpwm ]]; then + echo "$1" | stumpish -e "title" > /dev/null + fi + elif [[ $TERM == xterm* ]]; then print -n "\e]2;$1\e\\" fi