Sync .bashrc from master.

This commit is contained in:
Darren 'Tadgy' Austin 2023-10-20 20:34:10 +01:00
commit b67c763676

45
.bashrc
View file

@ -26,7 +26,7 @@ __prompt_git_status() {
# S:branch_name >5 *
# Returns: Exit code of the command line before entering this function.
# shellcheck disable=SC2155
local BRANCH COUNT GIT_PROMPT GIT_REPO_INFO PWD=$(pwd -P) RET="$?"
local RET="$?" BRANCH COUNT GIT_PROMPT GIT_PROMPT_MARKER_SET GIT_REPO_INFO PWD=$(pwd -P)
# Bail out if there's no format argument given.
(( $# != 1 )) && return "$RET"
@ -66,8 +66,7 @@ __prompt_git_status() {
# Add upstream status.
[[ -n "$GIT_PROMPT_SHOW_UPSTREAM" ]] || [[ -n "$GIT_PROMPT_SHOW_UPSTREAM_EXTENDED" ]] && {
# Whether to run prefetch tasks.
[[ -n "$GIT_PROMPT_AUTO_PREFETCH" ]] && [[ "$PWD" == "${GIT_REPO_INFO[0]}" ]] && \
[[ "$(git config --get --bool maintenance.promptprefetchdisabled 2>/dev/null)" != "true" ]] && {
[[ -n "$GIT_PROMPT_AUTO_PREFETCH" ]] && [[ "$(git config --get --bool maintenance.promptprefetchdisabled 2>/dev/null)" != "true" ]] && {
git maintenance run --task=prefetch 2>/dev/null || printf "\\033[1;31m%s\\033[39m\\n" "Git maintenance 'prefetch' task failed." >&2
}
COUNT="$(git rev-list --count --left-right "${BRANCH:+refs/prefetch/remotes/origin/}${BRANCH:-@{upstream\}}...HEAD" 2>/dev/null | tr '[:blank:]' ' ')"
@ -108,17 +107,40 @@ __prompt_git_status() {
}
# Add a marker if directory is ignored, there's unstaged files, uncommitted changes, untracked files or a stash.
if [[ -n "$GIT_PROMPT_SHOW_IGNORED" ]] && git check-ignore "${PWD#"${GIT_REPO_INFO[0]}/"}" >/dev/null 2>&1 ; then
[[ -n "$GIT_PROMPT_SHOW_IGNORED" ]] && git check-ignore "${PWD#"${GIT_REPO_INFO[0]}/"}" >/dev/null 2>&1 && {
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_MARKER_SET=1
}
[[ -z "$GIT_PROMPT_MARKER_SET" ]] && [[ -n "$GIT_PROMPT_SHOW_UNSTAGED" ]] && {
timeout --signal=KILL 2s git ls-files --modified --exclude-standard --directory --error-unmatch -- ':/*' >/dev/null 2>&1
ERR=$?
if (( ERR == 124 )) || (( ERR == 137 )); then
GIT_PROMPT+=" _"
GIT_PROMPT_MARKER_SET=1
elif (( ERR == 0 )); then
GIT_PROMPT+=" *"
GIT_PROMPT_MARKER_SET=1
fi
}
[[ -z "$GIT_PROMPT_MARKER_SET" ]] && [[ -n "$GIT_PROMPT_SHOW_UNCOMMITTED" ]] && ! git diff --name-only --cached --exit-code >/dev/null 2>&1 && {
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_MARKER_SET=1
}
[[ -z "$GIT_PROMPT_MARKER_SET" ]] && [[ -n "$GIT_PROMPT_SHOW_UNTRACKED" ]] && {
timeout --signal=KILL 2s git ls-files git ls-files --others --exclude-standard --directory --error-unmatch -- ':/*' >/dev/null 2>&1
ERR=$?
if (( ERR == 124 )) || (( ERR == 137 )); then
GIT_PROMPT+=" _"
GIT_PROMPT_MARKER_SET=1
elif (( ERR == 0 )); then
GIT_PROMPT+=" +"
GIT_PROMPT_MARKER_SET=1
fi
}
[[ -z "$GIT_PROMPT_MARKER_SET" ]] && [[ -n "$GIT_PROMPT_SHOW_STASH" ]] && git rev-parse --verify --quiet refs/stash >/dev/null && {
GIT_PROMPT+=" $"
fi
GIT_PROMPT_MARKER_SET=1
}
fi
# Output the prompt.
@ -405,6 +427,7 @@ HISTFILESIZE=1000000
HISTIGNORE="bg:bg *:fg:fg *:jobs:exit:clear:history"
HISTSIZE=1000000
HISTTIMEFORMAT="%d/%m/%y %H:%M:%S "
history -a
history -r
# The commands to execute before the prompt is displayed.