zshrc: Add function cdt() to create a temporary directory and change current working...
authorMichael Prokop <mika@grml.org>
Wed, 20 Jul 2011 14:23:34 +0000 (16:23 +0200)
committerMichael Prokop <mika@grml.org>
Thu, 21 Jul 2011 21:22:55 +0000 (23:22 +0200)
Thanks to Bernhard Tittelbach <bernhard@tittelbach.org>
for the suggestion, thanks to Julius Plenz <zshrc@plenz.com>
for his initial idea at http://www.plenz.com/tmp/setup/zshrc
and to Carsten Hey <carsten@debian.org> for the idea naming
it 'cdt' (instead of cdtemp).

doc/grmlzshrc.t2t
etc/zsh/zshrc

index 0f83c7b..7f62c1b 100644 (file)
@@ -511,6 +511,10 @@ If the original cdrecord is not installed, issues a warning to the user to
 use the wodim binary instead. Wodim is the debian fork of Joerg Schillings
 cdrecord.
 
+: **cdt()**
+Creates a temporary directory using mktemp. Then changes current
+working directory to it.
+
 : **changed()**
 Lists files in current directory, which have been changed within the
 last N days. N is an integer to be passed as first and only argument.
index 3271ee8..3e20e5b 100644 (file)
@@ -2656,6 +2656,13 @@ fir() {
 mcd() {
     mkdir -p "$@" && cd "$@"
 }
+#f5# Create temporary directory and \kbd{cd} to it
+cdt() {
+    local t
+    t=$(mktemp -d)
+    echo "$t"
+    builtin cd "$t"
+}
 #f5# Unified diff to timestamped outputfile
 mdiff() {
     diff -udrP "$1" "$2" > diff.`date "+%Y-%m-%d"`."$1"