tmux2k/scripts/utils.sh

23 lines
564 B
Bash
Raw Normal View History

2022-08-09 06:28:34 +05:30
#!/usr/bin/env bash
get_tmux_option() {
2023-03-29 14:52:27 +05:30
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
2022-08-09 06:28:34 +05:30
}
2024-03-17 04:00:27 +05:30
normalize_padding() {
2023-03-29 14:52:27 +05:30
percent_len=${#1}
2024-03-27 09:27:18 +05:30
max_len=${2:-5}
2023-03-29 14:52:27 +05:30
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 ""
2022-08-09 06:28:34 +05:30
}