From 8d44f5ced6e678ad61f8d2586f9430b84237431c Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Tue, 29 Mar 2022 13:20:56 +0530 Subject: [PATCH] fish: functions/gdbt: Spawning GDB with tmux panes Adapted from https://github.com/cyrus-and/gdb-dashboard/issues/63. --- fish/.config/fish/functions/gdbt.fish | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 fish/.config/fish/functions/gdbt.fish diff --git a/fish/.config/fish/functions/gdbt.fish b/fish/.config/fish/functions/gdbt.fish new file mode 100644 index 0000000..e94fd3a --- /dev/null +++ b/fish/.config/fish/functions/gdbt.fish @@ -0,0 +1,24 @@ +function gdbt -d "GDB with tmux panes" + if set -q TMUX + set proc (ps -ef | fzf | awk '{print $2}') + + if test -n "$proc" + set -l tty1_id (tmux split-pane -hPF "#D" "tail -f /dev/null") + tmux last-pane + set -l tty1 (tmux display-message -p -t "$tty1_id" '#{pane_tty}') + + set -l tty2_id (tmux split-pane -hPF "#D" "tail -f /dev/null") + tmux last-pane + set -l tty2 (tmux display-message -p -t "$tty2_id" '#{pane_tty}') + + tmux select-layout even-horizontal + + gdb -q -ex "dashboard breakpoints -output $tty1" -ex "dashboard variables -output $tty1" -ex "dashboard threads -output $tty2" -ex "attach $proc" + + tmux kill-pane -t $tty1_id + tmux kill-pane -t $tty2_id + end + else + echo "Not inside TMUX" + end +end