Created
October 2, 2013 17:35
-
-
Save diego-aslz/6797393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload colors && colors | |
# cheers, @ehrenmurdick | |
# http://github.com/ehrenmurdick/config/blob/master/zsh/prompt.zsh | |
git_branch() { | |
echo $(/usr/bin/git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}) | |
} | |
git_dirty() { | |
st=$(git status -sb 2>/dev/null | wc -l) | |
if [[ $st == "0" ]] | |
then | |
echo "" | |
else | |
if [[ $st == "1" ]] | |
then | |
echo " [%{$fg_bold[green]%}$(git_prompt_info)%{$reset_color%}]" | |
else | |
echo " [%{$fg_bold[yellow]%}$(git_prompt_info)%{$reset_color%}]" | |
fi | |
fi | |
} | |
git_prompt_info () { | |
ref=$(/usr/bin/git symbolic-ref HEAD 2>/dev/null) || return | |
echo "${ref#refs/heads/}" | |
} | |
unpushed () { | |
/usr/bin/git cherry -v @{upstream} 2>/dev/null | |
} | |
need_push () { | |
if [[ $(unpushed) == "" ]] | |
then | |
echo "" | |
else | |
echo "[%{$fg_bold[magenta]%}unpushed%{$reset_color%}]" | |
fi | |
} | |
rb_prompt(){ | |
if $(which rbenv &> /dev/null) | |
then | |
echo "%{$fg_bold[red]%}$(whoami)%{$reset_color%}" | |
else | |
echo "" | |
fi | |
} | |
# This keeps the number of todos always available the right hand side of my | |
# command line. I filter it to only count those tagged as "+next", so it's more | |
# of a motivation to clear out the list. | |
todo(){ | |
if $(which todo.sh &> /dev/null) | |
then | |
num=$(echo $(todo.sh ls +next | wc -l)) | |
let todos=num-2 | |
if [ $todos != 0 ] | |
then | |
echo "$todos" | |
else | |
echo "" | |
fi | |
else | |
echo "" | |
fi | |
} | |
svn_graph(){ | |
if [ -d .svn ]; then | |
echo `svn stat | awk '{ split($0, a, " ") arr[a[1]]++ }END{ print arr["M"] ? arr["M"] : "0", arr["A"] ? arr["A"] : "0", arr["?"] ? arr["?"] : "0", arr["D"] ? arr["D"] : "0", arr["!"] ? arr["!"] : "0" }' | spark` | |
fi | |
} | |
directory_name(){ | |
echo ":%{$fg_bold[cyan]%}$(pwd)/%{$reset_color%}" | |
} | |
export PROMPT_COUNT=0 | |
prompt() { | |
default=" › " | |
[[ "$PROMPT_COUNT" == "0" ]] && echo "$(rb_prompt)$(directory_name)$(git_dirty)$(need_push)\n$default" || echo $default | |
export PROMPT_COUNT=$(($PROMPT_COUNT + 1)) | |
[[ "$PROMPT_COUNT" < "5" ]] || export PROMPT_COUNT=0 | |
} | |
export PROMPT=$'$(prompt)' | |
set_prompt () { | |
export RPROMPT="%{$fg_bold[cyan]%}$(todo)%{$reset_color%}" | |
} | |
precmd() { | |
title "zsh" "%m" "%55<...<%~" | |
set_prompt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment