Merge pull request #3525 from apjanke/term-pwd-in-precmd
Move pwd update output to precmd to avoid contamination
Diff
1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
2index d9f2b64d4548006e901e850560268892b2d1eec6..bd0cf6ffe72864fc4a2610ce17ce1038d226aa7b 100644
3--- a/lib/termsupport.zsh
4+++ b/lib/termsupport.zsh
5@@ -16,12 +16,19 @@ function title {
6 ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
7 ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
8 9-#Appears when you have the prompt
10+# Runs before showing the prompt
11 function omz_termsupport_precmd {
12 title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
13+
14+ # Notify Terminal.app of current directory using undocumented OSC sequence
15+ # found in OS X 10.9 and 10.10's /etc/bashrc
16+ if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then
17+ local PWD_URL="file://$HOSTNAME${PWD// /%20}"
18+ printf '\e]7;%s\a' "$PWD_URL"
19+ fi
20 }
2122-#Appears at the beginning of (and during) of command execution
23+# Runs before executing the command
24 function omz_termsupport_preexec {
25 emulate -L zsh
26 setopt extended_glob
27@@ -33,18 +40,5 @@ function omz_termsupport_preexec {
28 title '$CMD' '%100>...>$LINE%<<'
29 }
3031-#Appears each time pwd is changed
32-function omz_termsupport_chpwd {
33- #Notify Terminal.app of current directory using undocumented OSC sequence
34- #found in OS X 10.10's /etc/bashrc
35- if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then
36- local PWD_URL="file://$HOSTNAME${PWD// /%20}"
37- printf '\e]7;%s\a' "$PWD_URL"
38- fi
39-}
40-#Fire it once so the pwd is set properly upon shell startup
41-omz_termsupport_chpwd
42-
43 precmd_functions+=(omz_termsupport_precmd)
44 preexec_functions+=(omz_termsupport_preexec)
45-chpwd_functions+=(omz_termsupport_chpwd)