Skip to content

Instantly share code, notes, and snippets.

@benvium
Last active February 15, 2018 14:11
Show Gist options
  • Save benvium/15a5156f4c0eb25173ce688704665c42 to your computer and use it in GitHub Desktop.
Save benvium/15a5156f4c0eb25173ce688704665c42 to your computer and use it in GitHub Desktop.
iTerm - Display the current folder name at the top of tabs, and update when changing directory.
#####
# iTerm - Display the current folder name at the top of tabs, and update when changing directory.
#
# Based on https://gist.github.com/phette23/5270658, with suggestions from the commments there
#####
addToPromptCommand() {
if [[ ":$PROMPT_COMMAND:" != *":$1:"* ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND:+"$PROMPT_COMMAND:"}$1"
fi
}
# Set iTerm title to show current directory
if [ $ITERM_SESSION_ID ]; then
addToPromptCommand 'echo -ne "\033];${PWD##*/}\007"'
fi
# Set iTerm2 tab titles
tabTitle() { echo -ne "\033]0;"$*"\007"; }
# Always list directory contents and set title upon 'cd'
cd() { builtin cd "$@"; ls -lFah; tabTitle ${PWD##*/}; }
#####
# End iTerm Tab Folder names
#####
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment