Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Display latest jobs in Terminal titles (revisited)' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Display latest jobs in Terminal titles (revisited)
Authored by: wgscott on Jul 02, '07 01:17:53PM
In zsh, I like to display by default the current working directory along with the penultimate directory in iTerm's tab. I also like it to display the active program only while it is running (eg vim, man), and then automatically return to the default tab label. I've been using this pair of functions to do so:

function preexec { printf "\e]1; $(history $HISTCMD | cut -b7- ) \a" }
function precmd { printf "\e]1;$PWD:h:t/$PWD:t\a" }

Note that
\e]1
puts the label in the tab only (or the xterm icon label),
\e]2
in the title only, and
\e]0
in both. I also use the
chpwd
function to set both the title bar and tab to new values when the PWD is changed (cd is executed), i.e.,

function chpwd { printf "\e]2;[zsh] $HOST:r:r::$PWD\a" ; printf "\e]1;$PWD:h:t/$PWD:t\a" }

[ Reply to This | # ]