From a1e61b97206061dee54b1b5d1978b42db9f882b7 Mon Sep 17 00:00:00 2001 From: Akelge Date: Thu, 27 Nov 2014 16:36:19 +0000 Subject: [PATCH] Repo aware prompt --- zsh/zsh.d/50-functions.zsh | 3 +++ zsh/zsh.d/prompts/prompt_nice_setup | 8 ++++---- zsh/zsh.d/zshfunctions/repo_char | 7 +++++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 zsh/zsh.d/zshfunctions/repo_char diff --git a/zsh/zsh.d/50-functions.zsh b/zsh/zsh.d/50-functions.zsh index 3971924..300f445 100644 --- a/zsh/zsh.d/50-functions.zsh +++ b/zsh/zsh.d/50-functions.zsh @@ -19,5 +19,8 @@ autoload -U bak # fancyTerm - returns true if we are on xterm/rxvt/screen, elsewhere false autoload -U fancyTerm +# repo_char - returns a character based on the type of repo we are in +autoload -U repo_char + # vim: set ts=4 sw=4 tw=0 ft=zsh : diff --git a/zsh/zsh.d/prompts/prompt_nice_setup b/zsh/zsh.d/prompts/prompt_nice_setup index 21793b5..0942b44 100644 --- a/zsh/zsh.d/prompts/prompt_nice_setup +++ b/zsh/zsh.d/prompts/prompt_nice_setup @@ -4,14 +4,14 @@ if `fancyTerm`; then I="%m::%." # L="$FX[bold]$FX[italic]$BG[111]$FG[239]@%m::%2~ $BG[000] # $FG[228]%#$FX[reset] " - L="$FX[bold]$FX[italic]$BG[062]@%m::%2~ $BG[000] -$FG[220]%#$FX[reset] " - PS1="%{]2;$W%}%{]1;$I%}$L" +L='$FX[bold]$FX[italic]$BG[062]@%m::%2~$(repo_char)$BG[000] +$FG[220]%#$FX[reset] ' +PS1="%{]2;$W%}%{]1;$I%}$L" unset W I L else # We are not on xterminal - PS1="%B%K{blue}%F{white}[%l] %n@%m:%~ %f%k%F{yellow}%#%f%b " + PS1="%B%K{blue}%F{white}[%l] %n@%m:%~ %f%k%F{yellow}%# $(repo_char)%f%b " fi } diff --git a/zsh/zsh.d/zshfunctions/repo_char b/zsh/zsh.d/zshfunctions/repo_char new file mode 100644 index 0000000..b5bd476 --- /dev/null +++ b/zsh/zsh.d/zshfunctions/repo_char @@ -0,0 +1,7 @@ +function repo_char { +# git branch > /dev/null 2> /dev/null && echo '±' && return +# svn info > /dev/null 2> /dev/null && echo '\u03a3' && return +# echo '\u25cb' + git branch > /dev/null 2> /dev/null && echo ' «git' && return + svn info > /dev/null 2> /dev/null && echo ' «svn' && return +}