From 115add6f227c523332037c373a0294c6a0d46300 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Fri, 8 Aug 2014 18:15:32 +0200 Subject: zshrc: Add git_get_branch and precmd/preexec … MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … for for setting window titles --- zsh/.zshrc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'zsh') diff --git a/zsh/.zshrc b/zsh/.zshrc index 29f863c..ab6638c 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -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 -- cgit v1.2.3-54-g00ecf