From 7fa0d20d8c452acb8a7d81d6aad5ac7485653f95 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sat, 8 Oct 2011 22:29:26 -0400 Subject: [PATCH] Set Apple Terminal current working directory. --- functions/terminal.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/terminal.zsh b/functions/terminal.zsh index d59056c..2008e49 100644 --- a/functions/terminal.zsh +++ b/functions/terminal.zsh @@ -31,6 +31,7 @@ function set-tab-title() { fi } +# Sets the tab and window titles with the command name. function set-title-by-command() { emulate -L zsh setopt localoptions extended_glob @@ -69,12 +70,15 @@ autoload -Uz add-zsh-hook # Sets the tab and window titles before the prompt is displayed. function set-title-precmd { - if check-bool "$AUTO_TITLE"; then + if [[ "$TERM_PROGRAM" != "Apple_Terminal" ]] && check-bool "$AUTO_TITLE"; then set-window-title "${(%):-%~}" for kind in tab screen; do # Left-truncate the current working directory to 15 characters. set-${kind}-title "${(%):-%15<...<%~%<<}" done + else + # Set Apple Terminal current working directory. + printf '\e]7;%s\a' "file://$HOST${PWD// /%20}" fi } add-zsh-hook precmd set-title-precmd