Implement save command strategy gdb

@danschumann originally came up with this strategy in #44
This commit is contained in:
Bruno Sutic 2014-09-21 00:08:40 +02:00
parent ae9083e695
commit 8ebda79f68
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
2 changed files with 23 additions and 0 deletions

View File

@ -4,6 +4,7 @@
- plugin now uses strategies when fetching pane full command. Implemented - plugin now uses strategies when fetching pane full command. Implemented
'default' strategy. 'default' strategy.
- save command strategy: 'pgrep'. It's here only if fallback is needed. - save command strategy: 'pgrep'. It's here only if fallback is needed.
- save command strategy: 'gdb'
### v1.3.0, 2014-09-20 ### v1.3.0, 2014-09-20
- remove dependency on `pgrep` command. Use `ps` for fetching process names. - remove dependency on `pgrep` command. Use `ps` for fetching process names.

22
save_command_strategies/gdb.sh Executable file
View File

@ -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