Browse Source

[Fix #41] Do not truncate the commit id

master
Colin Hebert 13 years ago committed by Sorin Ionescu
parent
commit
cdb95f810f
  1. 9
      helper.zsh
  2. 7
      plugins/git/functions/git-info
  3. 4
      themes/sorin/prompt_sorin_setup

9
helper.zsh

@ -15,6 +15,15 @@ function is-true() {
[[ -n "$1" && "$1" == (1|[Yy]([Ee][Ss]|)|[Tt]([Rr][Uu][Ee]|)|[Oo]([Nn]|)) ]] [[ -n "$1" && "$1" == (1|[Yy]([Ee][Ss]|)|[Tt]([Rr][Uu][Ee]|)|[Oo]([Nn]|)) ]]
} }
# Prints the first non-empty string in the arguments array.
function coalesce() {
for arg in "$argv[@]"; do
print "$arg"
return 0
done
return 1
}
# Trap signals were generated with 'kill -l'. # Trap signals were generated with 'kill -l'.
# DEBUG, EXIT, and ZERR are Zsh signals. # DEBUG, EXIT, and ZERR are Zsh signals.
TRAP_SIGNALS=( TRAP_SIGNALS=(

7
plugins/git/functions/git-info

@ -140,7 +140,6 @@ function git-info() {
local clean local clean
local clean_formatted local clean_formatted
local commit local commit
local commit_short
local commit_format local commit_format
local deleted=0 local deleted=0
local deleted_format local deleted_format
@ -220,9 +219,8 @@ function git-info() {
commit="$(git rev-parse HEAD 2>/dev/null)" commit="$(git rev-parse HEAD 2>/dev/null)"
# Format commit (short). # Format commit (short).
commit_short="$commit[1,7]"
zstyle -s ':omz:plugin:git:prompt' commit 'commit_format' zstyle -s ':omz:plugin:git:prompt' commit 'commit_format'
zformat -f commit_formatted "$commit_format" "c:$commit_short" zformat -f commit_formatted "$commit_format" "c:$commit"
# Stashed # Stashed
if [[ -f "$(_git-dir)/refs/stash" ]]; then if [[ -f "$(_git-dir)/refs/stash" ]]; then
@ -238,9 +236,6 @@ function git-info() {
(( line_number++ )) (( line_number++ ))
if (( line_number == 1 )) && [[ "$line" == *'(no branch)'* ]]; then if (( line_number == 1 )) && [[ "$line" == *'(no branch)'* ]]; then
# Set branch to commit (short) when the branch is not found.
branch="$commit_short"
# Get action. # Get action.
action="$(_git-action)" action="$(_git-action)"
if [[ -n "$action" ]]; then if [[ -n "$action" ]]; then

4
themes/sorin/prompt_sorin_setup

@ -35,12 +35,12 @@ function prompt_sorin_setup() {
zstyle ':omz:plugin:git:prompt' deleted ' %%B%F{red}✖%f%%b' zstyle ':omz:plugin:git:prompt' deleted ' %%B%F{red}✖%f%%b'
zstyle ':omz:plugin:git:prompt' modified ' %%B%F{blue}✱%f%%b' zstyle ':omz:plugin:git:prompt' modified ' %%B%F{blue}✱%f%%b'
zstyle ':omz:plugin:git:prompt' renamed ' %%B%F{magenta}➜%f%%b' zstyle ':omz:plugin:git:prompt' renamed ' %%B%F{magenta}➜%f%%b'
zstyle ':omz:plugin:git:prompt' commit '%c' zstyle ':omz:plugin:git:prompt' commit '%.7c'
zstyle ':omz:plugin:git:prompt' stashed ' %%B%F{cyan}✭%f%%b' zstyle ':omz:plugin:git:prompt' stashed ' %%B%F{cyan}✭%f%%b'
zstyle ':omz:plugin:git:prompt' unmerged ' %%B%F{yellow}═%f%%b' zstyle ':omz:plugin:git:prompt' unmerged ' %%B%F{yellow}═%f%%b'
zstyle ':omz:plugin:git:prompt' untracked ' %%B%F{white}◼%f%%b' zstyle ':omz:plugin:git:prompt' untracked ' %%B%F{white}◼%f%%b'
zstyle ':omz:plugin:git:prompt' prompt ' %F{blue}git%f%b%s'
zstyle ':omz:plugin:git:prompt' rprompt '%A%B%S%a%d%m%r%U%u' zstyle ':omz:plugin:git:prompt' rprompt '%A%B%S%a%d%m%r%U%u'
zstyle -e ':omz:plugin:git:prompt' prompt 'reply=("%F{blue}git%f$(coalesce "%b" "%c")%s")'
PROMPT='%F{cyan}%1~%f${git_prompt_info} %(!.%B%F{red}#%f%b.%B%F{green}❯%f%b) ' PROMPT='%F{cyan}%1~%f${git_prompt_info} %(!.%B%F{red}#%f%b.%B%F{green}❯%f%b) '
RPROMPT='%(?::%F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_rprompt_info}' RPROMPT='%(?::%F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_rprompt_info}'

Loading…
Cancel
Save