diff options
| author | 2024-11-10 11:28:57 +0100 | |
|---|---|---|
| committer | 2024-11-10 11:28:57 +0100 | |
| commit | 33cfe12580f9a987163d92949454d2ded1cf33a4 (patch) | |
| tree | 4e2c5fb5f0907879d504145b6a827cce55a38c57 | |
| parent | sh: remove cd=z alias (diff) | |
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.
| -rw-r--r-- | dot_local/share/sh/tmp | 11 | ||||
| -rw-r--r-- | dot_local/share/sh/tmp.fish | 11 |
2 files changed, 22 insertions, 0 deletions
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 +} diff --git a/dot_local/share/sh/tmp.fish b/dot_local/share/sh/tmp.fish new file mode 100644 index 0000000..9fe3a84 --- /dev/null +++ b/dot_local/share/sh/tmp.fish @@ -0,0 +1,11 @@ +. hascmd mktemp || return +function t + mkdir -p /tmp/t + cd /tmp/t +end +function tt + set -l dir (mktemp -d) + test -d $dir || return 1 + cd $dir + trap "rm -r '$dir'" EXIT +end |
