From 4fc6dccb4286828c7cd53d3612ec69b0c0d9aaf2 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 20 Dec 2014 02:24:26 -0500 Subject: [PATCH 1/3] term: Move DISABLE_AUTO_TITLE check to hooks Move the DISABLE_AUTO_TITLE check from title() to the preX hook functions that call it, to allow the title() function to be used directly by user or other callers. --- lib/termsupport.zsh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index bd0cf6ff..2fa61c43 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -1,8 +1,16 @@ -#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 + if [[ $2 == "" ]]; then + 2="$1" + fi + if [[ "$EMACS" == *term* ]]; then return fi if [[ "$TERM" == screen* ]]; then @@ -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 From b7e5dd35efb0750634eb16b7040337ce80f67684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 10 Feb 2015 19:43:25 +0100 Subject: [PATCH 2/3] Quick-fix code style --- lib/termsupport.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 2fa61c43..f21b0b04 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -7,12 +7,12 @@ # (In screen, only short_tab_title is used) # Limited support for Apple Terminal (Terminal can't set window and tab separately) function title { - if [[ $2 == "" ]]; then - 2="$1" - fi - if [[ "$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 From 2e41d06b7655067272cee1e54d2d66693136a90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 10 Feb 2015 19:53:40 +0100 Subject: [PATCH 3/3] Use quoted $TERM value everywhere --- lib/termsupport.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index f21b0b04..58c6203a 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -15,7 +15,7 @@ function title { 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