From 19831aa6a002a8c981564b52ffaa94218993385c Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Wed, 6 Mar 2019 19:14:56 +0000 Subject: Retain active pane on rolodex switch --- scripts/rolodex.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/rolodex.sh b/scripts/rolodex.sh index 56010a2..ddc6ba0 100755 --- a/scripts/rolodex.sh +++ b/scripts/rolodex.sh @@ -31,6 +31,10 @@ get_number_of_active_window_panes() { echo $(tmux lsp | wc -l) } +get_active_pane(){ + echo $(tmux lsp | grep '(active)' | cut -c 1) +} + get_number_of_buffer_window_panes() { echo $(tmux lsp -t 2 | wc -l) } @@ -52,6 +56,7 @@ main() { ACTION="${ARGS[0]}" fi + ACTIVE_PANE=$(get_active_pane) if [[ "$ACTION" == 'prev' ]]; then open_drawer_if_unopen tmux swap-pane -s 1.2 -t 2."$BUFFER_COUNT" @@ -60,7 +65,7 @@ main() { NEXT=$((i + 1)) tmux swap-pane -s 2."$i" -t 2."$NEXT" done - tmux select-pane -t 1.1 + tmux select-pane -t 1."$ACTIVE_PANE" elif [[ "$ACTION" == 'next' ]]; then open_drawer_if_unopen tmux swap-pane -s 1.2 -t 2.1 @@ -69,7 +74,7 @@ main() { NEXT=$((i + 1)) tmux swap-pane -s 2."$i" -t 2."$NEXT" done - tmux select-pane -t 1.1 + tmux select-pane -t 1."$ACTIVE_PANE" else echo "Command not recognized: $ACTION" fi -- cgit v1.2.3