From 841ac41e3688f24755dc72bb0b579b716c998f18 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Wed, 22 Feb 2023 21:14:10 -0800 Subject: [PATCH] [tools] Rearrange qemu tmux windows on smaller displays So I can still use ./qemu.sh --debug on my laptop. --- qemu.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/qemu.sh b/qemu.sh index 1b9de65..739b923 100755 --- a/qemu.sh +++ b/qemu.sh @@ -72,11 +72,28 @@ if ! ninja -C "${build}"; then fi if [[ -n $TMUX ]]; then + cols=$(tput cols) + if [[ -n $debug ]]; then - tmux split-window -h -l 270 "sleep 1; nc -t localhost 45455 | tee debugcon.log" - tmux split-window -h -l 160 "gdb ${debugtarget}" - tmux select-pane -t .left - tmux select-pane -t .right + log_width=100 + gdb_width=$(($cols - 2 * $log_width)) + + debugcon_cmd="sleep 1; nc -t localhost 45455 | tee debugcon.log" + + if (($gdb_width < 150)); then + stack=1 + gdb_width=$(($cols - $log_width)) + tmux split-window -h -l $gdb_width "gdb ${debugtarget}" + tmux select-pane -t .left + tmux split-window -v "$debugcon_cmd" + tmux select-pane -t .right + else + tmux split-window -h -l $(($log_width + $gdb_width)) "$debugcon_cmd" + tmux split-window -h -l $gdb_width "gdb ${debugtarget}" + tmux select-pane -t .left + tmux select-pane -t .right + fi + else tmux split-window -h -l 100 "sleep 1; telnet localhost 45455" tmux last-pane