Skip to content

Commit

Permalink
lib/theme: Fix a *few* SC2154
Browse files Browse the repository at this point in the history
These variables are referenced by themes already linted.
  • Loading branch information
gaelicWizard committed Sep 19, 2021
1 parent af0f1ff commit 6d58c8a
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions themes/base.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ RBFU_THEME_PROMPT_SUFFIX='|'
: "${SVN_EXE:=$SCM_SVN}"

function _bash_it_appearance_scm_init() {
GIT_EXE="$(type -P $SCM_GIT || true)"
P4_EXE="$(type -P $SCM_P4 || true)"
HG_EXE="$(type -P $SCM_HG || true)"
SVN_EXE="$(type -P $SCM_SVN || true)"
GIT_EXE="$(type -P "$SCM_GIT" || true)"
P4_EXE="$(type -P "$SCM_P4" || true)"
HG_EXE="$(type -P "$SCM_HG" || true)"
SVN_EXE="$(type -P "$SCM_SVN" || true)"

# Check for broken SVN exe that is caused by some versions of Xcode.
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
Expand Down Expand Up @@ -233,7 +233,7 @@ function git_prompt_minimal_info {
}

function git_prompt_vars {
if ${SCM_GIT_USE_GITSTATUS} && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT}" == "ok-sync" ]]; then
if "${SCM_GIT_USE_GITSTATUS:-false}" && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT:-}" == "ok-sync" ]]; then
# we can use faster gitstatus
# use this variable in githelpers and below to choose gitstatus output
SCM_GIT_GITSTATUS_RAN=true
Expand All @@ -257,8 +257,8 @@ function git_prompt_vars {
fi

if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
commits_behind=${VCS_STATUS_COMMITS_BEHIND}
commits_ahead=${VCS_STATUS_COMMITS_AHEAD}
commits_behind=${VCS_STATUS_COMMITS_BEHIND?}
commits_ahead=${VCS_STATUS_COMMITS_AHEAD?}
else
IFS=$'\t' read -r commits_behind commits_ahead <<< "$(_git-upstream-behind-ahead)"
fi
Expand All @@ -274,7 +274,7 @@ function git_prompt_vars {
if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then
local stash_count
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
stash_count=${VCS_STATUS_STASHES}
stash_count=${VCS_STATUS_STASHES?}
else
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
fi
Expand All @@ -284,9 +284,9 @@ function git_prompt_vars {
SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
if ! _git-hide-status; then
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
untracked_count=${VCS_STATUS_NUM_UNTRACKED}
unstaged_count=${VCS_STATUS_NUM_UNSTAGED}
staged_count=${VCS_STATUS_NUM_STAGED}
untracked_count=${VCS_STATUS_NUM_UNTRACKED?}
unstaged_count=${VCS_STATUS_NUM_UNSTAGED?}
staged_count=${VCS_STATUS_NUM_STAGED?}
else
IFS=$'\t' read -r untracked_count unstaged_count staged_count <<< "$(_git-status-counts)"
fi
Expand Down Expand Up @@ -427,14 +427,15 @@ function rbenv_version_prompt {
}

function rbfu_version_prompt {
if [[ $RBFU_RUBY_VERSION ]]; then
if [[ -n "${RBFU_RUBY_VERSION:-}" ]]; then
echo -e "${RBFU_THEME_PROMPT_PREFIX}${RBFU_RUBY_VERSION}${RBFU_THEME_PROMPT_SUFFIX}"
fi
}

function chruby_version_prompt {
if declare -f -F chruby &> /dev/null; then
if declare -f -F chruby_auto &> /dev/null; then
local ruby_version
if _command_exists chruby; then
if _command_exists chruby_auto; then
chruby_auto
fi

Expand All @@ -443,12 +444,12 @@ function chruby_version_prompt {
if ! chruby | grep -q '\*'; then
ruby_version="${ruby_version} (system)"
fi
echo -e "${CHRUBY_THEME_PROMPT_PREFIX}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX}"
echo -e "${CHRUBY_THEME_PROMPT_PREFIX:-}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX:-}"
fi
}

function ruby_version_prompt {
if [[ "${THEME_SHOW_RUBY_PROMPT}" = "true" ]]; then
if [[ "${THEME_SHOW_RUBY_PROMPT:-}" == "true" ]]; then
echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)"
fi
}
Expand All @@ -462,21 +463,22 @@ function k8s_namespace_prompt {
}

function virtualenv_prompt {
if [[ -n "$VIRTUAL_ENV" ]]; then
virtualenv=$(basename "$VIRTUAL_ENV")
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
virtualenv="${VIRTUAL_ENV##*/}"
echo -e "$VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX"
fi
}

function condaenv_prompt {
if [[ $CONDA_DEFAULT_ENV ]]; then
echo -e "${CONDAENV_THEME_PROMPT_PREFIX}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX}"
if [[ -n "${CONDA_DEFAULT_ENV:-}" ]]; then
echo -e "${CONDAENV_THEME_PROMPT_PREFIX:-}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX:-}"
fi
}

function py_interp_prompt {
local py_version
py_version=$(python --version 2>&1 | awk 'NR==1{print "py-"$2;}') || return
echo -e "${PYTHON_THEME_PROMPT_PREFIX}${py_version}${PYTHON_THEME_PROMPT_SUFFIX}"
echo -e "${PYTHON_THEME_PROMPT_PREFIX:-}${py_version}${PYTHON_THEME_PROMPT_SUFFIX:-}"
}

function python_version_prompt {
Expand Down Expand Up @@ -504,7 +506,7 @@ function clock_char {
function clock_prompt {
CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$normal"}
CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H:%M:%S"}
[ -z "$THEME_SHOW_CLOCK" ] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:-"true"}
[[ -z "${THEME_SHOW_CLOCK:-}" ]] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:-"true"}
SHOW_CLOCK=$THEME_SHOW_CLOCK

if [[ "${SHOW_CLOCK}" = "true" ]]; then
Expand Down Expand Up @@ -574,7 +576,7 @@ if ! _command_exists battery_percentage; then
fi

function aws_profile {
if [[ $AWS_DEFAULT_PROFILE ]]; then
if [[ -n "${AWS_DEFAULT_PROFILE:-}" ]]; then
echo -e "${AWS_DEFAULT_PROFILE}"
else
echo -e "default"
Expand Down

0 comments on commit 6d58c8a

Please sign in to comment.