Home

dotnix @main - refs - log -
-
https://git.jolheiser.com/dotnix.git
My nix dotfiles
tree log patch
add scratch and allow for descriptions
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQDAS0XC+0KXDDjNdh9Wal/jwGqxxfhUUbvypP0XKTvH6quVQpxsoYxMQ0HHXejqVLV g8ZQVZLwEXt2TRMRFkLgM= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
1 week ago
2 changed files, 23 additions(+), 2 deletions(-)
home/nogui/nushell/autoload/scratch.nuhome/nogui/nushell/autoload/tmp.nu
I home/nogui/nushell/autoload/scratch.nu
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/home/nogui/nushell/autoload/scratch.nu b/home/nogui/nushell/autoload/scratch.nu
new file mode 100644
index 0000000000000000000000000000000000000000..d4ee3df3ee2d69cab96be9ee1e745a8eb7d42d66
--- /dev/null
+++ b/home/nogui/nushell/autoload/scratch.nu
@@ -0,0 +1,15 @@
+module scratch {
+  # Make a throwaway buffer
+  export def --env main [
+    --description(-d): string         # Optional filename description for identifying
+    extension?:        string = "txt" # File extension (for highlighting)
+  ]: nothing -> nothing {
+    mut name = "tmp"
+    if $description != null {
+      $name = $description
+    }
+    let tmp = mktemp --tmpdir --suffix $".($extension)" $"($name).XXX"
+    ^$env.EDITOR $tmp
+  }
+}
+use scratch *
M home/nogui/nushell/autoload/tmp.nu -> home/nogui/nushell/autoload/tmp.nu
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/home/nogui/nushell/autoload/tmp.nu b/home/nogui/nushell/autoload/tmp.nu
index 003cff4384e2dc97b1a9115c8d3a32f4f6ee2764..67b4fd08ff2ec2e0ae0761bc896612c14f287d6c 100644
--- a/home/nogui/nushell/autoload/tmp.nu
+++ b/home/nogui/nushell/autoload/tmp.nu
@@ -1,7 +1,13 @@
 module tmp {
   # Create a temporary directory and cd in to it
-  export def --env main []: nothing -> nothing {
-    let t = mktemp --directory
+  export def --env main [
+    --description(-d): string # Optional filename description for identifying
+  ]: nothing -> nothing {
+    mut name = "tmp"
+    if $description != null {
+      $name = $description
+    }
+    let t = mktemp --directory $"($name).XXX"
     cd $t
   }
 }