Merge pull request #1785 from marcospereira/lint/themes/base.theme.bash

Add themes/base.theme.bash to clean files
pull/1783/head^2
Noah Gorny 2021-01-13 19:15:09 +02:00 committed by GitHub
commit a9b0ec7d1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 338 additions and 323 deletions

View File

@ -30,6 +30,7 @@ themes/agnoster
themes/90210 themes/90210
themes/powerline themes/powerline
themes/barbuk themes/barbuk
themes/base.theme.bash
# plugins # plugins
# #

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
CLOCK_CHAR_THEME_PROMPT_PREFIX='' CLOCK_CHAR_THEME_PROMPT_PREFIX=''
CLOCK_CHAR_THEME_PROMPT_SUFFIX='' CLOCK_CHAR_THEME_PROMPT_SUFFIX=''
@ -92,33 +92,47 @@ SVN_EXE=$(which svn 2> /dev/null || true)
# Check for broken SVN exe that is caused by some versions of Xcode. # 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. # See https://github.com/Bash-it/bash-it/issues/1612 for more details.
if [[ -x "$SVN_EXE" ]] ; then if [[ -x "$SVN_EXE" ]]; then
if ! "$SVN_EXE" --version > /dev/null 2>&1 ; then if ! "$SVN_EXE" --version > /dev/null 2>&1; then
# Unset the SVN exe variable so that SVN commands are avoided. # Unset the SVN exe variable so that SVN commands are avoided.
SVN_EXE="" SVN_EXE=""
fi fi
fi fi
function scm { function scm {
if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE if [[ "$SCM_CHECK" = false ]]; then
elif [[ -f .git/HEAD ]] && [[ -x "$GIT_EXE" ]]; then SCM=$SCM_GIT SCM=$SCM_NONE
elif [[ -x "$GIT_EXE" ]] && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT elif [[ -f .git/HEAD ]] && [[ -x "$GIT_EXE" ]]; then
elif [[ -x "$P4_EXE" ]] && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then SCM=$SCM_P4 SCM=$SCM_GIT
elif [[ -d .hg ]] && [[ -x "$HG_EXE" ]]; then SCM=$SCM_HG elif [[ -x "$GIT_EXE" ]] && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then
elif [[ -x "$HG_EXE" ]] && [[ -n "$(hg root 2> /dev/null)" ]]; then SCM=$SCM_HG SCM=$SCM_GIT
elif [[ -d .svn ]] && [[ -x "$SVN_EXE" ]]; then SCM=$SCM_SVN elif [[ -x "$P4_EXE" ]] && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then
elif [[ -x "$SVN_EXE" ]] && [[ -n "$(svn info --show-item wc-root 2>/dev/null)" ]]; then SCM=$SCM_SVN SCM=$SCM_P4
else SCM=$SCM_NONE elif [[ -d .hg ]] && [[ -x "$HG_EXE" ]]; then
SCM=$SCM_HG
elif [[ -x "$HG_EXE" ]] && [[ -n "$(hg root 2> /dev/null)" ]]; then
SCM=$SCM_HG
elif [[ -d .svn ]] && [[ -x "$SVN_EXE" ]]; then
SCM=$SCM_SVN
elif [[ -x "$SVN_EXE" ]] && [[ -n "$(svn info --show-item wc-root 2> /dev/null)" ]]; then
SCM=$SCM_SVN
else
SCM=$SCM_NONE
fi fi
} }
function scm_prompt_char { function scm_prompt_char {
if [[ -z $SCM ]]; then scm; fi if [[ -z $SCM ]]; then scm; fi
if [[ $SCM == $SCM_GIT ]]; then SCM_CHAR=$SCM_GIT_CHAR if [[ $SCM == "$SCM_GIT" ]]; then
elif [[ $SCM == $SCM_P4 ]]; then SCM_CHAR=$SCM_P4_CHAR SCM_CHAR=$SCM_GIT_CHAR
elif [[ $SCM == $SCM_HG ]]; then SCM_CHAR=$SCM_HG_CHAR elif [[ $SCM == "$SCM_P4" ]]; then
elif [[ $SCM == $SCM_SVN ]]; then SCM_CHAR=$SCM_SVN_CHAR SCM_CHAR=$SCM_P4_CHAR
else SCM_CHAR=$SCM_NONE_CHAR elif [[ $SCM == "$SCM_HG" ]]; then
SCM_CHAR=$SCM_HG_CHAR
elif [[ $SCM == "$SCM_SVN" ]]; then
SCM_CHAR=$SCM_SVN_CHAR
else
SCM_CHAR=$SCM_NONE_CHAR
fi fi
} }
@ -127,10 +141,10 @@ function scm_prompt_vars {
scm_prompt_char scm_prompt_char
SCM_DIRTY=0 SCM_DIRTY=0
SCM_STATE='' SCM_STATE=''
[[ $SCM == $SCM_GIT ]] && git_prompt_vars && return [[ $SCM == "$SCM_GIT" ]] && git_prompt_vars && return
[[ $SCM == $SCM_P4 ]] && p4_prompt_vars && return [[ $SCM == "$SCM_P4" ]] && p4_prompt_vars && return
[[ $SCM == $SCM_HG ]] && hg_prompt_vars && return [[ $SCM == "$SCM_HG" ]] && hg_prompt_vars && return
[[ $SCM == $SCM_SVN ]] && svn_prompt_vars && return [[ $SCM == "$SCM_SVN" ]] && svn_prompt_vars && return
} }
function scm_prompt_info { function scm_prompt_info {
@ -149,7 +163,7 @@ function scm_prompt_info_common {
SCM_DIRTY=0 SCM_DIRTY=0
SCM_STATE='' SCM_STATE=''
if [[ ${SCM} == ${SCM_GIT} ]]; then if [[ ${SCM} == "${SCM_GIT}" ]]; then
if [[ ${SCM_GIT_SHOW_MINIMAL_INFO} == true ]]; then if [[ ${SCM_GIT_SHOW_MINIMAL_INFO} == true ]]; then
# user requests minimal git status information # user requests minimal git status information
git_prompt_minimal_info git_prompt_minimal_info
@ -161,15 +175,15 @@ function scm_prompt_info_common {
fi fi
# TODO: consider adding minimal status information for hg and svn # TODO: consider adding minimal status information for hg and svn
{ [[ ${SCM} == ${SCM_P4} ]] && p4_prompt_info && return; } || true { [[ ${SCM} == "${SCM_P4}" ]] && p4_prompt_info && return; } || true
{ [[ ${SCM} == ${SCM_HG} ]] && hg_prompt_info && return; } || true { [[ ${SCM} == "${SCM_HG}" ]] && hg_prompt_info && return; } || true
{ [[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return; } || true { [[ ${SCM} == "${SCM_SVN}" ]] && svn_prompt_info && return; } || true
} }
function terraform_workspace_prompt { function terraform_workspace_prompt {
if _command_exists terraform ; then if _command_exists terraform; then
if [ -d .terraform ]; then if [ -d .terraform ]; then
echo -e "$(terraform workspace show 2>/dev/null)" echo -e "$(terraform workspace show 2> /dev/null)"
fi fi
fi fi
} }
@ -265,7 +279,7 @@ function git_prompt_vars {
SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
SCM_CHANGE=$(_git-short-sha 2>/dev/null || echo "") SCM_CHANGE=$(_git-short-sha 2> /dev/null || echo "")
} }
function p4_prompt_vars { function p4_prompt_vars {
@ -289,7 +303,7 @@ function p4_prompt_vars {
} }
function svn_prompt_vars { function svn_prompt_vars {
if [[ -n $(svn status |head -c1 2> /dev/null) ]]; then if [[ -n $(svn status | head -c1 2> /dev/null) ]]; then
SCM_DIRTY=1 SCM_DIRTY=1
SCM_STATE=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} SCM_STATE=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else else
@ -318,7 +332,7 @@ function get_hg_root {
return return
fi fi
CURRENT_DIR=$(dirname $CURRENT_DIR) CURRENT_DIR=$(dirname "$CURRENT_DIR")
done done
} }
@ -375,8 +389,8 @@ function rvm_version_prompt {
function rbenv_version_prompt { function rbenv_version_prompt {
if which rbenv &> /dev/null; then if which rbenv &> /dev/null; then
rbenv=$(rbenv version-name) || return rbenv=$(rbenv version-name) || return
$(rbenv commands | grep -q gemset) && gemset=$(rbenv gemset active 2> /dev/null) && rbenv="$rbenv@${gemset%% *}" $rbenv commands | grep -q gemset && gemset=$(rbenv gemset active 2> /dev/null) && rbenv="$rbenv@${gemset%% *}"
if [ $rbenv != "system" ]; then if [ "$rbenv" != "system" ]; then
echo -e "$RBENV_THEME_PROMPT_PREFIX$rbenv$RBENV_THEME_PROMPT_SUFFIX" echo -e "$RBENV_THEME_PROMPT_PREFIX$rbenv$RBENV_THEME_PROMPT_SUFFIX"
fi fi
fi fi
@ -396,7 +410,7 @@ function chruby_version_prompt {
ruby_version=$(ruby --version | awk '{print $1, $2;}') || return ruby_version=$(ruby --version | awk '{print $1, $2;}') || return
if [[ ! $(chruby | grep '\*') ]]; then if ! chruby | grep -q '\*'; then
ruby_version="${ruby_version} (system)" ruby_version="${ruby_version} (system)"
fi 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}"
@ -415,7 +429,7 @@ function k8s_context_prompt {
function virtualenv_prompt { function virtualenv_prompt {
if [[ -n "$VIRTUAL_ENV" ]]; then if [[ -n "$VIRTUAL_ENV" ]]; then
virtualenv=`basename "$VIRTUAL_ENV"` virtualenv=$(basename "$VIRTUAL_ENV")
echo -e "$VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX" echo -e "$VIRTUALENV_THEME_PROMPT_PREFIX$virtualenv$VIRTUALENV_THEME_PROMPT_SUFFIX"
fi fi
} }
@ -439,7 +453,7 @@ function git_user_info {
# support two or more initials, set by 'git pair' plugin # support two or more initials, set by 'git pair' plugin
SCM_CURRENT_USER=$(git config user.initials | sed 's% %+%') SCM_CURRENT_USER=$(git config user.initials | sed 's% %+%')
# if `user.initials` weren't set, attempt to extract initials from `user.name` # if `user.initials` weren't set, attempt to extract initials from `user.name`
[[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" $(for word in $(git config user.name | PERLIO=:utf8 perl -pe '$_=lc'); do printf "%s" "${word:0:1}"; done)) [[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" "$(for word in $(git config user.name | PERLIO=:utf8 perl -pe '$_=lc'); do printf "%s" "${word:0:1}"; done)")
[[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX" [[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX"
} }
@ -456,7 +470,7 @@ function clock_char {
function clock_prompt { function clock_prompt {
CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$normal"} CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$normal"}
CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H:%M:%S"} 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 SHOW_CLOCK=$THEME_SHOW_CLOCK
if [[ "${SHOW_CLOCK}" = "true" ]]; then if [[ "${SHOW_CLOCK}" = "true" ]]; then
@ -508,9 +522,9 @@ function battery_char {
fi fi
} }
if ! _command_exists battery_charge ; then if ! _command_exists battery_charge; then
# if user has installed battery plugin, skip this... # if user has installed battery plugin, skip this...
function battery_charge (){ function battery_charge() {
# no op # no op
echo -n echo -n
} }
@ -518,8 +532,8 @@ fi
# The battery_char function depends on the presence of the battery_percentage function. # The battery_char function depends on the presence of the battery_percentage function.
# If battery_percentage is not defined, then define battery_char as a no-op. # If battery_percentage is not defined, then define battery_char as a no-op.
if ! _command_exists battery_percentage ; then if ! _command_exists battery_percentage; then
function battery_char (){ function battery_char() {
# no op # no op
echo -n echo -n
} }
@ -548,7 +562,7 @@ function safe_append_prompt_command {
if [ "${__bp_imported}" == "defined" ]; then if [ "${__bp_imported}" == "defined" ]; then
# We are using bash-preexec # We are using bash-preexec
if ! __check_precmd_conflict "${1}" ; then if ! __check_precmd_conflict "${1}"; then
precmd_functions+=("${1}") precmd_functions+=("${1}")
fi fi
else else