Diff
1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
2index 9d668160310c53516cf81d0366d96a3cd3f8d285..d9f2b64d4548006e901e850560268892b2d1eec6 100644
3--- a/lib/termsupport.zsh
4+++ b/lib/termsupport.zsh
5@@ -1,7 +1,6 @@
6 #usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title
7 #http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
8 #Fully support screen, iterm, and probably most modern xterm and rxvt
9-#Limited support for Apple Terminal (Terminal can't set window or tab separately)
10 function title {
11 if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then
12 return
13@@ -10,7 +9,7 @@ function title {
14 print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
15 elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ $TERM == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
16 print -Pn "\e]2;$2:q\a" #set window name
17- print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
18+ print -Pn "\e]1;$1:q\a" #set icon (=tab) name
19 fi
20 }
21
22@@ -34,5 +33,18 @@ function omz_termsupport_preexec {
23 title '$CMD' '%100>...>$LINE%<<'
24 }
25
26+#Appears each time pwd is changed
27+function omz_termsupport_chpwd {
28+ #Notify Terminal.app of current directory using undocumented OSC sequence
29+ #found in OS X 10.10's /etc/bashrc
30+ if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then
31+ local PWD_URL="file://$HOSTNAME${PWD// /%20}"
32+ printf '\e]7;%s\a' "$PWD_URL"
33+ fi
34+}
35+#Fire it once so the pwd is set properly upon shell startup
36+omz_termsupport_chpwd
37+
38 precmd_functions+=(omz_termsupport_precmd)
39 preexec_functions+=(omz_termsupport_preexec)
40+chpwd_functions+=(omz_termsupport_chpwd)