Posts

Showing posts from August, 2017

Setting Mac ITerm tab titles to the current directory

Image
It is easy to set the iTerm titles to final part of the current working directory and the iTerm window title to be the full path of current tab. Start a new terminal window or tab after making the following changes.  New tabs and iTerm windows create new login sessions that read these file contents. Modify ~/.bashrc Edit  ~/.bashrc.  Create ~/.bashrc if it doesn't exist. Add the following text to the file.  Note that this text has comments that document where I found this on the internet # https://gist.github.com/phette23/5270658#gistcomment-1265682 # https://github.com/fish-shell/fish-shell/issues/2692 # Set iTerm2 tab titles to the last directory in PWD tabTitle() { echo -ne "\033]0;"$*"\007"; } # Set iTerm2 win titles to the full directory of PWD winTitle() { echo -ne "\033]2;"$*"\007"; } # Alias 'cd' to list directory and set title cd() { builtin cd "$@"; ls -lFah; tabTitle ${PWD