I gradually switch from Bash to ZSH and try to learn by replicating functions. It seems he cannot find this.
What should I put, and where to put it? Is it possible? Thanks.
Try the following:
settitle() { printf "\e]0; $@ \a" } dir_in_title() { settitle $PWD } chpwd_functions=(dir_in_title)
Now your cd commands will run the dir_in_title function, which will output an escape sequence requesting Terminal.app to update the header. (Oddly enough, using an escape sequence that also works in urxvt , at least. They should be more standardized than I expected.)
cd
dir_in_title
Terminal.app
urxvt
If you like the effect, you need to add these lines to your ~/.zshrc so that it works on future terminals.
~/.zshrc
I grabbed the correct escape sequence from Chris Page to the superuser and the style of the functions from my answer to a similar but different question . Chris Page gave his own answer to this question with details regarding OS X 10.7, which are very different . When upgrading, you will most likely want to use your own mechanism.