I'm gradually switching from Bash to ZSH, and trying to learn by replicating features. Can't seem to find this one though.
What should I put, and where should I put it? Is this even possible? Thanks.
Try this:
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 print an escape sequence that asks Terminal.app
to update the title. (Oddly enough, using an escape sequence that also works in urxvt
, at least. These must be more standardized than I expected.)
If you like the effect, you'll need to add these lines to your ~/.zshrc
for it to work on future terminals.
I grabbed the correct escape sequence from Chris Page on superuser and the style of functions from my answer to similar but different question. Chris Page gave his own answer on that question with details on OS X 10.7 that are drastically different. When you upgrade you'll probably want to use his mechanism instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With