aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-08-08 18:15:32 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2014-08-08 18:15:32 +0200
commit115add6f227c523332037c373a0294c6a0d46300 (patch)
tree6de135791610b0ea1bfa677c7356f52a4115694d
parentbaf337979de2832ae6e2fd2d7f40e897d70a2435 (diff)
downloaddotfiles-115add6f227c523332037c373a0294c6a0d46300.tar.xz
zshrc: Add git_get_branch and precmd/preexec …
… for for setting window titles
-rw-r--r--zsh/.zshrc20
1 files changed, 20 insertions, 0 deletions
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