mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-11-11 03:01:51 -05:00
fix(termsupport): improve Apple Terminal support (#14172)
This commit is contained in:
+7
-5
@@ -5,7 +5,6 @@
|
|||||||
# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
|
# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
|
||||||
# Fully supports screen, iterm, and probably most modern xterm and rxvt
|
# Fully supports screen, iterm, and probably most modern xterm and rxvt
|
||||||
# (In screen, only short_tab_title is used)
|
# (In screen, only short_tab_title is used)
|
||||||
# Limited support for Apple Terminal (Terminal can't set window and tab separately)
|
|
||||||
function title {
|
function title {
|
||||||
setopt localoptions nopromptsubst
|
setopt localoptions nopromptsubst
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ function title {
|
|||||||
: ${2=$1}
|
: ${2=$1}
|
||||||
|
|
||||||
case "$TERM" in
|
case "$TERM" in
|
||||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*|wezterm*)
|
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*|wezterm*|nsterm*)
|
||||||
print -Pn "\e]2;${2:q}\a" # set window name
|
print -Pn "\e]2;${2:q}\a" # set window name
|
||||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||||
;;
|
;;
|
||||||
@@ -26,10 +25,12 @@ function title {
|
|||||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus/tmux window name if `allow-rename` is on
|
print -Pn "\ek${1:q}\e\\" # set screen hardstatus/tmux window name if `allow-rename` is on
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
case "$TERM_PROGRAM" in
|
||||||
|
"iTerm.app"|"Apple_Terminal")
|
||||||
print -Pn "\e]2;${2:q}\a" # set window name
|
print -Pn "\e]2;${2:q}\a" # set window name
|
||||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||||
else
|
;;
|
||||||
|
*)
|
||||||
# Try to use terminfo to set the title if the feature is available
|
# Try to use terminfo to set the title if the feature is available
|
||||||
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
|
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
|
||||||
# Emit the capabilities with echoti so terminfo does its own parameter
|
# Emit the capabilities with echoti so terminfo does its own parameter
|
||||||
@@ -39,7 +40,8 @@ function title {
|
|||||||
print -Pn "$1"
|
print -Pn "$1"
|
||||||
echoti fsl
|
echoti fsl
|
||||||
fi
|
fi
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user