aboutsummaryrefslogtreecommitdiffstats
path: root/toggle-term.sh
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2025-08-16 16:44:10 -0400
committerEugene Triguba <hello@eugenetriguba.com>2025-08-16 16:44:10 -0400
commit8844ee60bbeafe1ccf89a83370121f33f26bcb18 (patch)
treeb9686b4263932322c72e55b9be73654308ea8c82 /toggle-term.sh
parentComment out active pane assertion (diff)
downloadtmux-toggle-term-8844ee60bbeafe1ccf89a83370121f33f26bcb18.zip
Fix bug with assuming first pane is at index 1
Diffstat (limited to 'toggle-term.sh')
-rwxr-xr-xtoggle-term.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/toggle-term.sh b/toggle-term.sh
index ace5978..d19fd70 100755
--- a/toggle-term.sh
+++ b/toggle-term.sh
@@ -8,7 +8,11 @@ POPUP_SESSION_NAME="popup"
main() {
if [ -n "${TMUX_SOCKET:-}" ]; then
- TMUX_CMD="tmux -L $TMUX_SOCKET"
+ if [ -n "${TMUX_CONFIG_PATH:-}" ]; then
+ TMUX_CMD="tmux -f $TMUX_CONFIG_PATH -L $TMUX_SOCKET"
+ else
+ TMUX_CMD="tmux -L $TMUX_SOCKET"
+ fi
fi
mode="$1"
@@ -89,7 +93,8 @@ toggle_split() {
#
# To simulate 'toggling' between the main pane and the split
# pane, we 'zoom' the main pane so it takes up the full screen.
- $TMUX_CMD resize-pane -Z -t1
+ first_pane_index="$($TMUX_CMD list-panes -F '#{pane_index}' | head -n1)"
+ $TMUX_CMD resize-pane -Z -t"$first_pane_index"
}
main "$@"