3

I'm running iTerms on my Mac OS X with zsh. With my workflow I have to switch between tab a lot and sometime I have to spend too much time just to find which tab is the one I'm looking for because all of them having the same name.

enter image description here

As you can see from the screenshot above. Now that would be very useful for me to at least display the Tab Title to the current working directory instead of the Job name in iTerms for zsh

I have looked at the preferences and there is no option for that. It will only display the CWD when the job is not running but once it is running then the job name will be display instead.

Ali
  • 1,361

2 Answers2

3

Check the hook functions precmd and preexec with which precmd and which preexec, resp.:

precmd Executed before each prompt. (...)

preexec Executed just after a command has been read and is about to be executed. (...) The actual command that will be executed (including expanded aliases) is passed in two different forms: the second argument is a single-line, size-limited version of the command (with things like function bodies elided); the third argument contains the full text that is being executed.

Probably in preexec there is some code which changes the tab title to $2 or $3.

As a first test you can disable both hook functions completely (precmd() {}, preexec() {}), set the title manually (echo -ne "\e]1;TEST\a") and check if it remains if you execute a command.

Then try to find the source of the original setting, either in you personal RC files (~/.zshrc) or the system wide ones (/etc/zsh*).

If sucessful, you can think about a sensible tab title and put the echo command to precmd like suggested by @Tiago.

mpy
  • 28,816
2

Edit your zsh configuration files to set the title in the precmd() function to e.g. $PWD.

echo -ne "\e]1;$PWD\a"
stderr
  • 10,569
  • 2
  • 36
  • 50