Clean up rev-parse usage. check-ignore uses current dir.
This commit is contained in:
parent
b67c763676
commit
7d9b3260d0
1 changed files with 6 additions and 6 deletions
12
.bashrc
12
.bashrc
|
@ -33,23 +33,23 @@ __prompt_git_status() {
|
|||
|
||||
# Get some repository information.
|
||||
# shellcheck disable=SC2207
|
||||
IFS=$'\n' GIT_REPO_INFO=( $(git rev-parse --show-toplevel --git-dir --is-bare-repository --is-shallow-repository --is-inside-git-dir --is-inside-work-tree 2>/dev/null) )
|
||||
IFS=$'\n' GIT_REPO_INFO=( $( git rev-parse --is-bare-repository --is-shallow-repository --is-inside-git-dir --is-inside-work-tree 2>/dev/null) )
|
||||
ERR="$?"
|
||||
|
||||
# Do nothing if there's an error.
|
||||
(( ERR >= 1 )) && return "$RET"
|
||||
|
||||
# Generate the prompt.
|
||||
if [[ "${GIT_REPO_INFO[4]}" == "true" ]]; then
|
||||
if [[ "${GIT_REPO_INFO[2]}" == "true" ]]; then
|
||||
# In the git directory, use a special branch marker.
|
||||
GIT_PROMPT+="!GIT_DIR!"
|
||||
elif [[ "${GIT_REPO_INFO[5]}" == "true" ]]; then
|
||||
elif [[ "${GIT_REPO_INFO[3]}" == "true" ]]; then
|
||||
# In the working directory, generate the prompt.
|
||||
# Add type markers.
|
||||
[[ -n "$GIT_PROMPT_SHOW_TYPE" ]] && {
|
||||
if [[ "${GIT_REPO_INFO[2]}" == "true" ]]; then
|
||||
if [[ "${GIT_REPO_INFO[0]}" == "true" ]]; then
|
||||
GIT_PROMPT+="B:"
|
||||
elif [[ "${GIT_REPO_INFO[3]}" == "true" ]]; then
|
||||
elif [[ "${GIT_REPO_INFO[1]}" == "true" ]]; then
|
||||
GIT_PROMPT+="S:"
|
||||
fi
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ __prompt_git_status() {
|
|||
}
|
||||
|
||||
# Add a marker if directory is ignored, there's unstaged files, uncommitted changes, untracked files or a stash.
|
||||
[[ -n "$GIT_PROMPT_SHOW_IGNORED" ]] && git check-ignore "${PWD#"${GIT_REPO_INFO[0]}/"}" >/dev/null 2>&1 && {
|
||||
[[ -n "$GIT_PROMPT_SHOW_IGNORED" ]] && git check-ignore . >/dev/null 2>&1 && {
|
||||
GIT_PROMPT+=" !"
|
||||
GIT_PROMPT_MARKER_SET=1
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue