summaryrefslogtreecommitdiff
path: root/lib/termsupport.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/termsupport.zsh')
-rw-r--r--lib/termsupport.zsh16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index d67223caa..654927a1c 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -105,8 +105,9 @@ function omz_termsupport_preexec {
title '$CMD' '%100>...>$LINE%<<'
}
-precmd_functions+=(omz_termsupport_precmd)
-preexec_functions+=(omz_termsupport_preexec)
+autoload -U add-zsh-hook
+add-zsh-hook precmd omz_termsupport_precmd
+add-zsh-hook preexec omz_termsupport_preexec
# Keep Apple Terminal.app's current working directory updated
@@ -120,16 +121,17 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
function update_terminalapp_cwd() {
emulate -L zsh
- # Percent-encode the pathname.
- local URL_PATH="$(omz_urlencode -P $PWD)"
- [[ $? != 0 ]] && return 1
+ # Percent-encode the host and path names.
+ local URL_HOST URL_PATH
+ URL_HOST="$(omz_urlencode -P $HOST)" || return 1
+ URL_PATH="$(omz_urlencode -P $PWD)" || return 1
# Undocumented Terminal.app-specific control sequence
- printf '\e]7;%s\a' "file://$HOST$URL_PATH"
+ printf '\e]7;%s\a' "file://$URL_HOST$URL_PATH"
}
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
- precmd_functions+=(update_terminalapp_cwd)
+ add-zsh-hook precmd update_terminalapp_cwd
# Run once to get initial cwd set
update_terminalapp_cwd
fi