2013-01-19 13:18:29 +00:00
|
|
|
|
autoload colors && colors
|
2013-02-22 12:32:41 +00:00
|
|
|
|
|
|
|
|
|
# Using git from Homebrew instead of default one
|
|
|
|
|
git=/usr/local/bin/git
|
2013-01-19 13:18:29 +00:00
|
|
|
|
|
|
|
|
|
git_branch() {
|
2013-02-22 12:32:41 +00:00
|
|
|
|
echo $($git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'})
|
2013-01-19 13:18:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
git_dirty() {
|
2013-02-22 12:32:41 +00:00
|
|
|
|
st=$($git status 2>/dev/null | tail -n 1)
|
2013-01-19 13:18:29 +00:00
|
|
|
|
if [[ $st == "" ]]
|
|
|
|
|
then
|
|
|
|
|
echo ""
|
|
|
|
|
else
|
2013-02-22 12:32:41 +00:00
|
|
|
|
if [[ "$st" =~ ^nothing ]]
|
2013-01-19 13:18:29 +00:00
|
|
|
|
then
|
2013-01-20 09:39:11 +00:00
|
|
|
|
echo " %F{002}($(git_prompt_info))%f"
|
2013-01-19 13:18:29 +00:00
|
|
|
|
else
|
2013-01-20 09:39:11 +00:00
|
|
|
|
echo " %F{001}($(git_prompt_info))%f"
|
2013-01-19 13:18:29 +00:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-19 18:11:41 +00:00
|
|
|
|
git_need_commit() {
|
|
|
|
|
git diff --stat 2>/dev/null | awk -F',' '/files? changed/ { lc += $2 + $3 } END {
|
|
|
|
|
if (lc > 100) print "\n%F{005}Y U NO COMMIT!?%f"
|
|
|
|
|
}'
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 13:18:29 +00:00
|
|
|
|
git_prompt_info () {
|
2013-02-22 12:32:41 +00:00
|
|
|
|
ref=$($git symbolic-ref HEAD 2>/dev/null) || return
|
|
|
|
|
echo "${ref#refs/heads/}"
|
2013-01-19 13:18:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unpushed () {
|
2013-02-22 12:32:41 +00:00
|
|
|
|
$git cherry -v @{upstream} 2>/dev/null
|
2013-01-19 13:18:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
need_push () {
|
|
|
|
|
if [[ $(unpushed) == "" ]]
|
|
|
|
|
then
|
|
|
|
|
echo ""
|
|
|
|
|
else
|
2013-01-20 09:39:11 +00:00
|
|
|
|
echo " %F{005}↑↑%f"
|
2013-01-19 13:18:29 +00:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rb_prompt(){
|
|
|
|
|
if $(which rbenv &> /dev/null)
|
|
|
|
|
then
|
2013-01-20 09:39:11 +00:00
|
|
|
|
echo "%F{004%}$(rbenv version | awk '{print $1}')%f"
|
2013-01-19 13:18:29 +00:00
|
|
|
|
else
|
|
|
|
|
echo ""
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_time(){
|
|
|
|
|
echo 'date +"%d.%m.%Y %H:%M:%S"'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
directory_name(){
|
2013-01-20 09:39:11 +00:00
|
|
|
|
echo "%F{003%}%1/%\%f"
|
2013-01-19 13:18:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-19 18:11:41 +00:00
|
|
|
|
export PROMPT=$'\n$(directory_name)$(git_dirty)$(need_push)$(git_need_commit) › '
|
2013-01-19 13:18:29 +00:00
|
|
|
|
set_prompt () {
|
|
|
|
|
export RPROMPT="$(rb_prompt)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
precmd() {
|
|
|
|
|
title "zsh" "%m" "%55<...<%~"
|
|
|
|
|
set_prompt
|
|
|
|
|
}
|