diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2014-08-08 18:15:32 +0200 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2014-08-08 18:15:32 +0200 |
commit | 115add6f227c523332037c373a0294c6a0d46300 (patch) | |
tree | 6de135791610b0ea1bfa677c7356f52a4115694d | |
parent | baf337979de2832ae6e2fd2d7f40e897d70a2435 (diff) | |
download | dotfiles-115add6f227c523332037c373a0294c6a0d46300.tar.xz |
zshrc: Add git_get_branch and precmd/preexec …
… for for setting window titles
-rw-r--r-- | zsh/.zshrc | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -38,6 +38,26 @@ setopt autocd \ # Menu completion zstyle ':completion:*' menu select +function get_git_branch { + if [[ -d .git ]]; then + branch=" $(git rev-parse --abbrev-ref HEAD) " + else + branch=" " + fi +} + +# Print basic prompt to the window title +function precmd { + print -Pn "\e];%n %~\a" + get_git_branch +} + +# Print the current running command's name to the window title +function preexec { + local cmd=${1[(wr)^(*=*|sudo|exec|ssh|-*)]} + print -Pn "\e];$cmd:q\a" +} + if [[ $TERM == xterm-termite && $DISPLAY == ":0" ]]; then . /etc/profile.d/vte.sh __vte_osc7 |