From 254b7c36d97a0fbe76ba81541e1f76f52120c841 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Wed, 28 Aug 2013 17:13:14 -0400 Subject: [PATCH] [Fix #324] Add configurable terminal window and tab title formats --- modules/terminal/README.md | 15 +++++++++++++-- modules/terminal/init.zsh | 16 +++++++++++++--- runcoms/zpreztorc | 6 ++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/modules/terminal/README.md b/modules/terminal/README.md index 76ce1c7..435d972 100644 --- a/modules/terminal/README.md +++ b/modules/terminal/README.md @@ -17,6 +17,16 @@ Auto titling is disabled inside terminal multiplexers, except inside dvtm, since it interferes with window names defined in configuration files and profile managers. +To format terminal window and tab titles, add the following to *zpreztorc*: + + zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' + zstyle ':prezto:module:terminal:tab-title' format '%m: %s' + +`%s` will be replaced with the current working directory path or the currently +executing program name. + +For a list of sequences, see [Expansion of Prompt Sequences][1]. + Functions --------- @@ -26,9 +36,10 @@ Functions Authors ------- -*The authors of this module should be contacted via the [issue tracker][1].* +*The authors of this module should be contacted via the [issue tracker][2].* - [Sorin Ionescu](https://github.com/sorin-ionescu) -[1]: https://github.com/sorin-ionescu/prezto/issues +[1]: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Expansion-of-Prompt-Sequences +[2]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index d49fd15..eeca67e 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -12,16 +12,26 @@ fi # Sets the terminal or terminal multiplexer window title. function set-window-title { + local title_format{,ted} + zstyle -s ':prezto:module:terminal:window-title' format 'title_format' || title_format="%s" + zformat -f title_formatted "$title_format" "s:$argv" + if [[ "$TERM" == screen* ]]; then - printf "\ek%s\e\\" ${(V)argv} + title_format="\ek%s\e\\" else - printf "\e]2;%s\a" ${(V)argv} + title_format="\e]2;%s\a" fi + + printf "$title_format" "${(V%)title_formatted}" } # Sets the terminal tab title. function set-tab-title { - printf "\e]1;%s\a" ${(V)argv} + local title_format{,ted} + zstyle -s ':prezto:module:terminal:tab-title' format 'title_format' || title_format="%s" + zformat -f title_formatted "$title_format" "s:$argv" + + printf "\e]1;%s\a" ${(V%)title_formatted} } # Sets the tab and window titles with a given command. diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index b045cab..9dd6c5d 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -130,6 +130,12 @@ zstyle ':prezto:module:prompt' theme 'sorin' # Auto set the tab and window titles. # zstyle ':prezto:module:terminal' auto-title 'yes' +# Set the window title format. +# zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' + +# Set the tab title format. +# zstyle ':prezto:module:terminal:tab-title' format '%m: %s' + # # Tmux #