aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash')
-rw-r--r--bash/bashrc.d/scr.bash10
1 files changed, 8 insertions, 2 deletions
diff --git a/bash/bashrc.d/scr.bash b/bash/bashrc.d/scr.bash
index e8b6b58a..b7a49b14 100644
--- a/bash/bashrc.d/scr.bash
+++ b/bash/bashrc.d/scr.bash
@@ -1,6 +1,12 @@
# Create a temporary directory and change into it, to stop me putting stray
-# files into $HOME, and making the system do cleanup for me
+# files into $HOME, and making the system do cleanup for me. Single optional
+# argument is the string to use for naming the directory; defaults to "scr".
scr() {
- pushd -- "$(mktemp -d)"
+ if (($# <= 1)) ; then
+ pushd -- "$(mktemp -dt "${1:-scr}".XXXXX)"
+ else
+ printf 'bash: scr: too many arguments\n' >&2
+ return 1
+ fi
}