@@ -92,10 +92,10 @@ RBFU_THEME_PROMPT_SUFFIX='|'
9292: " ${SVN_EXE:= $SCM_SVN } "
9393
9494function _bash_it_appearance_scm_init() {
95- GIT_EXE=" $( type -P $SCM_GIT || true) "
96- P4_EXE=" $( type -P $SCM_P4 || true) "
97- HG_EXE=" $( type -P $SCM_HG || true) "
98- SVN_EXE=" $( type -P $SCM_SVN || true) "
95+ GIT_EXE=" $( type -P " $SCM_GIT " || true) "
96+ P4_EXE=" $( type -P " $SCM_P4 " || true) "
97+ HG_EXE=" $( type -P " $SCM_HG " || true) "
98+ SVN_EXE=" $( type -P " $SCM_SVN " || true) "
9999
100100 # Check for broken SVN exe that is caused by some versions of Xcode.
101101 # See https://github.com/Bash-it/bash-it/issues/1612 for more details.
@@ -233,7 +233,7 @@ function git_prompt_minimal_info {
233233}
234234
235235function git_prompt_vars {
236- if ${SCM_GIT_USE_GITSTATUS} && _command_exists gitstatus_query && gitstatus_query && [[ " ${VCS_STATUS_RESULT} " == " ok-sync" ]]; then
236+ if " ${SCM_GIT_USE_GITSTATUS:- false} " && _command_exists gitstatus_query && gitstatus_query && [[ " ${VCS_STATUS_RESULT:- } " == " ok-sync" ]]; then
237237 # we can use faster gitstatus
238238 # use this variable in githelpers and below to choose gitstatus output
239239 SCM_GIT_GITSTATUS_RAN=true
@@ -257,8 +257,8 @@ function git_prompt_vars {
257257 fi
258258
259259 if [[ " ${SCM_GIT_GITSTATUS_RAN} " == " true" ]]; then
260- commits_behind=${VCS_STATUS_COMMITS_BEHIND}
261- commits_ahead=${VCS_STATUS_COMMITS_AHEAD}
260+ commits_behind=${VCS_STATUS_COMMITS_BEHIND? }
261+ commits_ahead=${VCS_STATUS_COMMITS_AHEAD? }
262262 else
263263 IFS=$' \t ' read -r commits_behind commits_ahead <<< " $(_git-upstream-behind-ahead)"
264264 fi
@@ -274,7 +274,7 @@ function git_prompt_vars {
274274 if [[ " ${SCM_GIT_SHOW_STASH_INFO} " = " true" ]]; then
275275 local stash_count
276276 if [[ " ${SCM_GIT_GITSTATUS_RAN} " == " true" ]]; then
277- stash_count=${VCS_STATUS_STASHES}
277+ stash_count=${VCS_STATUS_STASHES? }
278278 else
279279 stash_count=" $( git stash list 2> /dev/null | wc -l | tr -d ' ' ) "
280280 fi
@@ -284,9 +284,9 @@ function git_prompt_vars {
284284 SCM_STATE=${GIT_THEME_PROMPT_CLEAN:- $SCM_THEME_PROMPT_CLEAN }
285285 if ! _git-hide-status; then
286286 if [[ " ${SCM_GIT_GITSTATUS_RAN} " == " true" ]]; then
287- untracked_count=${VCS_STATUS_NUM_UNTRACKED}
288- unstaged_count=${VCS_STATUS_NUM_UNSTAGED}
289- staged_count=${VCS_STATUS_NUM_STAGED}
287+ untracked_count=${VCS_STATUS_NUM_UNTRACKED? }
288+ unstaged_count=${VCS_STATUS_NUM_UNSTAGED? }
289+ staged_count=${VCS_STATUS_NUM_STAGED? }
290290 else
291291 IFS=$' \t ' read -r untracked_count unstaged_count staged_count <<< " $(_git-status-counts)"
292292 fi
@@ -427,14 +427,15 @@ function rbenv_version_prompt {
427427}
428428
429429function rbfu_version_prompt {
430- if [[ $ RBFU_RUBY_VERSION ]]; then
430+ if [[ -n " ${ RBFU_RUBY_VERSION:- } " ]]; then
431431 echo -e " ${RBFU_THEME_PROMPT_PREFIX}${RBFU_RUBY_VERSION}${RBFU_THEME_PROMPT_SUFFIX} "
432432 fi
433433}
434434
435435function chruby_version_prompt {
436- if declare -f -F chruby & > /dev/null; then
437- if declare -f -F chruby_auto & > /dev/null; then
436+ local ruby_version
437+ if _command_exists chruby; then
438+ if _command_exists chruby_auto; then
438439 chruby_auto
439440 fi
440441
@@ -443,12 +444,12 @@ function chruby_version_prompt {
443444 if ! chruby | grep -q ' \*' ; then
444445 ruby_version=" ${ruby_version} (system)"
445446 fi
446- echo -e " ${CHRUBY_THEME_PROMPT_PREFIX}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX} "
447+ echo -e " ${CHRUBY_THEME_PROMPT_PREFIX:- }${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX:- } "
447448 fi
448449}
449450
450451function ruby_version_prompt {
451- if [[ " ${THEME_SHOW_RUBY_PROMPT} " = " true" ]]; then
452+ if [[ " ${THEME_SHOW_RUBY_PROMPT:- } " = = " true" ]]; then
452453 echo -e " $( rbfu_version_prompt) $( rbenv_version_prompt) $( rvm_version_prompt) $( chruby_version_prompt) "
453454 fi
454455}
@@ -462,21 +463,22 @@ function k8s_namespace_prompt {
462463}
463464
464465function virtualenv_prompt {
465- if [[ -n " $VIRTUAL_ENV " ]]; then
466- virtualenv=$( basename " $ VIRTUAL_ENV" )
466+ if [[ -n " ${ VIRTUAL_ENV:- } " ]]; then
467+ virtualenv=" ${ VIRTUAL_ENV##*/ } "
467468 echo -e " $VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX "
468469 fi
469470}
470471
471472function condaenv_prompt {
472- if [[ $ CONDA_DEFAULT_ENV ]]; then
473- echo -e " ${CONDAENV_THEME_PROMPT_PREFIX}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX} "
473+ if [[ -n " ${ CONDA_DEFAULT_ENV:- } " ]]; then
474+ echo -e " ${CONDAENV_THEME_PROMPT_PREFIX:- }${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX:- } "
474475 fi
475476}
476477
477478function py_interp_prompt {
479+ local py_version
478480 py_version=$( python --version 2>&1 | awk ' NR==1{print "py-"$2;}' ) || return
479- echo -e " ${PYTHON_THEME_PROMPT_PREFIX}${py_version}${PYTHON_THEME_PROMPT_SUFFIX} "
481+ echo -e " ${PYTHON_THEME_PROMPT_PREFIX:- }${py_version}${PYTHON_THEME_PROMPT_SUFFIX:- } "
480482}
481483
482484function python_version_prompt {
@@ -504,7 +506,7 @@ function clock_char {
504506function clock_prompt {
505507 CLOCK_COLOR=${THEME_CLOCK_COLOR:- " $normal " }
506508 CLOCK_FORMAT=${THEME_CLOCK_FORMAT:- " %H:%M:%S" }
507- [ -z " $THEME_SHOW_CLOCK " ] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:- " true" }
509+ [[ -z " ${ THEME_SHOW_CLOCK:- } " ] ] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:- " true" }
508510 SHOW_CLOCK=$THEME_SHOW_CLOCK
509511
510512 if [[ " ${SHOW_CLOCK} " = " true" ]]; then
@@ -574,7 +576,7 @@ if ! _command_exists battery_percentage; then
574576fi
575577
576578function aws_profile {
577- if [[ $ AWS_DEFAULT_PROFILE ]]; then
579+ if [[ -n " ${ AWS_DEFAULT_PROFILE:- } " ]]; then
578580 echo -e " ${AWS_DEFAULT_PROFILE} "
579581 else
580582 echo -e " default"
0 commit comments