fix: Fix PROMPT_COMMAND management

This commit is contained in:
Xavier Logerais 2024-01-27 19:04:33 +01:00
parent fe6642402b
commit 66c57a0a51
3 changed files with 19 additions and 1 deletions

9
libs/path.bash Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
_path_add() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1"
fi
}
# Source : https://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there

9
libs/prompt_command.bash Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
_prompt_command_add() {
if [ -n "$1" ] && [[ ":$PROMPT_COMMAND:" != *":$1:"* ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND:+"$PROMPT_COMMAND:"}$1"
fi
}
export PROMPT_COMMAND

View File

@ -13,7 +13,7 @@ if [ "${POWERLINE}" = "powerline-go" ]; then
PS1=$($POWERLINE -jobs "$(jobs -p | wc -l)" -error $? -modules "ssh,host,wsl,user,cwd,direnv,venv,perms,git,jobs,exit,root" -modules-right "docker,docker-context,kube,terraform-workspace,termtitle" -newline) PS1=$($POWERLINE -jobs "$(jobs -p | wc -l)" -error $? -modules "ssh,host,wsl,user,cwd,direnv,venv,perms,git,jobs,exit,root" -modules-right "docker,docker-context,kube,terraform-workspace,termtitle" -newline)
} }
if [ "$TERM" != "linux" ]; then PROMPT_COMMAND="$PROMPT_COMMAND; _update_ps1"; fi if [ "$TERM" != "linux" ]; then _prompt_command_add "_update_ps1" ; fi
elif [ "${POWERLINE}" = "powerline" ]; then elif [ "${POWERLINE}" = "powerline" ]; then