Run programs with "setsid"
This commit is contained in:
parent
e1b69b417b
commit
34d17d1e99
1 changed files with 11 additions and 12 deletions
23
q-run
23
q-run
|
@ -5,23 +5,22 @@ ENV_sort=sort
|
||||||
ENV_uniq=uniq
|
ENV_uniq=uniq
|
||||||
|
|
||||||
find_all_executables() {
|
find_all_executables() {
|
||||||
{
|
{
|
||||||
IFS=:; for d in $PATH; do for f in $d/*; do [ -f $f ] && [ -x $f ] && echo ${f##*/}; done; done;
|
IFS=:; for d in $PATH; do for f in $d/*; do [ -f $f ] && [ -x $f ] && echo ${f##*/}; done; done;
|
||||||
} | $ENV_sort | $ENV_uniq
|
} | $ENV_sort | $ENV_uniq
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -z "$@" ]]; then
|
if [[ -z "$@" ]]; then
|
||||||
echo "^run [a-zA-Z0-9_-]*$"
|
echo "^run [a-zA-Z0-9_-]*$"
|
||||||
elif [[ "$1" == "--hint" ]]; then
|
elif [[ "$1" == "--hint" ]]; then
|
||||||
find_all_executables | $ENV_awk '{print $1 " run " $1}'
|
find_all_executables | $ENV_awk '{print $1 " run " $1}'
|
||||||
elif [[ "$1" == "--complete" ]]; then
|
elif [[ "$1" == "--complete" ]]; then
|
||||||
shift
|
shift
|
||||||
find_all_executables | $ENV_awk '{print $1 " run " $1}'
|
find_all_executables | $ENV_awk '{print $1 " run " $1}'
|
||||||
elif [[ "$1" == "--preview" ]]; then
|
elif [[ "$1" == "--preview" ]]; then
|
||||||
shift
|
shift
|
||||||
echo "Will run $1"
|
echo "Will run $1"
|
||||||
elif [[ "$1" == "--run" ]]; then
|
elif [[ "$1" == "--run" ]]; then
|
||||||
shift
|
shift
|
||||||
(nohup "$1" 2>/dev/null &)
|
setsid "$1"
|
||||||
sleep 0.01
|
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue