diff --git a/modules/terminal/README.md b/modules/terminal/README.md index 58f81be1..848ec78a 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 01140d8c..b63e4620 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 a54fdb02..4d3ba60d 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 #