Skip to content

Commit

Permalink
[Fix sorin-ionescu#324] Add configurable terminal window and tab titl…
Browse files Browse the repository at this point in the history
…e formats
  • Loading branch information
sorin-ionescu committed Nov 26, 2013
1 parent 97dd5b4 commit 3a62b3f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
15 changes: 13 additions & 2 deletions modules/terminal/README.md
Expand Up @@ -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
---------

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

16 changes: 13 additions & 3 deletions modules/terminal/init.zsh
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions runcoms/zpreztorc
Expand Up @@ -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
#
Expand Down

0 comments on commit 3a62b3f

Please sign in to comment.