From 0248538340fa980a7a48afd780789c9159055c66 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 24 Feb 2009 21:11:55 +0100 Subject: added current git branch to prompt --- .zsh/rc/15prompt | 10 +++++++++- .zsh/rc/50options | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) (limited to '.zsh') diff --git a/.zsh/rc/15prompt b/.zsh/rc/15prompt index c972c8a..5eb75ec 100644 --- a/.zsh/rc/15prompt +++ b/.zsh/rc/15prompt @@ -19,6 +19,9 @@ prompt_eof_setup() { prompt_eof_setup "$@" + + + # function to show the current git branch in prompt parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' @@ -27,10 +30,15 @@ parse_git_branch() { #-------------------- # Prompt #-------------------- -#PS1="[${fg_cyan}%*${fg_no_colour}] - ${fg_light_red}$USERNAME${fg_no_colour} ${fg_light_blue}%~${fg_no_colour} > " +# necessary if you want to use functions in the prompt +# without this they wouldn't be run again +precmd () { +# this has to be on the edge or you have some spaces in the prompt +# if you have any workaround please tell PS1="${fg_light_red}$USERNAME${fg_no_colour}@${fg_light_green}%m${fg_no_colour} \ - ${fg_light_blue}%~${fg_no_colour} ${fg_purple}$(parse_git_branch)${fg_no_colour} [${fg_cyan}%*${fg_no_colour}] > " +} ## Spelling prompt SPROMPT='zsh: correct '%R' to '%r' ? ([Y]es/[N]o/[E]dit/[A]bort) ' diff --git a/.zsh/rc/50options b/.zsh/rc/50options index fda3936..0b6d237 100644 --- a/.zsh/rc/50options +++ b/.zsh/rc/50options @@ -43,3 +43,4 @@ setopt EXTENDED_HISTORY setopt HIST_REDUCE_BLANKS setopt HIST_IGNORE_SPACE setopt nohistverify +setopt prompt_subst -- cgit v1.2.3-24-g4f1b