From 38d5b7166a291bb7b20cd772cccc29301ac78ba3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 19 Mar 2015 12:45:15 +1300 Subject: Allow supplying pattern string to scr --- bash/bashrc.d/scr.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bash') 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 } -- cgit v1.2.3