Fix ps command flags for FreeBSD

This was reported by @duck in #45
This commit is contained in:
Bruno Sutic 2014-09-29 13:39:41 +02:00
parent a7fe9dcac3
commit 8fd38588c0
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
2 changed files with 10 additions and 1 deletions

View File

@ -7,6 +7,8 @@
- save command strategy: 'gdb' - save command strategy: 'gdb'
- rename default strategy name to 'ps' - rename default strategy name to 'ps'
- create `expect` script that can fully restore tmux environment - 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 ### 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.

View File

@ -10,8 +10,15 @@ exit_safely_if_empty_ppid() {
fi fi
} }
ps_command_flags() {
case $(uname -s) in
FreeBSD) echo "-ao" ;;
*) echo "-eo" ;;
esac
}
full_command() { full_command() {
ps -eo "ppid command" | ps "$(ps_command_flags)" "ppid command" |
sed "s/^ *//" | sed "s/^ *//" |
grep "^${PANE_PID}" | grep "^${PANE_PID}" |
cut -d' ' -f2- cut -d' ' -f2-