diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b7d126..9f737f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### master - plugin now uses strategies when fetching pane full command. Implemented 'default' strategy. +- save command strategy: 'pgrep'. It's here only if fallback is needed. ### v1.3.0, 2014-09-20 - remove dependency on `pgrep` command. Use `ps` for fetching process names. diff --git a/save_command_strategies/pgrep.sh b/save_command_strategies/pgrep.sh new file mode 100755 index 0000000..15d98b3 --- /dev/null +++ b/save_command_strategies/pgrep.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() { + \pgrep -lf -P "$PANE_PID" | + cut -d' ' -f2- +} + +main() { + exit_safely_if_empty_ppid + full_command +} +main