Forked from phette23/current-dir-in-iterm-tab-title.sh
Last active
May 7, 2018 19:54
-
-
Save kpman/fdfa9093acef93894d12a157d9a672ec to your computer and use it in GitHub Desktop.
Revisions
-
kpman revised this gist
Jul 29, 2016 . 1 changed file with 7 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,17 +3,10 @@ if [ $ITERM_SESSION_ID ]; then export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND"; fi ########################### # ~/.zshrc precmd() { # sets the tab title to current dir echo -ne "\e]1;${PWD##*/}\a" } -
phette23 revised this gist
Mar 30, 2013 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,11 @@ # put this in your .bash_profile if [ $ITERM_SESSION_ID ]; then export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND"; fi # Piece-by-Piece Explanation: # the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment # iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too # the $PROMPT_COMMAND environment variable is executed every time a command is run # see: ss64.com/bash/syntax-prompt.html # we want to update the iTerm tab title to reflect the current directory (not full path, which is too long) -
phette23 created this gist
Mar 29, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # put this in your .bash_profile export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND"; # Piece-by-Piece Explanation: # the $PROMPT_COMMAND environment variable is executed every time a command is run # see: ss64.com/bash/syntax-prompt.html # we want to update the iTerm tab title to reflect the current directory (not full path, which is too long) # echo -ne "\033;foo\007" sets the current tab title to "foo" # see: stackoverflow.com/questions/8823103/how-does-this-script-for-naming-iterm-tabs-work # the two flags, -n = no trailing newline & -e = interpret backslashed characters, e.g. \033 is ESC, \007 is BEL # see: ss64.com/bash/echo.html for echo documentation # we set the title to ${PWD##*/} which is just the current dir, not full path # see: stackoverflow.com/questions/1371261/get-current-directory-name-without-full-path-in-bash-script # then we append the rest of $PROMPT_COMMAND so as not to remove what was already there # voilà!