From 7bc20823de7d7cb528c08b966c7e419a9fd29761 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Fri, 12 Apr 2024 20:57:55 +0100 Subject: [PATCH] Add meta window layout that automatically chooses split --- layouts/window-auto | 28 ++++++++++++++++++++++++++++ tasks.yaml | 1 + 2 files changed, 29 insertions(+) create mode 100755 layouts/window-auto diff --git a/layouts/window-auto b/layouts/window-auto new file mode 100755 index 0000000..f2f955e --- /dev/null +++ b/layouts/window-auto @@ -0,0 +1,28 @@ +#!/usr/bin/env zsh + +cols=`tput cols` +lines=`tput lines` +width=$(( $cols / 2 )).0 +height=$lines.0 +ratio=$(( ($width / $height) * 100 )) + +# echo "size: ( $width,$height ) ratio: $ratio" + +if [[ $cols -lt 140 ]] && [[ $lines -lt 70 ]]; then + # terminal is too small + exit +fi + +if [[ $ratio -ge 100 ]]; then + # terminal is wide or square + if [[ `tput cols` -gt 230 ]]; then + # terminal is wide and large + `dirname $0`/window-wide-right + else + # terminal is wide and small + tmux split-window -h -l 50% + fi +else + # terminal is tall + `dirname $0`/window-tall +fi diff --git a/tasks.yaml b/tasks.yaml index 4b1f76e..56c3afa 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -19,6 +19,7 @@ - session-local - session-main - session-visor + - window-auto - window-tall - window-wide-left - window-wide-right