utils upgrade
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
process_list="$(ps -eo 'pid command')"
|
||||
if [[ $# != 0 ]]; then
|
||||
process_list="$(echo "$process_list" | grep -Fiw "$@")"
|
||||
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [-h] [filter]
|
||||
|
||||
Display running processes.
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
|
||||
Arguments:
|
||||
filter Optional filter string to match processes
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "$process_list" |
|
||||
grep -Fv "${BASH_SOURCE[0]}" |
|
||||
grep -Fv grep |
|
||||
GREP_COLORS='mt=00;35' grep -E --colour=auto '^\s*[[:digit:]]+'
|
||||
if [[ $# == 0 ]]; then
|
||||
process_list="$(ps -eo 'pid command')"
|
||||
else
|
||||
process_list="$(echo "$process_list" | grep -Fiw "$@")"
|
||||
fi
|
||||
|
||||
echo "$process_list" \
|
||||
| grep -Fv "${BASH_SOURCE[0]}" \
|
||||
| grep -Fv grep \
|
||||
| GREP_COLORS='mt=00;35' grep -E --colour=auto '^\s*[[:digit:]]+'
|
||||
|
||||
Reference in New Issue
Block a user