浏览代码

Extract CWD notifier back out of auto-title hooks

Marc Cornellà 10 年之前
父节点
当前提交
3704fbb71e
共有 1 个文件被更改,包括 13 次插入7 次删除
  1. 13 7
      lib/termsupport.zsh

+ 13 - 7
lib/termsupport.zsh

@@ -31,13 +31,6 @@ function omz_termsupport_precmd {
   fi
 
   title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
-
-  # Notify Terminal.app of current directory using undocumented OSC sequence
-  # found in OS X 10.9 and 10.10's /etc/bashrc
-  if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then
-    local PWD_URL="file://$HOSTNAME${PWD// /%20}"
-    printf '\e]7;%s\a' "$PWD_URL"
-  fi
 }
 
 # Runs before executing the command
@@ -58,3 +51,16 @@ function omz_termsupport_preexec {
 
 precmd_functions+=(omz_termsupport_precmd)
 preexec_functions+=(omz_termsupport_preexec)
+
+
+# Runs before showing the prompt, to update the current directory in Terminal.app
+function omz_termsupport_cwd {
+  # Notify Terminal.app of current directory using undocumented OSC sequence
+  # found in OS X 10.9 and 10.10's /etc/bashrc
+  if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then
+    local PWD_URL="file://$HOSTNAME${PWD// /%20}"
+    printf '\e]7;%s\a' "$PWD_URL"
+  fi
+}
+
+precmd_functions+=(omz_termsupport_cwd)