How to make ZSH display the current directory in the terminal frame?

I gradually switch from Bash to ZSH and try to learn by replicating functions. It seems he cannot find this.

Bash does this by default I think

What should I put, and where to put it? Is it possible? Thanks.

+4
source share
1 answer

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.)

If you like the effect, you need to add these lines to your ~/.zshrc so that it works on future terminals.

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.

+10
source

All Articles