This commit is contained in:
Jonas Forsberg 2021-11-14 13:45:49 +01:00
parent 4c7cdca4fa
commit 9d30a4672d
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9

View File

@ -1,4 +1,17 @@
#!/bin/bash #!/bin/bash
function fetch_bash_ps1(){
local BASH_PS1_URL="${BASH_PS1_URL:-https://git.rre.nu/jonas/dotfiles/src/branch/master/.functions/ps1.sh}"
if ! command -v curl &> /dev/null;then
echo "curl not found"
return 1
fi
curl -o "${HOME}/.functions/ps1.sh" "$BASH_PS1_URL"
# shellcheck disable=1090
source "${HOME}/.functions/ps1.sh"
}
function bash_ps1 () { function bash_ps1 () {
local LAST_EXIT_STATUS=$? local LAST_EXIT_STATUS=$?
local EXIT_STATUS="" local EXIT_STATUS=""
@ -28,7 +41,12 @@ function bash_ps1 () {
export GIT_PS1_SHOWUNTRACKEDFILES=1 export GIT_PS1_SHOWUNTRACKEDFILES=1
[[ $LAST_EXIT_STATUS != 0 ]] && EXIT_STATUS="${PS1_COLOR_DIVIDER}[${PS1_COLOR_EXIT_STATUS}${LAST_EXIT_STATUS}${PS1_COLOR_DIVIDER}]" [[ $LAST_EXIT_STATUS != 0 ]] && EXIT_STATUS="${PS1_COLOR_DIVIDER}[${PS1_COLOR_EXIT_STATUS}${LAST_EXIT_STATUS}${PS1_COLOR_DIVIDER}]"
[[ $(type -t __git_ps1) == function ]] && GIT_BRANCH="${PS1_COLOR_DIVIDER}─[${PS1_COLOR_GITBRANCH}$(__git_ps1 '%s')${PS1_COLOR_DIVIDER}]" if [[ $(type -t __git_ps1) == function ]];then
GIT_BRANCH="$(__git_ps1 '%s')"
if [[ -n "$GIT_BRANCH" ]];then
GIT_BRANCH="${PS1_COLOR_DIVIDER}─[${PS1_COLOR_GITBRANCH}${GIT_BRANCH}${PS1_COLOR_DIVIDER}]"
fi
fi
[[ -n "$VIRTUAL_ENV" ]] && PYTHON_ENV="${PS1_COLOR_DIVIDER}─[${PS1_COLOR_VENV}${VIRTUAL_ENV##*/}${PS1_COLOR_DIVIDER}]" [[ -n "$VIRTUAL_ENV" ]] && PYTHON_ENV="${PS1_COLOR_DIVIDER}─[${PS1_COLOR_VENV}${VIRTUAL_ENV##*/}${PS1_COLOR_DIVIDER}]"
if [[ $(type kubectl) ]]; then if [[ $(type kubectl) ]]; then
CURRENT_CONTEXT="$(kubectl config current-context)" CURRENT_CONTEXT="$(kubectl config current-context)"