q.sh/q-run

23 lines
516 B
Text
Raw Permalink Normal View History

#!/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
}
if [[ -z "$@" ]]; then
2024-11-03 01:52:52 +00:00
echo "^run [a-zA-Z0-9_-]*$"
elif [[ "$1" == "--hint" ]]; then
2024-11-03 23:36:22 +00:00
find_all_executables | awk '{print $1 " run " $1}'
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}'
elif [[ "$1" == "--preview" ]]; then
2024-11-03 01:52:52 +00:00
shift
echo "Will run $1"
elif [[ "$1" == "--run" ]]; then
2024-11-03 01:52:52 +00:00
shift
setsid -f "$2"
fi