2014-09-20 21:47:15 +00:00
|
|
|
#!/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
|
|
|
|
}
|
|
|
|
|
2014-09-29 11:39:41 +00:00
|
|
|
ps_command_flags() {
|
|
|
|
case $(uname -s) in
|
|
|
|
FreeBSD) echo "-ao" ;;
|
2015-01-15 22:20:29 +00:00
|
|
|
OpenBSD) echo "-ao" ;;
|
2014-09-29 11:39:41 +00:00
|
|
|
*) echo "-eo" ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2014-09-20 21:47:15 +00:00
|
|
|
full_command() {
|
2014-09-29 11:39:41 +00:00
|
|
|
ps "$(ps_command_flags)" "ppid command" |
|
2014-09-20 21:47:15 +00:00
|
|
|
sed "s/^ *//" |
|
|
|
|
grep "^${PANE_PID}" |
|
|
|
|
cut -d' ' -f2-
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
exit_safely_if_empty_ppid
|
|
|
|
full_command
|
|
|
|
}
|
|
|
|
main
|