Setting Mac ITerm tab titles to the current directory
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTNXOwZEectmsNSF6o25ujYRo_xQ57NEI-DvLH_hCsyB9aAlDnirVJvLkI8oyKM2EOBw0qTEnoAAxyjSiQbYz1UiTei9TDpDQwaw87xVwX-u3aRVZ6Z4pZYYRv8H3tBLHZnsdQ9HjQG6XP/s400/Screen+Shot+2017-08-13+at+10.22.12+PM.png)
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