fish: fix git prompt not showing staged changes if there's no commit
This commit is contained in:
parent
ddf010febb
commit
f2f4a01c6a
|
@ -103,29 +103,29 @@ function fish_git_prompt
|
||||||
_fish_prompt_warn "init"
|
_fish_prompt_warn "init"
|
||||||
end
|
end
|
||||||
|
|
||||||
git rev-parse HEAD -- &>/dev/null
|
# if we have at least one commit
|
||||||
or return
|
if git rev-parse HEAD -- &>/dev/null
|
||||||
|
# print a "↑" if ahead of origin
|
||||||
|
test 0 -ne (git log --oneline "$git_remote_branch"..HEAD -- | wc -l)
|
||||||
|
and set -f _git_sync_ahead '↑'
|
||||||
|
|
||||||
# print a "↑" if ahead of origin
|
# print a "↓" if behind of origin
|
||||||
test 0 -ne (git log --oneline "$git_remote_branch"..HEAD -- | wc -l)
|
test 0 -lt (git log --oneline HEAD.."$git_remote_branch" -- | wc -l)
|
||||||
and set -f _git_sync_ahead '↑'
|
and set -l _git_sync_behind '↓'
|
||||||
|
|
||||||
# print a "↓" if behind of origin
|
if set -q _git_sync_ahead _git_sync_behind
|
||||||
test 0 -lt (git log --oneline HEAD.."$git_remote_branch" -- | wc -l)
|
_fish_prompt_normal '⇅'
|
||||||
and set -l _git_sync_behind '↓'
|
else if set -q _git_sync_ahead
|
||||||
|
_fish_prompt_normal '↑'
|
||||||
|
else if set -q _git_sync_behind
|
||||||
|
_fish_prompt_normal '↓'
|
||||||
|
end
|
||||||
|
|
||||||
if set -q _git_sync_ahead _git_sync_behind
|
if test -n "$git_log_unpushed"
|
||||||
_fish_prompt_normal '⇅'
|
and not string match -qr "$git_branch" "$git_log_unpushed"
|
||||||
else if set -q _git_sync_ahead
|
_fish_prompt_normal '↻'
|
||||||
_fish_prompt_normal '↑'
|
_fish_prompt_warn $git_log_unpushed[1]
|
||||||
else if set -q _git_sync_behind
|
end
|
||||||
_fish_prompt_normal '↓'
|
|
||||||
end
|
|
||||||
|
|
||||||
if test -n "$git_log_unpushed"
|
|
||||||
and not string match -qr "$git_branch" "$git_log_unpushed"
|
|
||||||
_fish_prompt_normal '↻'
|
|
||||||
_fish_prompt_warn $git_log_unpushed[1]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
Loading…
Reference in a new issue