Usability update to stuff

This commit is contained in:
Natsu Kagami 2022-11-01 11:38:34 +01:00
parent 1b39ae8f40
commit b98e7ab879
Signed by: nki
GPG key ID: 7306B3D3C3AD6E51
2 changed files with 45 additions and 2 deletions

View file

@ -12,8 +12,49 @@
package = pkgs.unstable.fish;
functions = {
# Simplify nix usage!
nx = "test (count $argv) -gt 0 && nix run nixpkgs#$argv[1] -- $argv[2..]";
nsh = "test (count $argv) -gt 0 && nix shell nixpkgs#$argv -c fish";
nx = {
body = ''
set impure
if test $argv[1] = "--impure"
set impure "--impure"
set argv $argv[2..]
end
if test (count $argv) -gt 0
nix run $impure nixpkgs#$argv[1] -- $argv[2..]
else
echo "nx [--impure] {package} [args...]"
exit 1
end
'';
wraps = "nix run";
description = "Runs an app from the nixpkgs store.";
};
nsh = {
description = "Spawns a shell from the given nixpkgs packages";
wraps = "nix shell";
body = ''
set impure
if test $argv[1] = "--impure"
set impure "--impure"
set argv $argv[2..]
end
if test (count $argv) -gt 0
set minusc (contains -i -- "-c" $argv)
if test -z $minusc
nix shell $impure nixpkgs#$argv -c fish
else if test $minusc -eq (count $argv)
echo "nsh [--impure] {packages} [-c command args...]"
return 1
else
nix shell $impure nixpkgs#$argv[..(math $minusc - 1)] $argv[$minusc..]
end
else
echo "nsh [--impure] {packages} [-c command args...]"
return 1
end
'';
};
# Grep stuff
eg = {
body = ''

View file

@ -297,6 +297,8 @@ in
"(.*) Mozilla Firefox" = "🌎 $1";
"(.*) - Kakoune" = "$1";
"(.*) - fish" = ">_ $1";
"(.*) - Discord" = "🗨 $1";
# ArmCord thing
" Discord \\| (.*)" = "🗨 $1";
"\\((\\d+)\\) Discord \\| (.*)" = "🗨 [$1] $2";
};