dotnix @main -
refs -
log -
-
https://git.jolheiser.com/dotnix.git
Signature
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY
oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5
AAAAQIZFDQ5tYgRB7Y84gFnjM0fKX/5Ilu6hK+LfKc6d35fqElj9GsXA5K49P3QA5USJ8E
nBfLO7goAT6LMeCCOASAE=
-----END SSH SIGNATURE-----
diff --git a/apps/nogui/nushell.nix b/apps/nogui/nushell.nix
index d13c1a9769b935a56309a017c20ad67be8ec4409..b9fcbce5485cf63bb62d439c4cc547cdf44b00ff 100644
--- a/apps/nogui/nushell.nix
+++ b/apps/nogui/nushell.nix
@@ -34,6 +34,8 @@ xdg.configFile = {
"nushell/jolheiser.nu".source = ./nushell/jolheiser.nu;
"nushell/ssh.nu".source = ./nushell/ssh.nu;
programs.nushell = {
+ shellAliases = {
+ programs.nushell = {
configFile.source = ./nushell/config.nu;
};
}
diff --git a/apps/nogui/nushell/jolheiser.nu b/apps/nogui/nushell/jolheiser.nu
index 6cc998de81d9e1f58d698af93d8b6d90839ec825..121628560c3dd6a0a10fedf555f773c5ac638e2c 100644
--- a/apps/nogui/nushell/jolheiser.nu
+++ b/apps/nogui/nushell/jolheiser.nu
@@ -102,3 +102,4 @@ $env.EDITOR = 'hx'
$env.SSH_AUTH_SOCK = '/run/user/1000/ssh-agent'
source ~/.config/nushell/ohmyposh.nu
source ~/.config/nushell/ssh.nu
+source ~/.config/nushell/miniserve.nu
diff --git a/apps/nogui/nushell/miniserve.nu b/apps/nogui/nushell/miniserve.nu
new file mode 100644
index 0000000000000000000000000000000000000000..5418c40d2f230ad245734dca5d12341f4efeeff7
--- /dev/null
+++ b/apps/nogui/nushell/miniserve.nu
@@ -0,0 +1,38 @@
+export def serve [
+ path: path # The path to serve
+ --dir (-d): string # The base dir in miniserve for the path
+ --public (-p) # Send to http://pubserve (via http://privserve) rather than http://files
+ --verbose (-v) # Print uploads
+] {
+ let endpoint = if $public { "http://privserve" } else { "http://files" }
+ let url = if $public { "http://pubserve.serval-vibes.ts.net" } else { "http://files" }
+ let upload = $"($endpoint)/upload"
+ let baseName = $path | path basename
+ let cleanDir = if $dir != null { $"($dir | str trim --char '/')" } else { "" }
+ # When uploading, "" is invalid. It must either be "/" or relative "foo/bar/"
+ let uploadDir = $"($cleanDir)/"
+ let serveDir = if $cleanDir != "" { $uploadDir } else { "" }
+ if ($path | path type) == "dir" {
+ let prefix = $path | path expand
+ let baseDir = [$cleanDir, ($prefix | path basename | str trim --char '/')] | path join
+ glob -F $"($prefix)/**" | each {|g|
+ let b = $g | str replace $prefix "" | str trim --left --char '/'
+ let d = [$baseDir, $b] | path join
+ if $verbose { print $"Creating dir ($d)" }
+ ^curl -F $"mkdir=($d)" $"($upload)?path=/" | complete
+ }
+ glob -D $"($prefix)/**" | each {|g|
+ let f = $g | str replace $prefix "" | str trim --left --char '/'
+ let t = [$baseDir, $f] | path join
+ let p = $t | path dirname
+ if $verbose { print $"Uploading ($g) to ($t)" }
+ ^curl -F $"path=@($g)" $"($upload)?path=($p)" | complete
+ }
+ } else {
+ if $verbose { print $"Creating dir ($uploadDir)" }
+ ^curl -F $"mkdir=($uploadDir)" $"($upload)?path=/" | complete
+ if $verbose { print $"Uploading ($path | path expand) to ($serveDir)($baseName)" }
+ ^curl -F $"path=@($path)" $"($upload)?path=($uploadDir)" | complete
+ }
+ $"($url)/($serveDir)($baseName)"
+}