diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index a3a6ff8b6..c32fd2f87 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -1,3 +1,51 @@ +## Source : https://bitbucket.org/Josh/mercurial-for-zsh + +function prompt_hg_info(){ + __CURRENT_DIR_IS_REPO=$(hg summary 2> /dev/null) || return + + if [ -n "$__CURRENT_DIR_IS_REPO" ]; then + update_current_hg_vars + fi + + if [ -n "$__CURRENT_HG_BRANCH" ]; then + local s="$__CURRENT_HG_BRANCH" + case "$__CURRENT_HG_BRANCH_STATUS" in + ahead) + d="↑" + ;; + diverged) + d="↕" + ;; + behind) + d="↓" + ;; + esac + if [ -n "$__CURRENT_HG_BRANCH_IS_DIRTY" ]; then + d="⚡" + fi + + printf "%s[%s %s%s%s] " "%{${fg[yellow]}%}" $s "%{${fg[red]}%}" $d "%{${fg[yellow]}%}" + 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 +} # Mercurial alias hgc='hg commit' @@ -17,4 +65,4 @@ function hg_current_branch() { if [ -d .hg ]; then echo hg:$(hg branch) fi -} \ No newline at end of file +} diff --git a/themes/educatux.zsh-theme b/themes/educatux.zsh-theme new file mode 100644 index 000000000..baed1fc8d --- /dev/null +++ b/themes/educatux.zsh-theme @@ -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=""