From b5bcc89ae60bae4798bb241e3dd2950be9a86407 Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Mon, 28 Apr 2014 04:19:52 +0200 Subject: [PATCH] Choose title for terminal multiplexers --- modules/terminal/README.md | 8 ++++++++ modules/terminal/init.zsh | 20 +++++++++++++++++--- runcoms/zpreztorc | 3 +++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/modules/terminal/README.md b/modules/terminal/README.md index 58f81be..848ec78 100644 --- a/modules/terminal/README.md +++ b/modules/terminal/README.md @@ -17,6 +17,8 @@ Auto titling is disabled inside terminal multiplexers, except inside dvtm, since it interferes with window names defined in configuration files and profile managers. +### Title formats + To format terminal window and tab titles, add the following to *zpreztorc*: zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' @@ -27,6 +29,11 @@ executing program name. For a list of sequences, see [Expansion of Prompt Sequences][1]. +Users of terminal multiplexers like screen can choose which title format should +be used (`window-title` or `tab-title`). + + zstyle ':prezto:module:terminal' multiplexer-title 'window-title' + Functions --------- @@ -39,6 +46,7 @@ Authors *The authors of this module should be contacted via the [issue tracker][2].* - [Sorin Ionescu](https://github.com/sorin-ionescu) + - [Olaf Conradi](https://github.com/oohlaf) [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 01140d8..b63e462 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -3,6 +3,7 @@ # # Authors: # Sorin Ionescu +# Olaf Conradi # # Return if requirements are not found. @@ -10,13 +11,18 @@ if [[ "$TERM" == (dumb|linux|*bsd*) ]]; then return 1 fi +# Set default title for terminal multiplexers to the window title. +zstyle ':prezto:module:terminal' multiplexer-title 'window-title' + # 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 + if zstyle -t ':prezto:module:terminal' multiplexer-title 'window-title' \ + && [[ "$TERM" == screen* ]] + then title_format="\ek%s\e\\" else title_format="\e]2;%s\a" @@ -25,13 +31,21 @@ function set-window-title { printf "$title_format" "${(V%)title_formatted}" } -# Sets the terminal tab title. +# Sets the terminal or terminal multiplexer tab title. function set-tab-title { 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} + if zstyle -t ':prezto:module:terminal' multiplexer-title 'tab-title' \ + && [[ "$TERM" == screen* ]] + then + title_format="\ek%s\e\\" + else + title_format="\e]1;%s\a" + fi + + printf "$title_format" "${(V%)title_formatted}" } # Sets the tab and window titles with a given command. diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index a54fdb0..4d3ba60 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -143,6 +143,9 @@ zstyle ':prezto:module:prompt' theme 'sorin' # Set the tab title format. # zstyle ':prezto:module:terminal:tab-title' format '%m: %s' +# Choose tab-title as the multiplexer title +# zstyle ':prezto:module:terminal' multiplexer-title 'tab-title' + # # Tmux #