#!/bin/sh

[ -z "$TMUX" ] && echo "Not in tmux!" && exit 1

if [ $(tmux list-panes | wc -l) = 1 ]; then
    tmux split-window -h
else
    tmux select-pane -l
fi
other_tty=$(tty)
tmux select-pane -l

echo "gdb -q -ex \"tty $other_tty\" \"$@\""
exec gdb -q -ex "tty $other_tty" "$@"
