1
0

feat: initial commit; NixOS Era

This commit is contained in:
2025-11-20 22:13:05 +01:00
commit 8d0bddf680
46 changed files with 2044 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
function clip
if not command -q xclip
echoerr "clip: 'xclip' is not available on this system"
return 1
end
if not tty -s
set -l stdin
read stdin -z
end
if set -ql stdin
echo "$stdin" | xclip -selection clipboard
echo "copied into clipboard (stdin)"
return 0
end
if [ -n "$(string trim -- $argv)" ]
echo "$argv" | xclip -selection clipboard
echo "copied into clipboard"
return 0
end
xclip -selection clipboard -o
end
+3
View File
@@ -0,0 +1,3 @@
function echoerr
echo $argv >&2
end
+45
View File
@@ -0,0 +1,45 @@
function nix-shell
set -l _argv (string split ' ' -- $argv);
if contains -- '-q' $_argv; or contains -- '--query' $_argv
for pkg in (string split ' ' -- $FISH_NIX_PACKAGES)
echo $pkg
end
return 0;
end
function package_flag -a arg
contains -- '-p' $arg
or contains -- '--packages' $arg
end
if not command -q nix-shell; or not package_flag $argv
command nix-shell --run fish $argv;
return $status;
end
set -l packages
set -l reading_packages 0
for arg in $_argv
if [ $reading_packages -ne 0 ]
if string match -r '^-'
set reading_packages 0
else
not contains -- $arg (string split ' ' -- $FISH_NIX_PACKAGES);
and set packages $packages $arg
end
else
package_flag $arg; and set reading_packages 1
end
end
set -l prev_packages $FISH_NIX_PACKAGES;
set -x FISH_NIX_PACKAGES $prev_packages $packages;
command nix-shell --run fish $argv;
set -l nix_status $status;
set -x FISH_NIX_PACKAGES $prev_packages;
return $nix_status
end
+12
View File
@@ -0,0 +1,12 @@
function nix-shell
if not command -q nix-shell
command nix-shell;
return $status;
end
set -l _argv $argv
argparse -i 'p/packages=' -- $argv
or command nix-shell -- $_argv
set -x FISH_NIX_PACKAGES
end
+18
View File
@@ -0,0 +1,18 @@
function round
argparse -n 'round' -i 'p/precision=!_validate_int' -- $argv
or return 1;
set -l value (string trim -- $argv)
if [ -z $value ]
echoerr 'round: no input'
return 1
end
set -l precision 1
if set -q _flag_precision
set precision (math "10 ^ $_flag_precision")
end
set value (math "$value * $precision")
echo (math "round($value) / $precision")
end