1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-26 22:10:06 +00:00

Squashed 'gitstatus/' changes from bdaad2e8d..38d35b959

38d35b959 cleanup
7e7b5e807 bash prompt: set PROMPT_COMMAND in a nicer and more robust manner (#403)
7ee9227de Merge branch 'samiam-append_prompt'
198ed58ce Revert "Update README to append to PROMPT_COMMAND"
8b6a229fa Switch to using var assignment for backward compatibility
693f9efa0 Update README to append to PROMPT_COMMAND
a48175ce1 Append to PROMPT_COMMAND to play nice with other prompt programs

git-subtree-dir: gitstatus
git-subtree-split: 38d35b95926e09d07b8cf78edade7cee7a9a1dcf
This commit is contained in:
Roman Perepelitsa 2023-08-15 10:30:02 +02:00
parent 9401ed17c0
commit d8041e4700

View file

@ -2,7 +2,7 @@
# Source gitstatus.plugin.sh from $GITSTATUS_DIR or from the same directory
# in which the current script resides if the variable isn't set.
if [[ -n "${GITSTATUS_DIR:-}" ]]; then
if [[ -n "${GITSTATUS_DIR-}" ]]; then
source "$GITSTATUS_DIR" || return
elif [[ "${BASH_SOURCE[0]}" == */* ]]; then
source "${BASH_SOURCE[0]%/*}/gitstatus.plugin.sh" || return
@ -85,7 +85,14 @@ function gitstatus_prompt_update() {
gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1
# On every prompt, fetch git status and set GITSTATUS_PROMPT.
PROMPT_COMMAND=gitstatus_prompt_update
if [[ -z "${PROMPT_COMMAND[*]}" ]]; then
PROMPT_COMMAND=gitstatus_prompt_update
elif [[ ! "${PROMPT_COMMAND[*]}" =~ [[:space:]\;]?gitstatus_prompt_update[[:space:]\;]? ]]; then
# Note: If PROMPT_COMMAND is an array, this will modify its first element.
PROMPT_COMMAND=$'gitstatus_prompt_update\n'"$PROMPT_COMMAND"
fi
# Retain 3 trailing components of the current directory.
PROMPT_DIRTRIM=3
# Enable promptvars so that ${GITSTATUS_PROMPT} in PS1 is expanded.