Skip to content

Commit 116c0ca

Browse files
authored
Cleanup (#421)
* comply with shellfmt * activate shellfmt in super-linter
1 parent 03b8f7f commit 116c0ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+584
-583
lines changed

.github/workflows/linter-full.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Lint Code Base
23

34
on:
@@ -20,7 +21,8 @@ jobs:
2021
- name: Checkout Code
2122
uses: actions/checkout@v4
2223
with:
23-
# Full git history is needed to get a proper list of changed files within `super-linter`
24+
# Full git history is needed to get a proper list of changed
25+
# files within `super-linter`
2426
fetch-depth: 0
2527
- name: Lint Code Base
2628
uses: super-linter/[email protected]
@@ -30,6 +32,5 @@ jobs:
3032
VALIDATE_BASH_EXEC: false
3133
VALIDATE_CPP: false
3234
VALIDATE_CLANG_FORMAT: false
33-
VALIDATE_SHELL_SHFMT: false
3435
VALIDATE_PYTHON_PYLINT: false
3536
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/linter-pr.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Lint Pull Request
23

34
on:
@@ -20,7 +21,8 @@ jobs:
2021
- name: Checkout Code
2122
uses: actions/checkout@v4
2223
with:
23-
# Full git history is needed to get a proper list of changed files within `super-linter`
24+
# Full git history is needed to get a proper list of changed
25+
# files within `super-linter`
2426
fetch-depth: 0
2527
- name: Lint Code Base
2628
uses: super-linter/super-linter@v6
@@ -30,6 +32,5 @@ jobs:
3032
VALIDATE_BASH_EXEC: false
3133
VALIDATE_CPP: false
3234
VALIDATE_CLANG_FORMAT: false
33-
VALIDATE_SHELL_SHFMT: false
3435
VALIDATE_PYTHON_PYLINT: false
3536
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/stale.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: "Close stale issues and PRs"
23
on:
34
workflow_dispatch:

color_palette.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# Idea from http://superuser.com/questions/285381/how-does-the-tmux-color-palette-work
44

55
for i in $(seq 0 8 255); do
6-
for j in $(seq "$i" $(( i + 7 ))); do
7-
for _unused in $(seq 1 $(( 7 - ${#j} ))); do
6+
for j in $(seq "$i" $((i + 7))); do
7+
for _unused in $(seq 1 $((7 - ${#j}))); do
88
echo -n " "
99
done
1010
echo -en "\x1b[38;5;${j}mcolour${j}"
11-
[[ $(( j % 8 )) != 7 ]] && echo -n " "
11+
[[ $((j % 8)) != 7 ]] && echo -n " "
1212
done
1313
echo
1414
done

config/helpers.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Other settings and helper functions.
33

44
debug_mode_enabled() {
5-
[ -n "$TMUX_POWERLINE_DEBUG_MODE_ENABLED" ] && [ "$TMUX_POWERLINE_DEBUG_MODE_ENABLED" != "false" ];
5+
[ -n "$TMUX_POWERLINE_DEBUG_MODE_ENABLED" ] && [ "$TMUX_POWERLINE_DEBUG_MODE_ENABLED" != "false" ]
66
}
77

88
patched_font_in_use() {
9-
[ -z "$TMUX_POWERLINE_PATCHED_FONT_IN_USE" ] || [ "$TMUX_POWERLINE_PATCHED_FONT_IN_USE" != "false" ];
9+
[ -z "$TMUX_POWERLINE_PATCHED_FONT_IN_USE" ] || [ "$TMUX_POWERLINE_PATCHED_FONT_IN_USE" != "false" ]
1010
}

config/shell.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ ostype() { echo "$OSTYPE" | tr '[:upper:]' '[:lower:]'; }
77
export SHELL_PLATFORM='unknown'
88

99
case "$(ostype)" in
10-
*'linux'* ) SHELL_PLATFORM='linux' ;;
11-
*'darwin'* ) SHELL_PLATFORM='osx' ;;
12-
*'bsd'* ) SHELL_PLATFORM='bsd' ;;
10+
*'linux'*) SHELL_PLATFORM='linux' ;;
11+
*'darwin'*) SHELL_PLATFORM='osx' ;;
12+
*'bsd'*) SHELL_PLATFORM='bsd' ;;
1313
esac
1414

1515
shell_is_linux() { [[ $SHELL_PLATFORM == 'linux' || $SHELL_PLATFORM == 'bsd' ]]; }
16-
shell_is_osx() { [[ $SHELL_PLATFORM == 'osx' ]]; }
17-
shell_is_bsd() { [[ $SHELL_PLATFORM == 'bsd' || $SHELL_PLATFORM == 'osx' ]]; }
16+
shell_is_osx() { [[ $SHELL_PLATFORM == 'osx' ]]; }
17+
shell_is_bsd() { [[ $SHELL_PLATFORM == 'bsd' || $SHELL_PLATFORM == 'osx' ]]; }
1818

1919
export -f shell_is_linux
2020
export -f shell_is_osx

generate_config.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
# Generate default config file.
33

4-
TMUX_POWERLINE_DIR_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
TMUX_POWERLINE_DIR_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
export TMUX_POWERLINE_DIR_HOME
66

77
source "${TMUX_POWERLINE_DIR_HOME}/config/paths.sh"

lib/arg_processing.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
check_arg_segment() {
55
local segment="$1"
6-
if ! [[ "$segment" == "left" || "$segment" == "right" || "$segment" == "window-current-format" || "$segment" == "window-format" ]]; then
6+
if ! [[ "$segment" == "left" || "$segment" == "right" || "$segment" == "window-current-format" || "$segment" == "window-format" ]]; then
77
echo "Argument must be the side to handle {left, right}, or {window-current-format, window-format}, not \"${segment}\"."
8-
exit 1
8+
exit 1
99
fi
1010
}

lib/colors.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ __normalize_color() {
1919
local result
2020

2121
case "$input" in
22-
[0-9]|[0-9][0-9]|[0-9][0-9][0-9]) # handle 1 to 3 digits
23-
result="colour$input"
24-
;;
25-
*) # Catch-all
26-
result=$input
27-
;;
22+
[0-9] | [0-9][0-9] | [0-9][0-9][0-9]) # handle 1 to 3 digits
23+
result="colour$input"
24+
;;
25+
*) # Catch-all
26+
result=$input
27+
;;
2828
esac
2929

3030
echo -n "$result"

lib/config_file.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,10 @@ process_settings() {
8080

8181
export TMUX_POWERLINE_STATUS_STYLE="fg=$fg_color,bg=$bg_color"
8282
fi
83-
84-
8583
}
8684

8785
generate_default_config() {
88-
read -r -d '' config_contents << EORC
86+
read -r -d '' config_contents <<EORC
8987
# Default configuration file for tmux-powerline.
9088
# Modeline {
9189
# vi: foldmarker={,} foldmethod=marker foldlevel=0 tabstop=4 filetype=sh
@@ -142,13 +140,13 @@ EORC
142140
fi
143141
done
144142

145-
echo -e "$config_contents" > "$TMUX_POWERLINE_CONFIG_FILE_DEFAULT"
143+
echo -e "$config_contents" >"$TMUX_POWERLINE_CONFIG_FILE_DEFAULT"
146144
echo "Default configuration file generated to: ${TMUX_POWERLINE_CONFIG_FILE_DEFAULT}"
147145
echo "Copy/move it to \"${TMUX_POWERLINE_CONFIG_FILE}\" and make your changes."
148146
}
149147

150148
__read_config_file() {
151-
if [ -f "$TMUX_POWERLINE_CONFIG_FILE" ]; then
149+
if [ -f "$TMUX_POWERLINE_CONFIG_FILE" ]; then
152150
# shellcheck disable=SC1090
153151
source "$TMUX_POWERLINE_CONFIG_FILE"
154152
fi

lib/headers.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Source all needed libs and helpers, kind of like a main.h.
33

44
if [ -z "$TMUX_POWERLINE_DIR_HOME" ]; then
5-
lib_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+
lib_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
TMUX_POWERLINE_DIR_HOME="$(dirname "$lib_dir")" # step up to parent dir.
77

88
export TMUX_POWERLINE_DIR_HOME

lib/muting.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# In all cases $1 is the side to be muted (eg left/right).
44

55
powerline_muted() {
6-
[ -e "$(__powerline_mute_file "$1")" ];
6+
[ -e "$(__powerline_mute_file "$1")" ]
77
}
88

99
toggle_powerline_mute_status() {

lib/powerline.sh

+34-36
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ print_powerline_side() {
2222
print_powerline_window_status_current_format() {
2323
if [ -z "$TMUX_POWERLINE_WINDOW_STATUS_CURRENT" ]; then
2424
TMUX_POWERLINE_WINDOW_STATUS_CURRENT=(
25-
"#[$(format inverse)]" \
26-
"$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR" \
27-
" #I#F " \
28-
"$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" \
29-
" #W " \
30-
"#[$(format regular)]" \
25+
"#[$(format inverse)]"
26+
"$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR"
27+
" #I#F "
28+
"$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN"
29+
" #W "
30+
"#[$(format regular)]"
3131
"$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR"
3232
)
3333
fi
@@ -38,9 +38,9 @@ print_powerline_window_status_current_format() {
3838
print_powerline_window_status_format() {
3939
if [ -z "$TMUX_POWERLINE_WINDOW_STATUS_FORMAT" ]; then
4040
TMUX_POWERLINE_WINDOW_STATUS_FORMAT=(
41-
"#[$(format regular)]" \
42-
" #I#{?window_flags,#F, } " \
43-
"$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" \
41+
"#[$(format regular)]"
42+
" #I#{?window_flags,#F, } "
43+
"$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN"
4444
" #W "
4545
)
4646
fi
@@ -57,31 +57,30 @@ format() {
5757
fg_color=$(__normalize_color "$TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR")
5858

5959
case $type in
60-
inverse)
61-
echo "fg=$bg_color,bg=$fg_color,nobold,noitalics,nounderscore"
62-
;;
63-
regular)
64-
echo "fg=$fg_color,bg=$bg_color,nobold,noitalics,nounderscore"
65-
;;
66-
*)
67-
;;
60+
inverse)
61+
echo "fg=$bg_color,bg=$fg_color,nobold,noitalics,nounderscore"
62+
;;
63+
regular)
64+
echo "fg=$fg_color,bg=$bg_color,nobold,noitalics,nounderscore"
65+
;;
66+
*) ;;
6867
esac
6968
}
7069

7170
__process_segment_defaults() {
7271
# shellcheck disable=SC2154 # disable until we found a better solution for eval input_segments
7372
for segment_index in "${!input_segments[@]}"; do
7473
local input_segment
75-
read -r -a input_segment <<< "${input_segments[segment_index]}"
74+
read -r -a input_segment <<<"${input_segments[segment_index]}"
7675
eval "local default_separator=\$TMUX_POWERLINE_DEFAULT_${upper_side}SIDE_SEPARATOR"
7776

7877
powerline_segment_with_defaults=(
79-
"${input_segment[0]:-no_script}" \
80-
"${input_segment[1]:-$TMUX_POWERLINE_DEFAULT_BACKGROUND_COLOR}" \
81-
"${input_segment[2]:-$TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}" \
82-
"${input_segment[3]:-$default_separator}" \
83-
"${input_segment[6]:-$spacing_disable}" \
84-
"${input_segment[7]:-$separator_disable}" \
78+
"${input_segment[0]:-no_script}"
79+
"${input_segment[1]:-$TMUX_POWERLINE_DEFAULT_BACKGROUND_COLOR}"
80+
"${input_segment[2]:-$TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}"
81+
"${input_segment[3]:-$default_separator}"
82+
"${input_segment[6]:-$spacing_disable}"
83+
"${input_segment[7]:-$separator_disable}"
8584
)
8685

8786
powerline_segments[segment_index]="${powerline_segment_with_defaults[*]}"
@@ -91,9 +90,9 @@ __process_segment_defaults() {
9190
__process_scripts() {
9291
for segment_index in "${!powerline_segments[@]}"; do
9392
local powerline_segment
94-
read -r -a powerline_segment <<< "${powerline_segments[segment_index]}"
93+
read -r -a powerline_segment <<<"${powerline_segments[segment_index]}"
9594

96-
if [ -n "$TMUX_POWERLINE_DIR_USER_SEGMENTS" ] && [ -f "$TMUX_POWERLINE_DIR_USER_SEGMENTS/${powerline_segment[0]}.sh" ] ; then
95+
if [ -n "$TMUX_POWERLINE_DIR_USER_SEGMENTS" ] && [ -f "$TMUX_POWERLINE_DIR_USER_SEGMENTS/${powerline_segment[0]}.sh" ]; then
9796
local script="$TMUX_POWERLINE_DIR_USER_SEGMENTS/${powerline_segment[0]}.sh"
9897
else
9998
local script="$TMUX_POWERLINE_DIR_SEGMENTS/${powerline_segment[0]}.sh"
@@ -109,7 +108,7 @@ __process_scripts() {
109108
local exit_code="$?"
110109
unset -f run_segment
111110

112-
if [ "$exit_code" -ne 0 ] && debug_mode_enabled ; then
111+
if [ "$exit_code" -ne 0 ] && debug_mode_enabled; then
113112
local seg_name="${script##*/}"
114113
echo "Segment '${seg_name}' exited with code ${exit_code}. Aborting."
115114
exit 1
@@ -134,14 +133,14 @@ __process_scripts() {
134133
__process_colors() {
135134
for segment_index in "${!powerline_segments[@]}"; do
136135
local powerline_segment
137-
read -r -a powerline_segment <<< "${powerline_segments[segment_index]}"
136+
read -r -a powerline_segment <<<"${powerline_segments[segment_index]}"
138137
local separator_enable=${powerline_segment[5]}
139138
# Find the next segment that produces content (i.e. skip empty segments).
140-
for next_segment_index in $(eval echo "{$((segment_index + 1))..${#powerline_segments}}") ; do
139+
for next_segment_index in $(eval echo "{$((segment_index + 1))..${#powerline_segments}}"); do
141140
[[ -n ${powerline_segments[next_segment_index]} ]] && break
142141
done
143142
local next_segment
144-
read -r -a next_segment <<< "${powerline_segments[next_segment_index]}"
143+
read -r -a next_segment <<<"${powerline_segments[next_segment_index]}"
145144

146145
if [ "$side" == 'left' ]; then
147146
powerline_segment[4]=${next_segment[1]:-$TMUX_POWERLINE_DEFAULT_BACKGROUND_COLOR}
@@ -165,7 +164,7 @@ __process_colors() {
165164
__process_powerline() {
166165
for segment_index in "${!powerline_segments[@]}"; do
167166
local powerline_segment
168-
read -r -a powerline_segment <<< "${powerline_segments[segment_index]}"
167+
read -r -a powerline_segment <<<"${powerline_segments[segment_index]}"
169168

170169
local background_color=${powerline_segment[1]}
171170
local foreground_color=${powerline_segment[2]}
@@ -188,7 +187,7 @@ __print_left_segment() {
188187
local separator_disable=$7
189188

190189
__print_colored_content "$content" "$content_background_color" "$content_foreground_color"
191-
if [ ! "$separator_disable" == "separator_disable" ] ; then
190+
if [ ! "$separator_disable" == "separator_disable" ]; then
192191
__print_colored_content "$separator" "$separator_background_color" "$separator_foreground_color"
193192
fi
194193
}
@@ -202,19 +201,18 @@ __print_right_segment() {
202201
local separator_foreground_color=$6
203202
local separator_disable=$7
204203

205-
if [ ! "$separator_disable" == "separator_disable" ] ; then
204+
if [ ! "$separator_disable" == "separator_disable" ]; then
206205
__print_colored_content "$separator" "$separator_background_color" "$separator_foreground_color"
207206
fi
208207
__print_colored_content "$content" "$content_background_color" "$content_foreground_color"
209208
}
210209

211210
__segment_separator_is_thin() {
212-
[[ ${powerline_segment[3]} == "$TMUX_POWERLINE_SEPARATOR_LEFT_THIN" || \
213-
${powerline_segment[3]} == "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" ]];
211+
[[ ${powerline_segment[3]} == "$TMUX_POWERLINE_SEPARATOR_LEFT_THIN" || ${powerline_segment[3]} == "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" ]]
214212
}
215213

216214
__check_platform() {
217215
if [ "$SHELL_PLATFORM" == "unknown" ] && debug_mode_enabled; then
218-
echo "Unknown platform; modify config/shell.sh" >&2
216+
echo "Unknown platform; modify config/shell.sh" >&2
219217
fi
220218
}

lib/text_roll.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
# arg4: mode to fill {"space", "repeat"}
77
# arg5: repeat separator
88
roll_text() {
9-
local text="$1" # Text to print
9+
local text="$1" # Text to print
1010

1111
if [ -z "$text" ]; then
12-
return;
12+
return
1313
fi
1414

15-
local max_len="10" # Default max length.
15+
local max_len="10" # Default max length.
1616

1717
if [ -n "$2" ]; then
1818
max_len="$2"
1919
fi
2020

21-
local speed="1" # Default roll speed in chars per second.
21+
local speed="1" # Default roll speed in chars per second.
2222

2323
if [ -n "$3" ]; then
2424
speed="$3"
@@ -60,13 +60,13 @@ roll_text() {
6060
# Truncate text on time-based offset
6161
text=${text:offset}
6262

63-
# Ensure text is not longer than max_len
63+
# Ensure text is not longer than max_len
6464
text=${text:0:max_len}
6565

6666
# Get fill count by substracting length of current text from max_len
6767
local fill_count=$((max_len - ${#text}))
6868

69-
for ((index=0; index < fill_count; index++)); do
69+
for ((index = 0; index < fill_count; index++)); do
7070
if [ "$fill_mode" = "repeat" ]; then
7171
text="${text}${repeat:index:1}"
7272
elif [ "$fill_mode" = "space" ] || :; then

0 commit comments

Comments
 (0)