diff --git a/.functions/ps1.sh b/.functions/ps1.sh index 977d7b3..5671fc4 100644 --- a/.functions/ps1.sh +++ b/.functions/ps1.sh @@ -1,4 +1,17 @@ #!/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 () { local LAST_EXIT_STATUS=$? local EXIT_STATUS="" @@ -28,7 +41,12 @@ function bash_ps1 () { export GIT_PS1_SHOWUNTRACKEDFILES=1 [[ $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}]" if [[ $(type kubectl) ]]; then CURRENT_CONTEXT="$(kubectl config current-context)"