Skip to content

Commit

Permalink
[Fix sorin-ionescu#41] Do not truncate the commit id
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinHebert authored and sorin-ionescu committed Mar 22, 2012
1 parent 720a48c commit 8acc66a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
9 changes: 9 additions & 0 deletions helper.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ function is-true() {
[[ -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'.
# DEBUG, EXIT, and ZERR are Zsh signals.
TRAP_SIGNALS=(
Expand Down
7 changes: 1 addition & 6 deletions plugins/git/functions/git-info
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ function git-info() {
local clean
local clean_formatted
local commit
local commit_short
local commit_format
local deleted=0
local deleted_format
Expand Down Expand Up @@ -220,9 +219,8 @@ function git-info() {
commit="$(git rev-parse HEAD 2>/dev/null)"

# Format commit (short).
commit_short="$commit[1,7]"
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
if [[ -f "$(_git-dir)/refs/stash" ]]; then
Expand All @@ -238,9 +236,6 @@ function git-info() {
(( line_number++ ))

if (( line_number == 1 )) && [[ "$line" == *'(no branch)'* ]]; then
# Set branch to commit (short) when the branch is not found.
branch="$commit_short"

# Get action.
action="$(_git-action)"
if [[ -n "$action" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions themes/sorin/prompt_sorin_setup
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ function prompt_sorin_setup() {
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' 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' unmerged ' %%B%F{yellow}═%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 -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) '
RPROMPT='%(?::%F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_rprompt_info}'
Expand Down

0 comments on commit 8acc66a

Please sign in to comment.