Last active
February 15, 2018 14:11
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### | |
# 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