FAQ から抜粋。 > 3.6: How do I automatically display the directory in my xterm title bar? > > You should use the special function `chpwd', which is called when > the directory changes. The following checks that standard output is > a terminal, then puts the directory in the title bar if the terminal > is an xterm or some close relative, or a sun-cmd. > > chpwd() { > [[ -t 1 ]] || return > case $TERM in > sun-cmd) print -Pn "\e]l%~\e\\" > ;; > *xterm*|rxvt|(dt|k|E)term) print -Pn "\e]2;%~\a" > ;; > esac > } > > Change `%~' if you want the message to be different. (The `-P' > option interprets such sequences just like in prompts, in this case > producing the current directory; you can of course use `$PWD' here, > but that won't use the `~' notation which I find clearer.) Note that > when the xterm starts up you will probably want to call chpwd > directly: just put `chpwd' in .zshrc after it is defined or autoloaded.