2023-05-14 17:24:43 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-05-14 19:24:27 +00:00
|
|
|
ENV_awk=awk
|
|
|
|
ENV_sort=sort
|
|
|
|
ENV_uniq=uniq
|
2023-05-14 17:24:43 +00:00
|
|
|
|
|
|
|
find_all_executables() {
|
|
|
|
{
|
|
|
|
IFS=:; for d in $PATH; do for f in $d/*; do [ -f $f ] && [ -x $f ] && echo ${f##*/}; done; done;
|
2023-05-14 19:24:27 +00:00
|
|
|
} | $ENV_sort | $ENV_uniq
|
2023-05-14 17:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ -z "$@" ]]; then
|
|
|
|
echo "^run [a-zA-Z0-9_-]*$"
|
|
|
|
elif [[ "$1" == "--hint" ]]; then
|
2023-05-14 19:24:27 +00:00
|
|
|
find_all_executables | $ENV_awk '{print $1 " run " $1}'
|
2023-05-14 17:24:43 +00:00
|
|
|
elif [[ "$1" == "--complete" ]]; then
|
|
|
|
shift
|
2023-05-14 19:24:27 +00:00
|
|
|
find_all_executables | $ENV_awk '{print $1 " run " $1}'
|
2023-05-14 17:24:43 +00:00
|
|
|
elif [[ "$1" == "--preview" ]]; then
|
|
|
|
shift
|
|
|
|
echo "Will run $1"
|
|
|
|
elif [[ "$1" == "--run" ]]; then
|
|
|
|
shift
|
|
|
|
(nohup "$1" 2>/dev/null &)
|
|
|
|
sleep 0.01
|
|
|
|
fi
|