From 4fc6dccb4286828c7cd53d3612ec69b0c0d9aaf2 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Sat, 20 Dec 2014 02:24:26 -0500 Subject: [PATCH] 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 bd0cf6ffe..2fa61c431 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