summaryrefslogtreecommitdiff
path: root/features/user/cli
diff options
context:
space:
mode:
authoroutremonde <outremonde@vivaldi.net>2025-06-13 22:05:16 -0400
committeroutremonde <outremonde@vivaldi.net>2025-06-13 22:05:16 -0400
commit335a6afd5f47b58861dfa788f37369b64583efe7 (patch)
tree935949a337c4e2f8a6c22867ed78fb033ec3a4f7 /features/user/cli
parent73250600f16a965481b22ba19e52c158b8ba2610 (diff)
finished projinit and qr commands
Former-commit-id: 2c9217e7b6e27de846a109d7834654032fc11f52
Diffstat (limited to 'features/user/cli')
-rw-r--r--features/user/cli/shells/nushell/default.nix31
1 files changed, 20 insertions, 11 deletions
diff --git a/features/user/cli/shells/nushell/default.nix b/features/user/cli/shells/nushell/default.nix
index c0c8b40..b8abba5 100644
--- a/features/user/cli/shells/nushell/default.nix
+++ b/features/user/cli/shells/nushell/default.nix
@@ -59,33 +59,42 @@ in {
}
# define a function to initialize a direnv project
- def projinit [path?: string] {
+ def projinit [path?: string] { # this code sucks but I'm tired of working on it
mut path = $path
if ($path == null) {
$path = "./"
}
let path = $path | path expand
- cp -r ${./direnv-project-template}/* $path
- chmod +w $"($path)/"
- direnv allow
+ let template_path = "${./direnv-project-template}" | path expand
+ let template_files = ls -a $template_path | get name
+ $template_files | each {|item| cp $item $path}
+ ls -a $path | get name | filter {|name| $template_files | str contains ($name | path basename) | any {}} | each {|name| chmod +w $name}
+ if (try {git rev-parse --is-inside-work-tree e> /dev/null}) != null {
+ direnv allow
+ } else {
+ git init
+ direnv allow
+ }
+ git add $"($path)/."
+ git commit -m "initialized"
}
# Quickly create a nix shell.
- def qs [...pkgs] {
- if $pkgs == [] {
+ def qs [...packages] {
+ if $packages == [] {
print "Please use a package name."
return
}
- let pkgs_string = $pkgs
- | each {|pkg| return $"nixpkgs#($pkg) "}
+ let packages_string = $packages
+ | each {|package| return $"nixpkgs#($package) "}
| str join
| str trim
- nu -c $"nix shell ($pkgs_string)"
+ nu -c $"nix shell ($packages_string)"
}
# Quickly run a nix package.
- def qr [pkg: string] {
- nix run $"nixpkgs#($pkg)"
+ def qr --wrapped [package: string ...arguments] {
+ nix run $"nixpkgs#($package)" -- ($arguments | str join " ")
}
'';
};