From 6d33253c8d91f56c8e7c5194936f6f26c86f7508 Mon Sep 17 00:00:00 2001
From: Jens Nolte <git@queezle.net>
Date: Fri, 19 Nov 2021 03:58:34 +0100
Subject: [PATCH] Add `tmp` shell function to enter shell in temporary
 directory

---
 layers/zsh.nix | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/layers/zsh.nix b/layers/zsh.nix
index 7bfc539..30f07a4 100644
--- a/layers/zsh.nix
+++ b/layers/zsh.nix
@@ -332,5 +332,15 @@ in
         builtin cd "$@"
       fi
     }
+
+    tmp () (
+      readonly tmpdir=$(mktemp -d ''${1:-})
+      [[ -z $tmpdir ]] && exit 1
+      TRAPEXIT() {
+        rm -rf $tmpdir
+      }
+      cd $tmpdir
+      zsh -is
+    )
   '';
 }
-- 
GitLab