mirror of
https://github.com/Noratrieb/nixos.git
synced 2026-01-14 19:55:08 +01:00
add u, the most awesome program
This commit is contained in:
parent
1235ffe614
commit
dd0b4d1f71
5 changed files with 38 additions and 4 deletions
32
custom-pkgs/u/default.nix
Normal file
32
custom-pkgs/u/default.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{ pkgs, ... }: pkgs.writeShellApplication {
|
||||
name = "u";
|
||||
|
||||
text = ''
|
||||
programs=(cargo git)
|
||||
|
||||
if [ -z "''${1:-}" ]; then
|
||||
echo "u: universial command executor"
|
||||
echo "programs: ''${programs[*]}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
program_to_use=""
|
||||
|
||||
for program in "''${programs[@]}"; do
|
||||
if PAGER=true "$program" "$1" --help >/dev/null 2>/dev/null; then
|
||||
if [ -n "$program_to_use" ]; then
|
||||
echo "u: conflict: $1 is provided by both $program_to_use and $program" >&2
|
||||
exit 1
|
||||
fi
|
||||
program_to_use="$program"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$program_to_use" ]; then
|
||||
exec "$program_to_use" "$@"
|
||||
fi
|
||||
|
||||
echo "error: cannot find program for $1" >&2
|
||||
exit 1
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue