2023-05-14 17:24:43 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
find_all_executables() {
|
2024-11-03 01:52:52 +00:00
|
|
|
{
|
|
|
|
IFS=:; for d in $PATH; do for f in $d/*; do [ -f $f ] && [ -x $f ] && echo ${f##*/}; done; done;
|
2024-11-03 23:36:22 +00:00
|
|
|
} | sort | uniq
|
2023-05-14 17:24:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ -z "$@" ]]; then
|
2024-11-03 01:52:52 +00:00
|
|
|
echo "^run [a-zA-Z0-9_-]*$"
|
2023-05-14 17:24:43 +00:00
|
|
|
elif [[ "$1" == "--hint" ]]; then
|
2024-11-03 23:36:22 +00:00
|
|
|
find_all_executables | awk '{print $1 " run " $1}'
|
2023-05-14 17:24:43 +00:00
|
|
|
elif [[ "$1" == "--complete" ]]; then
|
2024-11-03 01:52:52 +00:00
|
|
|
shift
|
2024-11-03 23:36:22 +00:00
|
|
|
find_all_executables | awk '{print $1 " run " $1}'
|
2023-05-14 17:24:43 +00:00
|
|
|
elif [[ "$1" == "--preview" ]]; then
|
2024-11-03 01:52:52 +00:00
|
|
|
shift
|
|
|
|
echo "Will run $1"
|
2023-05-14 17:24:43 +00:00
|
|
|
elif [[ "$1" == "--run" ]]; then
|
2024-11-03 01:52:52 +00:00
|
|
|
shift
|
2024-11-20 07:08:16 +00:00
|
|
|
setsid -f "$2"
|
2023-05-14 17:24:43 +00:00
|
|
|
fi
|