summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2015-02-10 11:49:56 -0800
committerRobby Russell <robby@planetargon.com>2015-02-10 11:49:56 -0800
commitef7e53a78d0e4196c2d1e6e5b268209759d51753 (patch)
tree3db85360933644a01c5dd692a517a41b16b2a4fe
parent6aa9720b4bfdb1fd909ff09c8c422968aeb5af4c (diff)
parent2e41d06b7655067272cee1e54d2d66693136a90f (diff)
downloadzsh-ef7e53a78d0e4196c2d1e6e5b268209759d51753.tar.gz
zsh-ef7e53a78d0e4196c2d1e6e5b268209759d51753.tar.bz2
zsh-ef7e53a78d0e4196c2d1e6e5b268209759d51753.zip
Merge pull request #3568 from mcornella/apjanke-title-disable-check
Repost #3426: move DISABLE_AUTO_TITLE check to hooks
-rw-r--r--lib/termsupport.zsh30
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index bd0cf6ffe..58c6203a0 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -1,13 +1,21 @@
-#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title
-#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
-#Fully support screen, iterm, and probably most modern xterm and rxvt
+# Set terminal window and tab/icon title
+#
+# usage: title short_tab_title [long_window_title]
+#
+# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
+# Fully supports screen, iterm, and probably most modern xterm and rxvt
+# (In screen, only short_tab_title is used)
+# Limited support for Apple Terminal (Terminal can't set window and tab separately)
function title {
- if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then
- return
- fi
+ [[ "$EMACS" == *term* ]] && return
+
+ # if $2 is unset use $1 as default
+ # if it is set and empty, leave it as is
+ : ${2=$1}
+
if [[ "$TERM" == screen* ]]; then
print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
- elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ $TERM == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == rxvt* ]] || [[ "$TERM" == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
print -Pn "\e]2;$2:q\a" #set window name
print -Pn "\e]1;$1:q\a" #set icon (=tab) name
fi
@@ -18,6 +26,10 @@ ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
# Runs before showing the prompt
function omz_termsupport_precmd {
+ if [[ $DISABLE_AUTO_TITLE == true ]]; then
+ return
+ fi
+
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
# Notify Terminal.app of current directory using undocumented OSC sequence
@@ -30,6 +42,10 @@ function omz_termsupport_precmd {
# Runs before executing the command
function omz_termsupport_preexec {
+ if [[ $DISABLE_AUTO_TITLE == true ]]; then
+ return
+ fi
+
emulate -L zsh
setopt extended_glob