themes: disable SC2154, fix SC2155

Each one of these themes will need it’s own fix for SC2154, possibly upstream.

Due to the way themes are, it's entirely normal to have a *lot* of false positives for SC2034. So much so, that I have to admit that it is probably just not worth linting for SC2034 despite my dislike of blanket ignore rules.
pull/1947/head
John D Pell 2021-09-14 21:53:05 -07:00
parent 14bfdb5956
commit 16b5c09249
4 changed files with 22 additions and 12 deletions

View File

@ -1,4 +1,7 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX=" |"
@ -11,7 +14,7 @@ GIT_THEME_PROMPT_SUFFIX="${green}|"
# Nicely formatted terminal prompt
function prompt_command() {
export PS1="\n${bold_black}[${blue}\@${bold_black}]-${bold_black}[${green}\u${yellow}@${green}\h${bold_black}]-${bold_black}[${purple}\w${bold_black}]-$(scm_prompt_info)\n${reset_color}\$ "
PS1="\n${bold_black}[${blue}\@${bold_black}]-${bold_black}[${green}\u${yellow}@${green}\h${bold_black}]-${bold_black}[${purple}\w${bold_black}]-$(scm_prompt_info)\n${reset_color}\$ "
}
safe_append_prompt_command prompt_command

View File

@ -1,4 +1,7 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
# Define this here so it can be used by all of the Powerline themes
THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=true}
@ -139,7 +142,7 @@ function __powerline_scm_prompt() {
}
function __powerline_cwd_prompt() {
local cwd=$(pwd | sed "s|^${HOME}|~|")
local cwd="${PWD/$HOME/\~}"
echo "${cwd}|${CWD_THEME_PROMPT_COLOR}"
}
@ -157,10 +160,10 @@ function __powerline_clock_prompt() {
}
function __powerline_battery_prompt() {
local color=""
local battery_status="$(battery_percentage 2> /dev/null)"
local color="" battery_status
battery_status="$(battery_percentage 2> /dev/null)"
if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then
if [[ -z "${battery_status}" || "${battery_status}" == "-1" || "${battery_status}" == "no" ]]; then
true
else
if [[ "$((10#${battery_status}))" -le 5 ]]; then
@ -176,7 +179,7 @@ function __powerline_battery_prompt() {
}
function __powerline_in_vim_prompt() {
if [ -n "$VIMRUNTIME" ]; then
if [[ -n "$VIMRUNTIME" ]]; then
echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}"
fi
}
@ -221,7 +224,8 @@ function __powerline_command_number_prompt() {
}
function __powerline_duration_prompt() {
local duration=$(_command_duration)
local duration
duration=$(_command_duration)
[[ -n "$duration" ]] && echo "${duration}|${COMMAND_DURATION_PROMPT_COLOR}"
}
@ -265,7 +269,7 @@ function __powerline_last_status_prompt() {
function __powerline_prompt_command() {
local last_status="$?" ## always the first
local separator_char="${POWERLINE_PROMPT_CHAR}"
local separator_char="${POWERLINE_PROMPT_CHAR}" info prompt_color
LEFT_PROMPT=""
SEGMENTS_AT_LEFT=0
@ -277,7 +281,7 @@ function __powerline_prompt_command() {
## left prompt ##
for segment in $POWERLINE_PROMPT; do
local info="$(__powerline_"${segment}"_prompt)"
info="$(__powerline_"${segment}"_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
@ -289,7 +293,7 @@ function __powerline_prompt_command() {
# By default we try to match the prompt to the adjacent segment's background color,
# but when part of the prompt exists within that segment, we instead match the foreground color.
local prompt_color="$(set_color "${LAST_SEGMENT_COLOR}" -)"
prompt_color="$(set_color "${LAST_SEGMENT_COLOR}" -)"
if [[ -n "${LEFT_PROMPT}" ]] && [[ -n "${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}" ]]; then
LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}")${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}"
prompt_color="${normal}"

View File

@ -1,4 +1,5 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck source=../../themes/powerline/powerline.base.bash
. "$BASH_IT/themes/powerline/powerline.base.bash"

View File

@ -1,4 +1,6 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
@ -26,8 +28,8 @@ venv_prompt() {
}
function prompt_command() {
retval=$?
local ret_status="$([ $retval -eq 0 ] && echo -e "$STATUS_THEME_PROMPT_OK" || echo -e "$STATUS_THEME_PROMPT_BAD")"
local retval=$? ret_status
ret_status="$([ $retval -eq 0 ] && echo -e "$STATUS_THEME_PROMPT_OK" || echo -e "$STATUS_THEME_PROMPT_BAD")"
PS1="\n${PURITY_THEME_PROMPT_COLOR}\w $(scm_prompt_info)\n${ret_status}$(venv_prompt)"
}