|
|
|
@ -39,6 +39,17 @@ function set-terminal-tab-title {
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Sets the OSX Terminal.app document/directory URL.
|
|
|
|
|
# This has the following effects:
|
|
|
|
|
# - a title bar shows an icon and a basename of the given document/directory
|
|
|
|
|
# - the icon can be dragged with a mouse like any other file
|
|
|
|
|
# - right-clicking the title shows a file hierarchy menu
|
|
|
|
|
function set-terminal-app-document-url {
|
|
|
|
|
if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then
|
|
|
|
|
printf '\e]7;%s\a' ${(V)argv}
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Sets the tab and window titles with a given command.
|
|
|
|
|
function set-titles-with-command {
|
|
|
|
|
# Do not set the window and tab titles in Terminal.app because they are not
|
|
|
|
@ -85,20 +96,18 @@ function set-titles-with-path {
|
|
|
|
|
setopt EXTENDED_GLOB
|
|
|
|
|
|
|
|
|
|
local absolute_path="${${1:a}:-$PWD}"
|
|
|
|
|
local abbreviated_path="${absolute_path/#$HOME/~}"
|
|
|
|
|
local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}"
|
|
|
|
|
unset MATCH
|
|
|
|
|
|
|
|
|
|
if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]]; then
|
|
|
|
|
printf '\e]7;%s\a' "file://$HOST${absolute_path// /%20}"
|
|
|
|
|
set-terminal-app-document-url "file://$HOST${absolute_path// /%20}"
|
|
|
|
|
set-terminal-tab-title "$truncated_path"
|
|
|
|
|
elif [[ "$TERM" == screen* ]]; then
|
|
|
|
|
set-screen-window-title "$truncated_path"
|
|
|
|
|
else
|
|
|
|
|
local abbreviated_path="${absolute_path/#$HOME/~}"
|
|
|
|
|
local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}"
|
|
|
|
|
unset MATCH
|
|
|
|
|
|
|
|
|
|
if [[ "$TERM" == screen* ]]; then
|
|
|
|
|
set-screen-window-title "$truncated_path"
|
|
|
|
|
else
|
|
|
|
|
set-terminal-window-title "$abbreviated_path"
|
|
|
|
|
set-terminal-tab-title "$truncated_path"
|
|
|
|
|
fi
|
|
|
|
|
set-terminal-window-title "$abbreviated_path"
|
|
|
|
|
set-terminal-tab-title "$truncated_path"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|