diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f737f5..6859606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - plugin now uses strategies when fetching pane full command. Implemented 'default' strategy. - save command strategy: 'pgrep'. It's here only if fallback is needed. +- save command strategy: 'gdb' ### v1.3.0, 2014-09-20 - remove dependency on `pgrep` command. Use `ps` for fetching process names. diff --git a/save_command_strategies/gdb.sh b/save_command_strategies/gdb.sh new file mode 100755 index 0000000..2f0ab56 --- /dev/null +++ b/save_command_strategies/gdb.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +PANE_PID="$1" + +exit_safely_if_empty_ppid() { + if [ -z "$PANE_PID" ]; then + exit 0 + fi +} + +full_command() { + gdb -batch --eval "attach $PANE_PID" --eval "call write_history(\"/tmp/bash_history-${PANE_PID}.txt\")" --eval 'detach' --eval 'q' >/dev/null 2>&1 + \tail -1 "/tmp/bash_history-${PANE_PID}.txt" +} + +main() { + exit_safely_if_empty_ppid + full_command +} +main