[environment] add customizable term title

Adds customizable terminal/window title. Set `${ztermtitle}` in `.zimrc`
to use this functionality.

Check the notes added in templates/zimrc for additional usage info.

Closes #52
This commit is contained in:
Matt Hamilton 2017-01-21 08:54:32 -08:00
parent 2c0cc6fbd7
commit cc34e3f310
3 changed files with 24 additions and 0 deletions

View File

@ -5,6 +5,8 @@ Sets generic Zsh built-in environment options.
Also enables smart URL-pasting. This prevents the user from having to manually escape URLs.
Uses `.zimrc` defined `${ztermtitle}` variable to set the terminal title, if defined.
ZSH Options
-----------

View File

@ -46,3 +46,14 @@ if [[ -z ${PAGER} ]]; then
export PAGER=more
fi
fi
# sets the window title and updates upon directory change
# more work probably needs to be done here to support multiplexers
if (($+ztermtitle)); then
case ${TERM} in
xterm*)
precmd() { print -Pn "\e]0;${ztermtitle}\a" }
precmd # we execute it once to initialize the window title
;;
esac
fi

View File

@ -42,6 +42,17 @@ zprompt_theme='steeef'
# See: http://zsh.sourceforge.net/Doc/Release/Options.html#Input_002fOutput
#setopt CORRECT
#
# Environment
#
# Set the string below to the desired terminal title format string.
# The terminal title is redrawn upon directory change, however, variables like
# ${PWD} are only evaluated once. Use prompt expansion strings for dynamic data:
# http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
# The example below uses the following format: 'username@host:/current/directory'
ztermtitle='%n@%m:%~'
#
# Input
#