Sync .bashrc from master.
This commit is contained in:
parent
6af59dd344
commit
b67c763676
1 changed files with 34 additions and 11 deletions
45
.bashrc
45
.bashrc
|
|
@ -26,7 +26,7 @@ __prompt_git_status() {
|
||||||
# S:branch_name >5 *
|
# S:branch_name >5 *
|
||||||
# Returns: Exit code of the command line before entering this function.
|
# Returns: Exit code of the command line before entering this function.
|
||||||
# shellcheck disable=SC2155
|
# 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.
|
# Bail out if there's no format argument given.
|
||||||
(( $# != 1 )) && return "$RET"
|
(( $# != 1 )) && return "$RET"
|
||||||
|
|
@ -66,8 +66,7 @@ __prompt_git_status() {
|
||||||
# Add upstream status.
|
# Add upstream status.
|
||||||
[[ -n "$GIT_PROMPT_SHOW_UPSTREAM" ]] || [[ -n "$GIT_PROMPT_SHOW_UPSTREAM_EXTENDED" ]] && {
|
[[ -n "$GIT_PROMPT_SHOW_UPSTREAM" ]] || [[ -n "$GIT_PROMPT_SHOW_UPSTREAM_EXTENDED" ]] && {
|
||||||
# Whether to run prefetch tasks.
|
# Whether to run prefetch tasks.
|
||||||
[[ -n "$GIT_PROMPT_AUTO_PREFETCH" ]] && [[ "$PWD" == "${GIT_REPO_INFO[0]}" ]] && \
|
[[ -n "$GIT_PROMPT_AUTO_PREFETCH" ]] && [[ "$(git config --get --bool maintenance.promptprefetchdisabled 2>/dev/null)" != "true" ]] && {
|
||||||
[[ "$(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
|
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:]' ' ')"
|
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.
|
# 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+=" !"
|
GIT_PROMPT+=" !"
|
||||||
elif [[ -n "$GIT_PROMPT_SHOW_UNSTAGED" ]] && git ls-files --modified --exclude-standard --directory --error-unmatch -- ':/*' >/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+=" *"
|
||||||
elif [[ -n "$GIT_PROMPT_SHOW_UNCOMMITTED" ]] && ! git diff --name-only --cached --exit-code >/dev/null 2>&1; then
|
GIT_PROMPT_MARKER_SET=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+=" $"
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
[[ -z "$GIT_PROMPT_MARKER_SET" ]] && [[ -n "$GIT_PROMPT_SHOW_UNCOMMITTED" ]] && ! git diff --name-only --cached --exit-code >/dev/null 2>&1 && {
|
||||||
|
GIT_PROMPT+=" &"
|
||||||
|
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+=" $"
|
||||||
|
GIT_PROMPT_MARKER_SET=1
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output the prompt.
|
# Output the prompt.
|
||||||
|
|
@ -405,6 +427,7 @@ HISTFILESIZE=1000000
|
||||||
HISTIGNORE="bg:bg *:fg:fg *:jobs:exit:clear:history"
|
HISTIGNORE="bg:bg *:fg:fg *:jobs:exit:clear:history"
|
||||||
HISTSIZE=1000000
|
HISTSIZE=1000000
|
||||||
HISTTIMEFORMAT="%d/%m/%y %H:%M:%S "
|
HISTTIMEFORMAT="%d/%m/%y %H:%M:%S "
|
||||||
|
history -a
|
||||||
history -r
|
history -r
|
||||||
|
|
||||||
# The commands to execute before the prompt is displayed.
|
# The commands to execute before the prompt is displayed.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue