|
|
@ -39,14 +39,13 @@ function set-terminal-tab-title { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Sets the Terminal.app current working directory. |
|
|
|
|
|
|
|
function set-terminal-app-cwd { |
|
|
|
|
|
|
|
printf '\e]7;%s\a' "file://$HOST${PWD// /%20}" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Sets the tab and window titles with a given command. |
|
|
|
# Sets the tab and window titles with a given command. |
|
|
|
function set-titles-with-command { |
|
|
|
function set-titles-with-command { |
|
|
|
# Do not set the window and tab titles in Terminal.app because they are not |
|
|
|
|
|
|
|
# reset upon command termination. |
|
|
|
|
|
|
|
if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then |
|
|
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emulate -L zsh |
|
|
|
emulate -L zsh |
|
|
|
setopt EXTENDED_GLOB |
|
|
|
setopt EXTENDED_GLOB |
|
|
|
|
|
|
|
|
|
|
@ -85,10 +84,6 @@ function set-titles-with-path { |
|
|
|
setopt EXTENDED_GLOB |
|
|
|
setopt EXTENDED_GLOB |
|
|
|
|
|
|
|
|
|
|
|
local absolute_path="${${1:a}:-$PWD}" |
|
|
|
local absolute_path="${${1:a}:-$PWD}" |
|
|
|
|
|
|
|
|
|
|
|
if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then |
|
|
|
|
|
|
|
printf '\e]7;%s\a' "file://$HOST${absolute_path// /%20}" |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
local abbreviated_path="${absolute_path/#$HOME/~}" |
|
|
|
local abbreviated_path="${absolute_path/#$HOME/~}" |
|
|
|
local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}" |
|
|
|
local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}" |
|
|
|
unset MATCH |
|
|
|
unset MATCH |
|
|
@ -99,12 +94,25 @@ function set-titles-with-path { |
|
|
|
set-terminal-window-title "$abbreviated_path" |
|
|
|
set-terminal-window-title "$abbreviated_path" |
|
|
|
set-terminal-tab-title "$truncated_path" |
|
|
|
set-terminal-tab-title "$truncated_path" |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Don't override precmd/preexec; append to hook array. |
|
|
|
# Don't override precmd/preexec; append to hook array. |
|
|
|
autoload -Uz add-zsh-hook |
|
|
|
autoload -Uz add-zsh-hook |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then |
|
|
|
|
|
|
|
# Sets the Terminal.app current working directory. |
|
|
|
|
|
|
|
add-zsh-hook precmd set-terminal-app-cwd |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Do not set the tab and window titles in Terminal.app since it sets the tab |
|
|
|
|
|
|
|
# title to the currently running process by default and the current working |
|
|
|
|
|
|
|
# directory is set separately. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Do set the tab and window titles inside terminal multiplexers. |
|
|
|
|
|
|
|
if [[ "$TERM" != screen* ]]; then |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Sets the tab and window titles before the prompt is displayed. |
|
|
|
# Sets the tab and window titles before the prompt is displayed. |
|
|
|
function set-titles-precmd { |
|
|
|
function set-titles-precmd { |
|
|
|
if zstyle -t ':prezto:module:terminal' auto-title; then |
|
|
|
if zstyle -t ':prezto:module:terminal' auto-title; then |
|
|
|