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.
This commit is contained in:
Andrew Janke 2014-12-20 02:24:26 -05:00
commit 7a955ed906

View file

@ -1,9 +1,16 @@
#usage: title short_tab_title looooooooooooooooooooooggggggg_windows_title # Set terminal window and tab/icon title
#http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 #
#Fully support screen, iterm, and probably most modern xterm and rxvt # usage: title short_tab_title [long_window_title]
#Limited support for Apple Terminal (Terminal can't set window or tab separately) #
# 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 { function title {
if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then if [[ $2 == "" ]]; then
2="$1"
fi
if [[ "$EMACS" == *term* ]]; then
return return
fi fi
if [[ "$TERM" == screen* ]]; then if [[ "$TERM" == screen* ]]; then
@ -17,13 +24,21 @@ function title {
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
#Appears when you have the prompt # Called when you have a prompt
function omz_termsupport_precmd { function omz_termsupport_precmd {
if [[ $DISABLE_AUTO_TITLE == true ]]; then
return
fi
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
} }
#Appears at the beginning of (and during) of command execution # Called at the beginning of command execution
function omz_termsupport_preexec { function omz_termsupport_preexec {
if [[ $DISABLE_AUTO_TITLE == true ]]; then
return
fi
emulate -L zsh emulate -L zsh
setopt extended_glob setopt extended_glob