Update mercurial plugin

This commit is contained in:
Stéphane GAUTIER 2012-01-06 15:01:40 +01:00
commit 6e69c4d002
2 changed files with 81 additions and 0 deletions

View file

@ -1,3 +1,74 @@
## Source : https://bitbucket.org/Josh/mercurial-for-zsh
function chpwd_update_hg_vars() {
update_current_hg_vars
}
function precmd_update_hg_vars(){
if [ -n "$__EXECUTED_HG_COMMAND" ]; then
update_current_hg_vars
unset __EXECUTED_HG_COMMAND
fi
}
function preexec_update_hg_vars(){
case "$1" in
hg*)
export __EXECUTED_HG_COMMAND=1
;;
esac
}
function prompt_hg_info(){
if [ -n "$__CURRENT_HG_BRANCH" ]; then
local s="["
s+="$__CURRENT_HG_BRANCH"
case "$__CURRENT_HG_BRANCH_STATUS" in
ahead)
s+="↑"
;;
diverged)
s+="↕"
;;
behind)
s+="↓"
;;
esac
if [ -n "$__CURRENT_HG_BRANCH_IS_DIRTY" ]; then
s+="⚡"
fi
s+="] "
printf " %s%s" "%{${fg[yellow]}%}" $s
fi
}
function update_current_hg_vars(){
unset __CURRENT_HG_BRANCH
unset __CURRENT_HG_BRANCH_STATUS
unset __CURRENT_HG_BRANCH_IS_DIRTY
local st="$(hg status 2>/dev/null)"
local br="$(hg branch 2>/dev/null)"
if [ -n "$br" ]; then
local -a arr
arr=(${(f)br})
export __CURRENT_HG_BRANCH="$(echo $arr[1])"
fi
if [ -n "$st" ]; then
if echo $st | grep "nothing to commit (working directory clean)" >/dev/null; then
else
export __CURRENT_HG_BRANCH_IS_DIRTY='1'
fi
fi
}
preexec_functions+='preexec_update_hg_vars'
precmd_functions+='precmd_update_hg_vars'
chpwd_functions+='chpwd_update_hg_vars'
# Set the prompt.
# PROMPT=$'%{${fg[cyan]}%}%B%~%b$(prompt_hg_info)%{${fg[default]}%} '
# Mercurial
alias hgc='hg commit -v'

10
themes/educatux.zsh-theme Normal file
View file

@ -0,0 +1,10 @@
PROMPT=$'
%{$fg[blue]%}%/%{$reset_color%} $(git_prompt_info)%{$fg[white]%}$(prompt_hg_info)%{$fg[white]%}[%n@%m]%{$reset_color%} %{$fg[white]%}[%T]%{$reset_color%}
%{$fg_bold[black]%}>%{$reset_color%} '
PROMPT2="%{$fg_blod[black]%}%_> %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}*%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""