From 0f6b28e1e9a8b358e0f90ed1420981e4f7600e96 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sun, 5 Mar 2023 17:26:21 +0100 Subject: [PATCH] fixed SC2268 violation SC2268 (style): Avoid x-prefix in comparisons as it no longer serves a purpose --- .tmux.conf | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index ee021f5..57dc334 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -191,7 +191,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # TMUX_PID=$(printf '%s' "$TMUX" | cut -d, -f2) # TMUX_PROGRAM=$(lsof -b -w -a -d txt -p "$TMUX_PID" -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g) { print; exit } } exit 1; {" || readlink "/proc/$TMUX_PID/exe" 2>/dev/null || printf tmux) # fi -# if [ x"$TMUX_PROGRAM" = x"tmux" ]; then +# if [ "$TMUX_PROGRAM" = "tmux" ]; then # tmux() { # command tmux ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} "$@" # } @@ -204,15 +204,15 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # _tmux_version=$(tmux -V | awk '{gsub(/[^0-9.]/, "", $2); print ($2+0) * 100}') # # _is_true() { -# [ x"$1" = x"true" ] || [ x"$1" = x"yes" ] || [ x"$1" = x"1" ] +# [ "$1" = "true" ] || [ "$1" = "yes" ] || [ "$1" = "1" ] # } # # _is_enabled() { -# [ x"$1" = x"enabled" ] +# [ "$1" = "enabled" ] # } # # _is_disabled() { -# [ x"$1" = x"disabled" ] +# [ "$1" = "disabled" ] # } # # _circled() { @@ -272,7 +272,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # new_pane=${info#*.} # # retry=20 -# while [ x"$("$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} list-panes -t "$session_window" -F '#{session_name}:#{window_index}.#{pane_id} #{pane_dead}' 2>/dev/null)" != x"$info 1" ] && [ "$retry" -ne 0 ]; do +# while [ "$("$TMUX_PROGRAM" ${TMUX_SOCKET:+-S "$TMUX_SOCKET"} list-panes -t "$session_window" -F '#{session_name}:#{window_index}.#{pane_id} #{pane_dead}' 2>/dev/null)" != "$info 1" ] && [ "$retry" -ne 0 ]; do # sleep 0.1 # retry=$((retry - 1)) # done @@ -372,7 +372,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # # battery_status_charging=$1 # battery_status_discharging=$2 -# if [ x"$discharging" = x"true" ]; then +# if [ "$discharging" = "true" ]; then # battery_status="$battery_status_discharging" # else # battery_status="$battery_status_charging" @@ -398,7 +398,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # battery_hbar_palette=$5 # battery_vbar_palette=$6 # -# if [ x"$battery_bar_length" = x"auto" ]; then +# if [ "$battery_bar_length" = "auto" ]; then # columns=$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80) # if [ "$columns" -ge 80 ]; then # battery_bar_length=10 @@ -412,9 +412,9 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; } # palette_style=$1 # battery_bg=${2:-none} -# [ x"$palette_style" = x"gradient" ] && \ +# [ "$palette_style" = "gradient" ] && \ # palette="196 202 208 214 220 226 190 154 118 82 46" -# [ x"$palette_style" = x"heat" ] && \ +# [ "$palette_style" = "heat" ] && \ # palette="243 245 247 144 143 142 184 214 208 202 196" # # palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }') @@ -439,7 +439,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # battery_bg=$3 # # full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }") -# [ x"$battery_bg" != x"none" ] && \ +# [ "$battery_bg" != "none" ] && \ # battery_bar="#[bg=$battery_bg]" # #shellcheck disable=SC2046 # [ "$full" -gt 0 ] && \ @@ -455,9 +455,9 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # # shellcheck disable=SC2086 # { set -f; IFS=,; set -- $battery_hbar_palette; unset IFS; set +f; } # palette_style=$1 -# [ x"$palette_style" = x"gradient" ] && \ +# [ "$palette_style" = "gradient" ] && \ # palette="196 202 208 214 220 226 190 154 118 82 46" -# [ x"$palette_style" = x"heat" ] && \ +# [ "$palette_style" = "heat" ] && \ # palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196" # # palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }') @@ -482,9 +482,9 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # # shellcheck disable=SC2086 # { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; } # palette_style=$1 -# [ x"$palette_style" = x"gradient" ] && \ +# [ "$palette_style" = "gradient" ] && \ # palette="196 202 208 214 220 226 190 154 118 82 46" -# [ x"$palette_style" = x"heat" ] && \ +# [ "$palette_style" = "heat" ] && \ # palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196" # # palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }') @@ -649,7 +649,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # # username=$(_username "$pane_pid" "$pane_tty" false) # -# [ x"$username" = x"root" ] && echo "$root" +# [ "$username" = "root" ] && echo "$root" # } # # _uptime() { @@ -753,19 +753,19 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # _apply_24b() { # tmux_conf_theme_24b_colour=${tmux_conf_theme_24b_colour:-auto} # tmux_conf_24b_colour=${tmux_conf_24b_colour:-$tmux_conf_theme_24b_colour} -# if [ x"$tmux_conf_24b_colour" = x"auto" ]; then +# if [ "$tmux_conf_24b_colour" = "auto" ]; then # case "$COLORTERM" in # truecolor|24bit) # apply_24b=true # ;; # esac -# if [ x"$apply_24b" = x"" ] && [ x"$(tput colors)" = x"16777216" ]; then +# if [ "$apply_24b" = "" ] && [ "$(tput colors)" = "16777216" ]; then # apply_24b=true # fi # elif _is_true "$tmux_conf_24b_colour"; then # apply_24b=true # fi -# if [ x"$apply_24b" = x"true" ]; then +# if [ "$apply_24b" = "true" ]; then # case "$TERM" in # screen-*|tmux-*) # ;; @@ -987,26 +987,26 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # tmux_conf_theme_window_status_last_bg=${tmux_conf_theme_window_status_last_bg:-default} # tmux_conf_theme_window_status_last_attr=${tmux_conf_theme_window_status_last_attr:-none} # -# if [ x"$tmux_conf_theme_window_status_bg" = x"$tmux_conf_theme_status_bg" ] || [ x"$tmux_conf_theme_window_status_bg" = x"default" ]; then +# if [ "$tmux_conf_theme_window_status_bg" = "$tmux_conf_theme_status_bg" ] || [ "$tmux_conf_theme_window_status_bg" = "default" ]; then # spacer='' # spacer_current=' ' # else # spacer=' ' # spacer_current=' ' # fi -# if [ x"$tmux_conf_theme_window_status_last_bg" = x"$tmux_conf_theme_status_bg" ] || [ x"$tmux_conf_theme_window_status_last_bg" = x"default" ] ; then +# if [ "$tmux_conf_theme_window_status_last_bg" = "$tmux_conf_theme_status_bg" ] || [ "$tmux_conf_theme_window_status_last_bg" = "default" ] ; then # spacer_last='' # else # spacer_last=' ' # fi -# if [ x"$tmux_conf_theme_window_status_activity_bg" = x"$tmux_conf_theme_status_bg" ] || [ x"$tmux_conf_theme_window_status_activity_bg" = x"default" ] ; then +# if [ "$tmux_conf_theme_window_status_activity_bg" = "$tmux_conf_theme_status_bg" ] || [ "$tmux_conf_theme_window_status_activity_bg" = "default" ] ; then # spacer_activity='' # spacer_last_activity="$spacer_last" # else # spacer_activity=' ' # spacer_last_activity=' ' # fi -# if [ x"$tmux_conf_theme_window_status_bell_bg" = x"$tmux_conf_theme_status_bg" ] || [ x"$tmux_conf_theme_window_status_bell_bg" = x"default" ] ; then +# if [ "$tmux_conf_theme_window_status_bell_bg" = "$tmux_conf_theme_status_bg" ] || [ "$tmux_conf_theme_window_status_bell_bg" = "default" ] ; then # spacer_bell='' # spacer_last_bell="$spacer_last" # spacer_activity_bell="$spacer_activity" @@ -1018,7 +1018,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # spacer_last_activity_bell=' ' # fi # spacer="#{?window_last_flag,#{?window_activity_flag,#{?window_bell_flag,$spacer_last_activity_bell,$spacer_last_activity},#{?window_bell_flag,$spacer_last_bell,$spacer_last}},#{?window_activity_flag,#{?window_bell_flag,$spacer_activity_bell,$spacer_activity},#{?window_bell_flag,$spacer_bell,$spacer}}}" -# if [ x"$(tmux show -g -v status-justify)" = x"right" ]; then +# if [ "$(tmux show -g -v status-justify)" = "right" ]; then # if [ -z "$tmux_conf_theme_right_separator_main" ]; then # window_status_separator=' ' # else @@ -1404,7 +1404,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # # # -- custom variables ------------------------------------------------------ # -# if [ -f "$TMUX_CONF_LOCAL" ] && [ x"$(cut -c3- "$TMUX_CONF_LOCAL" | sh 2>/dev/null -s printf probe)" = x"probe" ]; then +# if [ -f "$TMUX_CONF_LOCAL" ] && [ "$(cut -c3- "$TMUX_CONF_LOCAL" | sh 2>/dev/null -s printf probe)" = "probe" ]; then # replacements=$(perl -n -e 'print if s!^#\s+([^_][^()\s]+)\s*\(\)\s*{\s*(?:#.*)?\n!s%#\\\{\1((?:\\s+(?:[^\{\}]+?|#\\{(?:[^\{\}]+?)\}))*)\\\}%#(cut -c3- \"\\\$TMUX_CONF_LOCAL\" | sh -s \1\\1)%g; !p' "$TMUX_CONF_LOCAL") # status_left=$(echo "$status_left" | perl -p -e "$replacements" || echo "$status_left") # status_right=$(echo "$status_right" | perl -p -e "$replacements" || echo "$status_right") @@ -1436,7 +1436,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # tmux display 'Done uninstalling tpm and plugins...' # fi # else -# if [ x"$(command tmux display -p '#{pid} #{version} #{socket_path}')" = x"$($TMUX_PROGRAM display -p '#{pid} #{version} #{socket_path}')" ]; then +# if [ "$(command tmux display -p '#{pid} #{version} #{socket_path}')" = "$($TMUX_PROGRAM display -p '#{pid} #{version} #{socket_path}')" ]; then # if git ls-remote -hq https://github.com/gpakosz/.tmux.git master > /dev/null; then # tpm_plugins=$(cat << EOF | tr ' ' '\n' | awk '/^\s*$/ {next;}; !seen[$0]++ { gsub(/^[ \t]+/,"",$0); gsub(/[ \t]+$/,"",$0); print $0 }' # $(awk '/^[ \t]*set(-option)?.*[ \t]@plugin[ \t]/ { gsub(/'\''/, ""); gsub(/'\"'/, ""); print $NF }' "$TMUX_CONF_LOCAL" 2>/dev/null) @@ -1453,14 +1453,14 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # tmux display 'Updating tpm and plugins...' # (cd "$TMUX_PLUGIN_MANAGER_PATH/tpm" && git fetch -q -p && git checkout -q master && git reset -q --hard origin/master) # fi -# if [ x"$install_tpm" = x"true" ] || [ x"$update_tpm" = x"true" ]; then +# if [ "$install_tpm" = "true" ] || [ "$update_tpm" = "true" ]; then # perl -0777 -p -i -e 's/git clone(?!\s+--depth\s+1)/git clone --depth 1/g # ;s/(install_plugin(.(?!&))*)\n(\s+)done/\1&\n\3done\n\3wait/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/install_plugins.sh" # perl -p -i -e 's/git submodule update --init --recursive(?!\s+--depth\s+1)/git submodule update --init --recursive --depth 1/g' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/update_plugin.sh" # perl -p -i -e 's,\$tmux_file\s+>/dev/null\s+2>\&1,$& || { tmux display "Plugin \$(basename \${plugin_path}) failed" && false; },' "$TMUX_PLUGIN_MANAGER_PATH/tpm/scripts/source_plugins.sh" # tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "$TMUX_PLUGIN_MANAGER_PATH" # fi -# if [ x"$update_tpm" = x"true" ]; then +# if [ "$update_tpm" = "true" ]; then # { # echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ # "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ @@ -1470,7 +1470,7 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration' # "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/clean_plugins" all >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 &&\ # tmux display 'Done updating tpm and plugins...' # } || tmux display 'Failed updating tpm and plugins...' -# elif [ x"$install_tpm" = x"true" ]; then +# elif [ "$install_tpm" = "true" ]; then # { # echo "Invoking $TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins ..." > "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1 && \ # "$TMUX_PLUGIN_MANAGER_PATH/tpm/bin/install_plugins" >> "$TMUX_PLUGIN_MANAGER_PATH/tpm_log.txt" 2>&1