From 895dace853fc4c979c8efd17c4206ea19ce837a6 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 18 Feb 2024 00:42:44 +0000 Subject: [PATCH] fix(layout-helpers): split_h/split_v work correctly on latest tmux (#99) The `-p` flag on `split-window` was deprecated in Tmux 3.1 in favor of just adding a `%` suffix to the numeric value given to the `-l` flag. This uses the new `-l %` format on Tmux 3.1 and later, and uses the old `-p ` format on 3.0 and older. --- lib/layout-helpers.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/layout-helpers.sh b/lib/layout-helpers.sh index cf862f9..593e165 100644 --- a/lib/layout-helpers.sh +++ b/lib/layout-helpers.sh @@ -37,7 +37,12 @@ new_window() { # - $2: (optional) Target pane ID to split in current window. # split_v() { - if [ -n "$1" ]; then local percentage=(-p "$1"); fi + if [ "$(tmuxifier-tmux-version "3.0")" == ">" ]; then + # Tmux 3.1 and later. + if [ -n "$1" ]; then local percentage=(-l "$1"'%'); fi + else + if [ -n "$1" ]; then local percentage=(-p "$1"); fi + fi tmuxifier-tmux split-window -t "$session:$window.$2" -v "${percentage[@]}" __go_to_window_or_session_path } @@ -49,7 +54,12 @@ split_v() { # - $2: (optional) Target pane ID to split in current window. # split_h() { - if [ -n "$1" ]; then local percentage=(-p "$1"); fi + if [ "$(tmuxifier-tmux-version "3.0")" == ">" ]; then + # Tmux 3.1 and later. + if [ -n "$1" ]; then local percentage=(-l "$1"'%'); fi + else + if [ -n "$1" ]; then local percentage=(-p "$1"); fi + fi tmuxifier-tmux split-window -t "$session:$window.$2" -h "${percentage[@]}" __go_to_window_or_session_path }