Customize titles of your terminal window

2012-02-28  |   |  Mac OS X   tool  

If you are like me, you use many many tabs in your command line terminal. By the way, iTerm2 is a very nice improvement over the vanilla OS X Terminal app.

To recognize tabs, I like to display the name of the current directory and add the directory it is contained in if more space are left. Open your .bash_profile or .profile file and add the following

function local_dir_and_within {

__LAST="${PWD##*/}"

__IN="${PWD%/*}"

__IN="${__IN/#$HOME/~}"

TITLE_TAB="$__LAST in $__IN"

echo -n $TITLE_TAB

}

export PROMPT_COMMAND='echo -ne "\033]0;$(local_dir_and_within)\007"'

Your tab title will now look like hibernate-search in ~/code.


Name: Emmanuel Bernard
Bio tags: French, Open Source actor, Hibernate, (No)SQL, JCP, JBoss, Snowboard, Economy
Employer: JBoss by Red Hat
Resume: LinkedIn
Team blog: in.relation.to
Personal blog: No relation to
Microblog: Twitter, Google+
Geoloc: Paris, France

Tags