1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-24 06:40:07 +00:00

Cleanup update_terminalapp_cwd function

This commit is contained in:
Marc Cornellà 2015-12-01 14:05:38 +01:00
parent eca912e51a
commit 4e306887c2

View file

@ -76,19 +76,18 @@ preexec_functions+=(omz_termsupport_preexec)
# With extra fixes to handle multibyte chars and non-UTF-8 locales # With extra fixes to handle multibyte chars and non-UTF-8 locales
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
# Emits the control sequence to notify Terminal.app of the cwd # Emits the control sequence to notify Terminal.app of the cwd
# Identifies the directory using a file: URI scheme, including
# the host name to disambiguate local vs. remote paths.
function update_terminalapp_cwd() { function update_terminalapp_cwd() {
emulate -L zsh emulate -L zsh
# Identify the directory using a "file:" scheme URL, including
# the host name to disambiguate local vs. remote paths.
# Percent-encode the pathname. # Percent-encode the pathname.
local URL_PATH="$(omz_urlencode -P $PWD)" local URL_PATH="$(omz_urlencode -P $PWD)"
[[ $? != 0 ]] && return 1 [[ $? != 0 ]] && return 1
local PWD_URL="file://$HOST$URL_PATH"
# Undocumented Terminal.app-specific control sequence # Undocumented Terminal.app-specific control sequence
printf '\e]7;%s\a' $PWD_URL printf '\e]7;%s\a' "file://$HOST$URL_PATH"
} }
# Use a precmd hook instead of a chpwd hook to avoid contaminating output # Use a precmd hook instead of a chpwd hook to avoid contaminating output