fish: add 'proj init' helper wrapping the flake template
2 files changed,  +43, -0
M README.md
+17, -0
 1@@ -62,6 +62,23 @@ nix flake init -t git+https://git.kilimanjaro.io/devkit
 2 
 3 (Local clone: `nix flake init -t path:/home/btburke/projects/devkit`.)
 4 
 5+## Fish shell helper
 6+
 7+`fish/functions/proj.fish` defines a `proj` function wrapping the scaffold:
 8+
 9+```sh
10+proj init            # scaffold in the current directory
11+proj init newthing   # mkdir, cd, then scaffold
12+```
13+
14+Install by symlinking into fish's autoload directory (or wire it into your
15+dotfiles):
16+
17+```sh
18+mkdir -p ~/.config/fish/functions
19+ln -sf ~/projects/devkit/fish/functions/proj.fish ~/.config/fish/functions/proj.fish
20+```
21+
22 ## Gotchas
23 
24 - Not for the tool repos themselves (`bug`, `secrets`, `local-code-review`):
A fish/functions/proj.fish
+26, -0
 1@@ -0,0 +1,26 @@
 2+function proj --description 'Personal project helpers (devkit scaffold)'
 3+    set -l template git+https://git.kilimanjaro.io/devkit
 4+
 5+    if test (count $argv) -eq 0
 6+        echo "usage: proj init [DIR]" >&2
 7+        return 2
 8+    end
 9+
10+    switch $argv[1]
11+        case init
12+            # Optional DIR: create it and cd in before scaffolding.
13+            if set -q argv[2]
14+                mkdir -p $argv[2]; or return 1
15+                cd $argv[2]; or return 1
16+            end
17+            echo "Initializing devkit project in "(pwd)"..." >&2
18+            command nix --extra-experimental-features 'nix-command flakes' \
19+                flake init -t $template
20+            or return 1
21+            echo "Scaffold written. Next: devenv shell" >&2
22+        case '*'
23+            printf 'proj: unknown subcommand: %s\n' $argv[1] >&2
24+            echo "usage: proj init [DIR]" >&2
25+            return 2
26+    end
27+end