Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
possible duplicate of Change iTerm2 window and tab titles in zsh – mpy Aug 2 '13 at 7:45
@mpy well that is not really answered my question because when the process is running the name is changed again. – Ali Aug 7 '13 at 3:35
You are right, it does not answer exactly your question. But I was thinking of it as a duplicate, because in the linked answers you get (a.) the escape sequences how to set tab and window title and (b.) the hint about precmd. But I must admit, that in your case it could also be the function preexec which changes your title -- I retracted my close vote. – mpy Aug 7 '13 at 10:53
Thanks. I will do some research on how to do that because it is very annoying not to know which tab is which. – Ali Aug 7 '13 at 12:30
up vote 2 down vote accepted

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.

share|improve this answer

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

echo -ne "\e]1;$PWD\a"
share|improve this answer
I'm not sure if I understand that right, but getting the present working directory overwrite the current job is that the way you do it? – Ali Aug 1 '13 at 18:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .