mirror of
https://github.com/TECHNOFAB11/tmux2k.git
synced 2025-12-11 23:50:08 +01:00
style: shellcheck fixes
This commit is contained in:
parent
54ecf3dc0b
commit
de0e8225a6
10 changed files with 356 additions and 389 deletions
|
|
@ -1,25 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
get_tmux_option() {
|
||||
local option=$1
|
||||
local default_value=$2
|
||||
local option_value=$(tmux show-option -gqv "$option")
|
||||
if [ -z "$option_value" ]; then
|
||||
echo $default_value
|
||||
else
|
||||
echo $option_value
|
||||
fi
|
||||
local option=$1
|
||||
local default_value=$2
|
||||
local option_value=$(tmux show-option -gqv "$option")
|
||||
if [ -z "$option_value" ]; then
|
||||
echo $default_value
|
||||
else
|
||||
echo $option_value
|
||||
fi
|
||||
}
|
||||
|
||||
# normalize the percentage string to always have a length of 5
|
||||
normalize_percent_len() {
|
||||
# the max length that the percent can reach, which happens for a two digit number with a decimal house: "99.9%"
|
||||
max_len=5
|
||||
percent_len=${#1}
|
||||
let diff_len=$max_len-$percent_len
|
||||
# if the diff_len is even, left will have 1 more space than right
|
||||
let left_spaces=($diff_len+1)/2
|
||||
let right_spaces=($diff_len)/2
|
||||
printf "%${left_spaces}s%s%${right_spaces}s\n" "" $1 ""
|
||||
# the max length that the percent can reach, which happens for a two digit number with a decimal house: "99.9%"
|
||||
max_len=5
|
||||
percent_len=${#1}
|
||||
let diff_len=$max_len-$percent_len
|
||||
# if the diff_len is even, left will have 1 more space than right
|
||||
let left_spaces=($diff_len + 1)/2
|
||||
let right_spaces=($diff_len)/2
|
||||
printf "%${left_spaces}s%s%${right_spaces}s\n" "" $1 ""
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue