refactor: dry duplicated code for getting tmux status-left

This commit is contained in:
Maciej Sypien 2024-09-22 22:25:56 +02:00
parent 28eed454f7
commit dd1c215631
No known key found for this signature in database
GPG key ID: 10BC01EDA6827DC8
10 changed files with 17 additions and 10 deletions

View file

@ -64,6 +64,13 @@ tmux_set_window_option_now() {
# return the value of status style # return the value of status style
tmux_get_statusstyle() { tmux_get_statusstyle() {
local _val=tmux show-option -gqv status-style local _val
_val=$(tmux show-option -gqv status-style)
echo "$_val"
}
tmux_get_statusleft() {
local _val
_val=$(tmux show-option -gqv status-left)
echo "$_val" echo "$_val"
} }

View file

@ -33,7 +33,7 @@ EOF
# check if left side match # check if left side match
_status_left_expected="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]" _status_left_expected="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left) _status_left_current=$(tmux_get_statusleft)
if [[ "$_status_left_current" != "$_status_left_expected" ]]; then if [[ "$_status_left_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown helper_teardown

View file

@ -34,7 +34,7 @@ EOF
# check if left side match # check if left side match
_status_left_expected="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]" _status_left_expected="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left) _status_left_current=$(tmux_get_statusleft)
if [[ "$_status_left_current" != "$_status_left_expected" ]]; then if [[ "$_status_left_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown helper_teardown

View file

@ -33,7 +33,7 @@ EOF
# check if left side match # check if left side match
_status_left_expected="#[bg=#665c54,fg=#bdae93] #S #[bg=#3c3836,fg=#665c54,nobold,noitalics,nounderscore]" _status_left_expected="#[bg=#665c54,fg=#bdae93] #S #[bg=#3c3836,fg=#665c54,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left) _status_left_current=$(tmux_get_statusleft)
if [[ "$_status_left_current" != "$_status_left_expected" ]]; then if [[ "$_status_left_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown helper_teardown

View file

@ -34,7 +34,7 @@ EOF
# check if left side match # check if left side match
_status_left_expected="#[bg=#665c54,fg=#bdae93] #S #[bg=#3c3836,fg=#665c54,nobold,noitalics,nounderscore]" _status_left_expected="#[bg=#665c54,fg=#bdae93] #S #[bg=#3c3836,fg=#665c54,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left) _status_left_current=$(tmux_get_statusleft)
if [[ "$_status_left_current" != "$_status_left_expected" ]]; then if [[ "$_status_left_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown helper_teardown

View file

@ -33,7 +33,7 @@ EOF
# check if left side match # check if left side match
_status_left_expected="#[bg=colour239,fg=colour223] #S #[bg=colour250,fg=colour239,nobold,noitalics,nounderscore]" _status_left_expected="#[bg=colour239,fg=colour223] #S #[bg=colour250,fg=colour239,nobold,noitalics,nounderscore]"
_status_left_current=$() _status_left_current=$(tmux_get_statusleft)
if [[ "$_status_left_current" != "$_status_left_expected" ]]; then if [[ "$_status_left_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown helper_teardown

View file

@ -34,7 +34,7 @@ EOF
# check if left side match # check if left side match
_status_left_expected="#[bg=colour239,fg=colour223] #S #[bg=colour250,fg=colour239,nobold,noitalics,nounderscore]" _status_left_expected="#[bg=colour239,fg=colour223] #S #[bg=colour250,fg=colour239,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left) _status_left_current=$(tmux_get_statusleft)
if [[ "$_status_left_current" != "$_status_left_expected" ]]; then if [[ "$_status_left_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown helper_teardown

View file

@ -33,7 +33,7 @@ EOF
# check if left side match # check if left side match
_status_left_expected="#[bg=#bdae93,fg=#665c54] #S #[bg=#ebdbb2,fg=#bdae93,nobold,noitalics,nounderscore]" _status_left_expected="#[bg=#bdae93,fg=#665c54] #S #[bg=#ebdbb2,fg=#bdae93,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left) _status_left_current=$(tmux_get_statusleft)
if [[ "$_status_left_current" != "$_status_left_expected" ]]; then if [[ "$_status_left_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown helper_teardown

View file

@ -34,7 +34,7 @@ EOF
# check if left side match # check if left side match
_status_left_expected="#[bg=#bdae93,fg=#665c54] #S #[bg=#ebdbb2,fg=#bdae93,nobold,noitalics,nounderscore]" _status_left_expected="#[bg=#bdae93,fg=#665c54] #S #[bg=#ebdbb2,fg=#bdae93,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left) _status_left_current=$(tmux_get_statusleft)
if [[ "$_status_left_current" != "$_status_left_expected" ]]; then if [[ "$_status_left_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown helper_teardown

View file

@ -36,7 +36,7 @@ EOF
# check if left side match # check if left side match
_status_left_expected="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]" _status_left_expected="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left) _status_left_current=$(tmux_get_statusleft)
if [[ "$_status_left_current" != "$_status_left_expected" ]]; then if [[ "$_status_left_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown helper_teardown