From a532a6fb2804c184feffb4bda269a952d7c7a86a Mon Sep 17 00:00:00 2001 From: Andreas P Date: Sun, 2 Apr 2023 10:29:37 +0200 Subject: [PATCH 01/10] optimize xpns_organize_panes --- bin/xpanes | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/xpanes b/bin/xpanes index 17bc684..bb3f24c 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -774,20 +774,19 @@ xpns_organize_panes() { local _window_name="$1" shift local _args_num="$1" - ## ---------------- + # Default behavior - ## ---------------- - if [[ "${_args_num}" -eq 1 ]]; then - ${TMUX_XPANES_EXEC} select-layout -t "${_window_name}" even-horizontal - elif [[ "${_args_num}" -gt 1 ]]; then - ${TMUX_XPANES_EXEC} select-layout -t "${_window_name}" tiled + local layout_command="select-layout -t ${_window_name} even-horizontal" + if (( _args_num > 1 )); then + layout_command="select-layout -t ${_window_name} tiled" fi - ## ---------------- + # Update layout - ## ---------------- if [[ "${XP_LAYOUT}" != "${XP_DEFAULT_LAYOUT}" ]]; then - ${TMUX_XPANES_EXEC} select-layout -t "${_window_name}" "${XP_LAYOUT}" + layout_command="select-layout -t ${_window_name} ${XP_LAYOUT}" fi + + ${TMUX_XPANES_EXEC} $layout_command } # From d0891e33190fc65a1e247f5d411ddd33d9d52695 Mon Sep 17 00:00:00 2001 From: Andreas P Date: Sun, 2 Apr 2023 10:41:49 +0200 Subject: [PATCH 02/10] Fix linting --- bin/xpanes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/xpanes b/bin/xpanes index bb3f24c..357ddb1 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -786,7 +786,7 @@ xpns_organize_panes() { layout_command="select-layout -t ${_window_name} ${XP_LAYOUT}" fi - ${TMUX_XPANES_EXEC} $layout_command + ${TMUX_XPANES_EXEC} "$layout_command" } # From de3116a7d09274608e80c38a3c5e9fa9eed112a8 Mon Sep 17 00:00:00 2001 From: Andreas P Date: Sun, 2 Apr 2023 12:51:06 +0200 Subject: [PATCH 03/10] lets go back to regular operator --- bin/xpanes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/xpanes b/bin/xpanes index 357ddb1..fa820f0 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -777,10 +777,10 @@ xpns_organize_panes() { # Default behavior local layout_command="select-layout -t ${_window_name} even-horizontal" - if (( _args_num > 1 )); then + if [[ "${_args_num}" -gt 1 ]]; then layout_command="select-layout -t ${_window_name} tiled" fi - +s # Update layout if [[ "${XP_LAYOUT}" != "${XP_DEFAULT_LAYOUT}" ]]; then layout_command="select-layout -t ${_window_name} ${XP_LAYOUT}" From ffffe66d2680fef4baed091e3db4ad62d547468a Mon Sep 17 00:00:00 2001 From: Andreas P Date: Wed, 5 Apr 2023 16:51:23 +0200 Subject: [PATCH 04/10] add space to variable --- bin/xpanes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/xpanes b/bin/xpanes index fa820f0..da07684 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -783,7 +783,7 @@ xpns_organize_panes() { s # Update layout if [[ "${XP_LAYOUT}" != "${XP_DEFAULT_LAYOUT}" ]]; then - layout_command="select-layout -t ${_window_name} ${XP_LAYOUT}" + layout_command=" select-layout -t ${_window_name} ${XP_LAYOUT}" fi ${TMUX_XPANES_EXEC} "$layout_command" From 37ca833be57fe2f9862d3a2c4cb6eb47ebe80edd Mon Sep 17 00:00:00 2001 From: Andreas P Date: Wed, 5 Apr 2023 20:27:03 +0200 Subject: [PATCH 05/10] remove typo from xpanes script --- bin/xpanes | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/xpanes b/bin/xpanes index da07684..94c9677 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -561,7 +561,7 @@ xpns_arr2args() { if [[ $# -lt 1 ]]; then return 0 fi -for _arg in "$@"; do + for _arg in "$@"; do # Use 'cat <<<"input"' command instead of 'echo', # because such the command recognizes option like '-e'. cat <<< "${_arg}" | @@ -780,7 +780,6 @@ xpns_organize_panes() { if [[ "${_args_num}" -gt 1 ]]; then layout_command="select-layout -t ${_window_name} tiled" fi -s # Update layout if [[ "${XP_LAYOUT}" != "${XP_DEFAULT_LAYOUT}" ]]; then layout_command=" select-layout -t ${_window_name} ${XP_LAYOUT}" From 817d18be0e234c0cc681ea80888a211e1f3399d6 Mon Sep 17 00:00:00 2001 From: Andreas P Date: Wed, 5 Apr 2023 22:56:37 +0200 Subject: [PATCH 06/10] remove " from layout command --- bin/xpanes | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/xpanes b/bin/xpanes index 7a7414d..a0a697e 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -777,16 +777,16 @@ xpns_organize_panes() { local _args_num="$1" # Default behavior - local layout_command="select-layout -t ${_window_name} even-horizontal" + local layout_command=" select-layout -t ${_window_name} even-horizontal" if [[ "${_args_num}" -gt 1 ]]; then - layout_command="select-layout -t ${_window_name} tiled" + layout_command=" select-layout -t ${_window_name} tiled" fi # Update layout if [[ "${XP_LAYOUT}" != "${XP_DEFAULT_LAYOUT}" ]]; then layout_command=" select-layout -t ${_window_name} ${XP_LAYOUT}" fi - ${TMUX_XPANES_EXEC} "$layout_command" + ${TMUX_XPANES_EXEC} $layout_command } # From f7ace832427d39bd6627cbcf7f3e387e3b0b5f79 Mon Sep 17 00:00:00 2001 From: Andreas P Date: Wed, 5 Apr 2023 23:07:32 +0200 Subject: [PATCH 07/10] apply shellcheck disable --- bin/xpanes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/xpanes b/bin/xpanes index a0a697e..725803f 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -785,7 +785,7 @@ xpns_organize_panes() { if [[ "${XP_LAYOUT}" != "${XP_DEFAULT_LAYOUT}" ]]; then layout_command=" select-layout -t ${_window_name} ${XP_LAYOUT}" fi - + # shellcheck disable=SC2086 ${TMUX_XPANES_EXEC} $layout_command } From a8ba07cf075785c0013905af82f9794fb25655de Mon Sep 17 00:00:00 2001 From: Andreas P Date: Wed, 5 Apr 2023 23:13:25 +0200 Subject: [PATCH 08/10] applying back arithmetic evaluation --- bin/xpanes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/xpanes b/bin/xpanes index 725803f..4721d70 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -778,7 +778,7 @@ xpns_organize_panes() { # Default behavior local layout_command=" select-layout -t ${_window_name} even-horizontal" - if [[ "${_args_num}" -gt 1 ]]; then + if (( _args_num > 1 ));; then layout_command=" select-layout -t ${_window_name} tiled" fi # Update layout From 4e105c5b65a3cfdd0752c8a0739fea35cc7d68cd Mon Sep 17 00:00:00 2001 From: Andreas P Date: Thu, 6 Apr 2023 08:49:31 +0200 Subject: [PATCH 09/10] fix typo --- bin/xpanes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/xpanes b/bin/xpanes index 4721d70..63374f3 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -778,7 +778,7 @@ xpns_organize_panes() { # Default behavior local layout_command=" select-layout -t ${_window_name} even-horizontal" - if (( _args_num > 1 ));; then + if (( _args_num > 1 )); then layout_command=" select-layout -t ${_window_name} tiled" fi # Update layout From d1847b6d783a60548cbc57594c4728122a1dc1d4 Mon Sep 17 00:00:00 2001 From: ReDTerraN Date: Thu, 6 Apr 2023 10:15:52 +0200 Subject: [PATCH 10/10] satisfy shfmt --- bin/xpanes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/xpanes b/bin/xpanes index 63374f3..8a9ef06 100755 --- a/bin/xpanes +++ b/bin/xpanes @@ -778,7 +778,7 @@ xpns_organize_panes() { # Default behavior local layout_command=" select-layout -t ${_window_name} even-horizontal" - if (( _args_num > 1 )); then + if ((_args_num > 1)); then layout_command=" select-layout -t ${_window_name} tiled" fi # Update layout