2021-07-06 11:21:21 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
get_tmux_option() {
|
|
|
|
local option=$1
|
|
|
|
local default_value=$2
|
|
|
|
local option_value=$(tmux show-option -gqv "$option")
|
2021-07-19 08:19:41 +02:00
|
|
|
if [ -z "$option_value" ]; then
|
2021-07-06 11:21:21 +02:00
|
|
|
echo $default_value
|
|
|
|
else
|
|
|
|
echo $option_value
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-12-22 22:50:05 +01:00
|
|
|
get_tmux_window_option() {
|
|
|
|
local option=$1
|
|
|
|
local default_value=$2
|
|
|
|
local option_value=$(tmux show-window-options -v "$option")
|
|
|
|
if [ -z "$option_value" ]; then
|
|
|
|
echo $default_value
|
|
|
|
else
|
|
|
|
echo $option_value
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-07-06 11:21:21 +02:00
|
|
|
# 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 ""
|
|
|
|
}
|
|
|
|
|