From 14a1ce80bbf7362ab2856cdd050714f02649fe3f Mon Sep 17 00:00:00 2001 From: James Adam Date: Tue, 20 Oct 2009 06:24:21 +0800 Subject: Added my prompt theme, with a tweak to the core oh-my-zsh to support it. My git_prompt_info function not only reports the branch and dirty status, but also whether or not the branch is ahead or behind of the remote, or both. It also switches the prompt colour from green to red if the previous command exited with a non-zero value (i.e. failed). --- themes/lazyatom.zsh-theme | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 themes/lazyatom.zsh-theme (limited to 'themes') diff --git a/themes/lazyatom.zsh-theme b/themes/lazyatom.zsh-theme new file mode 100644 index 000000000..6263bc2b7 --- /dev/null +++ b/themes/lazyatom.zsh-theme @@ -0,0 +1,40 @@ +git_prompt_info() { + branch=$(git symbolic-ref HEAD 2> /dev/null) || return + git_status="$(git status 2> /dev/null)" + state="" + case $git_status in + *Changed\ but\ not\ updated*) + state="%{$fg[red]%}⚡" + ;;; + *Untracked\ files*) + state="%{$fg[red]%}⚡" + ;;; + esac + + remote="" + case $git_status in + *Your\ branch\ is\ ahead*) + remote="%{$fg[yellow]%}↑" + ;;; + + *Your\ branch\ is\ behind*) + remote="%{$fg[yellow]%}↓" + ;;; + + "Your branch and") + remote="%{$fg[yellow]%}" + ;;; + esac + echo " %{$fg[yellow]%}(${branch#refs/heads/})${remote}${state}" +} + +function oh_my_zsh_theme_precmd() { + local previous_return_value=$?; + prompt="%{$fg[light_gray]%}%c%{$fg[yellow]%}$(git_prompt_info)%{$fg[white]%}" + if test $previous_return_value -eq 0 + then + export PROMPT="%{$fg[green]%}➜ %{$fg[white]%}${prompt}%{$fg[green]%} $%{$fg[white]%} " + else + export PROMPT="%{$fg[red]%}➜ %{$fg[white]%}${prompt}%{$fg[red]%} $%{$fg[white]%} " + fi +} \ No newline at end of file -- cgit v1.2.3-70-g09d2