From 33cfe12580f9a987163d92949454d2ded1cf33a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Vulquin?= Date: Sun, 10 Nov 2024 11:28:57 +0100 Subject: sh: add /tmp helpers I have really poor discipline when it comes to /tmp. In particular, almost every boot, I create a /tmp/t, and then I pollute it. With this, I can make auto-cleaned-up directories that are arbitrary (`tt`) that's for the quick experiments. And then there's a helper for longer term stuff (via `t`) that's equivalent to what I already do, but nicer. --- dot_local/share/sh/tmp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 dot_local/share/sh/tmp (limited to 'dot_local/share/sh/tmp') diff --git a/dot_local/share/sh/tmp b/dot_local/share/sh/tmp new file mode 100644 index 0000000..1aeaea1 --- /dev/null +++ b/dot_local/share/sh/tmp @@ -0,0 +1,11 @@ +. hascmd mktemp || return +t() { + mkdir -p /tmp/t + cd /tmp/t +} +tt() { + local dir=$(mktemp -d) + [ -d "$dir" ] || return 1 + cd "$dir" + trap "rm -r '$dir'" EXIT +} -- cgit v1.2.3