Gen 423: Converted shell scripts into nix files

This commit is contained in:
pagedMov
2024-10-12 17:17:10 -04:00
parent a3614a0dc7
commit 07b2f5cab9
63 changed files with 252 additions and 500 deletions

View File

@@ -0,0 +1,22 @@
{ pkgs }:
{
runbg = pkgs.writeShellScriptBin "runbg" (''
#!/usr/bin/env bash
[ $# -eq 0 ] && { # $# is number of args
echo "$(basename $0): missing command" >&2
exit 1
}
prog="$(which "$1")" # see below
[ -z "$prog" ] && {
echo "$(basename $0): unknown command: $1" >&2
exit 1
}
shift # remove $1, now $prog, from args
tty -s && exec </dev/null # if stdin is a terminal, redirect from null
tty -s <&1 && exec >/dev/null # if stdout is a terminal, redirect to null
tty -s <&2 && exec 2>&1 # stderr to stdout (which might not be null)
"$prog" "$@" & # $@ is all args
'');
}