From cc34e3f310aa6c0e532c70a739b081b89569571f Mon Sep 17 00:00:00 2001 From: Matt Hamilton Date: Sat, 21 Jan 2017 08:54:32 -0800 Subject: [PATCH] [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 --- modules/environment/README.md | 2 ++ modules/environment/init.zsh | 11 +++++++++++ templates/zimrc | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/modules/environment/README.md b/modules/environment/README.md index a8d18dc..e5eec80 100644 --- a/modules/environment/README.md +++ b/modules/environment/README.md @@ -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 ----------- diff --git a/modules/environment/init.zsh b/modules/environment/init.zsh index 81fb23d..0e8fd9d 100644 --- a/modules/environment/init.zsh +++ b/modules/environment/init.zsh @@ -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 diff --git a/templates/zimrc b/templates/zimrc index 8b5e0fd..b37e839 100644 --- a/templates/zimrc +++ b/templates/zimrc @@ -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 #