Show an uncommitted marker in the git prompt.

This commit is contained in:
Darren 'Tadgy' Austin 2023-10-02 15:39:28 +01:00
commit 9bac8a06bd

View file

@ -7,8 +7,9 @@ __prompt_git_status() {
# GIT_PROMPT_SHOW_TYPE=1 - Show type of repository (Bare, Shallow).
# GIT_PROMPT_SHOW_IGNORED=1 - Show a ! if the directory is ignored.
# GIT_PROMPT_SHOW_UNSTAGED=1 - Show a * if there are unstaged changes (superceeded by above).
# GIT_PROMPT_SHOW_UNCOMMITTED=1 - Show a & if there are staged but uncommitted changes (superceeded by above).
# GIT_PROMPT_SHOW_UNTRACKED=1 - Show a ? if there are untracked files in the working directory (superceeded by above).
# GIT_PROMPT_SHOW_STASH=1 - Show a & if there is a stash in this repository (superceeded by above).
# GIT_PROMPT_SHOW_STASH=1 - Show a $ if there is a stash in this repository (superceeded by above).
# GIT_PROMPT_SHOW_UPSTREAM=1 - Show status of this repository compaired to upstream:
# ?? - No upstream set.
# == - Working tree is equal to upstream.
@ -52,10 +53,12 @@ __prompt_git_status() {
GIT_PROMPT+=" !"
elif [[ -n "$GIT_PROMPT_SHOW_UNSTAGED" ]] && git ls-files --modified --exclude-standard --directory --error-unmatch -- ':/*' >/dev/null 2>&1; then
GIT_PROMPT+=" *"
elif [[ -n "$GIT_PROMPT_SHOW_UNCOMMITTED" ]] && ! git diff --name-only --cached --exit-code >/dev/null 2>&1; then
GIT_PROMPT+=" &"
elif [[ -n "$GIT_PROMPT_SHOW_UNTRACKED" ]] && git ls-files --others --exclude-standard --directory --error-unmatch -- ':/*' >/dev/null 2>&1; then
GIT_PROMPT+=" ?"
elif [[ -n "$GIT_PROMPT_SHOW_STASH" ]] && git rev-parse --verify --quiet refs/stash >/dev/null; then
GIT_PROMPT+=" &"
GIT_PROMPT+=" $"
fi
# Get upstream status.
@ -391,6 +394,7 @@ PROMPT_COMMAND="__nanorc_prompt_command; __ssh_agent_prompt_command"
GIT_PROMPT_SHOW_TYPE=1
GIT_PROMPT_SHOW_IGNORED=1
GIT_PROMPT_SHOW_UNSTAGED=1
GIT_PROMPT_SHOW_UNCOMMITTED=1
GIT_PROMPT_SHOW_UNTRACKED=1
GIT_PROMPT_SHOW_STASH=1
GIT_PROMPT_SHOW_UPSTREAM=1