|
|
@ -10,6 +10,16 @@
|
|
|
|
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
|
|
|
|
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setopt prompt_subst
|
|
|
|
|
|
|
|
autoload -Uz vcs_info
|
|
|
|
|
|
|
|
zstyle ':vcs_info:*' stagedstr '✚'
|
|
|
|
|
|
|
|
zstyle ':vcs_info:git:*' unstagedstr '●'
|
|
|
|
|
|
|
|
zstyle ':vcs_info:git*' actionformats " %b %F{red}| %a%f"
|
|
|
|
|
|
|
|
zstyle ':vcs_info:git*' formats " %b %c%u%m"
|
|
|
|
|
|
|
|
zstyle ':vcs_info:*' check-for-changes true
|
|
|
|
|
|
|
|
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-aheadbehind git-remotebranch git-tagname
|
|
|
|
|
|
|
|
zstyle ':vcs_info:*' enable git
|
|
|
|
|
|
|
|
|
|
|
|
### Segment drawing
|
|
|
|
### Segment drawing
|
|
|
|
# A few utility functions to make it easy and re-usable to draw segmented prompts
|
|
|
|
# A few utility functions to make it easy and re-usable to draw segmented prompts
|
|
|
|
|
|
|
|
|
|
|
@ -80,39 +90,67 @@ prompt_context() {
|
|
|
|
|
|
|
|
|
|
|
|
# Git: branch/detached head, dirty status
|
|
|
|
# Git: branch/detached head, dirty status
|
|
|
|
prompt_git() {
|
|
|
|
prompt_git() {
|
|
|
|
local ref dirty mode repo_path
|
|
|
|
local dirty
|
|
|
|
repo_path=$(git rev-parse --git-dir 2>/dev/null)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
|
|
|
|
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
|
|
|
|
dirty=$(parse_git_dirty)
|
|
|
|
dirty=$(parse_git_dirty)
|
|
|
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
|
|
|
|
|
|
|
|
if [[ -n $dirty ]]; then
|
|
|
|
if [[ -n $dirty ]]; then
|
|
|
|
left_prompt_segment yellow black
|
|
|
|
left_prompt_segment yellow black
|
|
|
|
else
|
|
|
|
else
|
|
|
|
left_prompt_segment green black
|
|
|
|
left_prompt_segment green black
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -e "${repo_path}/BISECT_LOG" ]]; then
|
|
|
|
echo -n "${vcs_info_msg_0_}"
|
|
|
|
mode=" <B>"
|
|
|
|
fi
|
|
|
|
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
|
|
|
|
}
|
|
|
|
mode=" >M<"
|
|
|
|
|
|
|
|
elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
|
|
|
|
function +vi-git-untracked() {
|
|
|
|
mode=" >R>"
|
|
|
|
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \
|
|
|
|
|
|
|
|
$(git ls-files --others --exclude-standard | sed q | wc -l | tr -d ' ') != 0 ]]; then
|
|
|
|
|
|
|
|
hook_com[unstaged]+="%F{black}?%f"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setopt promptsubst
|
|
|
|
function +vi-git-aheadbehind() {
|
|
|
|
autoload -Uz vcs_info
|
|
|
|
local ahead behind branch_name
|
|
|
|
|
|
|
|
local -a gitstatus
|
|
|
|
zstyle ':vcs_info:*' enable git
|
|
|
|
|
|
|
|
zstyle ':vcs_info:*' get-revision true
|
|
|
|
branch_name=${$(git symbolic-ref --short HEAD 2>/dev/null)}
|
|
|
|
zstyle ':vcs_info:*' check-for-changes true
|
|
|
|
|
|
|
|
zstyle ':vcs_info:*' stagedstr '✚'
|
|
|
|
# for git prior to 1.7
|
|
|
|
zstyle ':vcs_info:git:*' unstagedstr '●'
|
|
|
|
# ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l)
|
|
|
|
zstyle ':vcs_info:*' formats ' %u%c'
|
|
|
|
ahead=$(git rev-list ${branch_name}@{upstream}..HEAD 2>/dev/null | wc -l | tr -d ' ')
|
|
|
|
zstyle ':vcs_info:*' actionformats ' %u%c'
|
|
|
|
(( $ahead )) && gitstatus+=( "%F{black}↑${ahead}%f" )
|
|
|
|
vcs_info
|
|
|
|
|
|
|
|
echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}"
|
|
|
|
# for git prior to 1.7
|
|
|
|
fi
|
|
|
|
# behind=$(git rev-list HEAD..origin/${branch_name} | wc -l)
|
|
|
|
|
|
|
|
behind=$(git rev-list HEAD..${branch_name}@{upstream} 2>/dev/null | wc -l | tr -d ' ')
|
|
|
|
|
|
|
|
(( $behind )) && gitstatus+=( "%F{black}↓${behind}%f" )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hook_com[misc]+=${(j::)gitstatus}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function +vi-git-remotebranch() {
|
|
|
|
|
|
|
|
local remote branch_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Are we on a remote-tracking branch?
|
|
|
|
|
|
|
|
remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/}
|
|
|
|
|
|
|
|
branch_name=${$(git symbolic-ref --short HEAD 2>/dev/null)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hook_com[branch]="%F{black}${hook_com[branch]}%f"
|
|
|
|
|
|
|
|
# Always show the remote
|
|
|
|
|
|
|
|
#if [[ -n ${remote} ]] ; then
|
|
|
|
|
|
|
|
# Only show the remote if it differs from the local
|
|
|
|
|
|
|
|
if [[ -n ${remote} && ${remote#*/} != ${branch_name} ]] ; then
|
|
|
|
|
|
|
|
hook_com[branch]+="%F{black}→%f%F{black}${remote}%f"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function +vi-git-tagname() {
|
|
|
|
|
|
|
|
local tag
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tag=$(git describe --tags --exact-match HEAD 2>/dev/null)
|
|
|
|
|
|
|
|
[[ -n ${tag} ]] && hook_com[branch]="%F{black}${tag}%f"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Mercurial status
|
|
|
|
# Mercurial status
|
|
|
@ -238,5 +276,7 @@ build_right_prompt() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Create the prompts
|
|
|
|
# Create the prompts
|
|
|
|
|
|
|
|
precmd() { vcs_info }
|
|
|
|
|
|
|
|
|
|
|
|
PROMPT='%{%f%b%k%}$(build_left_prompt) '
|
|
|
|
PROMPT='%{%f%b%k%}$(build_left_prompt) '
|
|
|
|
RPROMPT='%{%f%b%k%}$(build_right_prompt)%{$reset_color%}'
|
|
|
|
RPROMPT='%{%f%b%k%}$(build_right_prompt)%{$reset_color%}'
|
|
|
|