1
0
Fork 0
dotfiles/zsh/prompt.zsh

70 lines
1.2 KiB
Bash
Raw Normal View History

2013-01-19 13:18:29 +00:00
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=$(/usr/bin/git status 2>/dev/null | tail -n 1)
if [[ $st == "" ]]
then
echo ""
else
if [[ $st == "nothing to commit (working directory clean)" ]]
then
echo " %F{002}($(git_prompt_info))%f"
2013-01-19 13:18:29 +00:00
else
echo " %F{001}($(git_prompt_info))%f"
2013-01-19 13:18:29 +00:00
fi
fi
}
git_prompt_info () {
ref=$(/usr/bin/git symbolic-ref HEAD 2>/dev/null) || return
echo "${ref#refs/heads/}"
}
unpushed () {
if [[ -a .git ]]; then
git diff origin/master..HEAD
fi
2013-01-19 13:18:29 +00:00
}
need_push () {
if [[ $(unpushed) == "" ]]
then
echo ""
else
echo " %F{005}↑↑%f"
2013-01-19 13:18:29 +00:00
fi
}
rb_prompt(){
if $(which rbenv &> /dev/null)
then
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(){
echo "%F{003%}%1/%\%f"
2013-01-19 13:18:29 +00:00
}
export PROMPT=$'\n$(directory_name)$(git_dirty)$(need_push) '
set_prompt () {
export RPROMPT="$(rb_prompt)"
}
precmd() {
title "zsh" "%m" "%55<...<%~"
set_prompt
}