From 8fd38588c0bddd83de5cc190dc8fafd558098075 Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Mon, 29 Sep 2014 13:39:41 +0200 Subject: [PATCH] Fix ps command flags for FreeBSD This was reported by @duck in #45 --- CHANGELOG.md | 2 ++ save_command_strategies/ps.sh | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 874e713..6333b85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ - save command strategy: 'gdb' - rename default strategy name to 'ps' - create `expect` script that can fully restore tmux environment +- fix default save command strategy `ps` command flags. Flags are different for + FreeBSD. ### v1.3.0, 2014-09-20 - remove dependency on `pgrep` command. Use `ps` for fetching process names. diff --git a/save_command_strategies/ps.sh b/save_command_strategies/ps.sh index 8544add..626cf6f 100755 --- a/save_command_strategies/ps.sh +++ b/save_command_strategies/ps.sh @@ -10,8 +10,15 @@ exit_safely_if_empty_ppid() { fi } +ps_command_flags() { + case $(uname -s) in + FreeBSD) echo "-ao" ;; + *) echo "-eo" ;; + esac +} + full_command() { - ps -eo "ppid command" | + ps "$(ps_command_flags)" "ppid command" | sed "s/^ *//" | grep "^${PANE_PID}" | cut -d' ' -f2-