[Fix #324] Add configurable terminal window and tab title formats

This commit is contained in:
Sorin Ionescu 2013-08-28 17:13:14 -04:00
parent d19c349f3f
commit 254b7c36d9
3 changed files with 32 additions and 5 deletions

View File

@ -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

View File

@ -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.

View File

@ -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
#