From: Michael Prokop Date: Wed, 20 Jul 2011 14:23:34 +0000 (+0200) Subject: zshrc: Add function cdt() to create a temporary directory and change current working... X-Git-Tag: v0.4.00~4 X-Git-Url: http://git.grml.org/?p=grml-etc-core.git;a=commitdiff_plain;h=885aa3719e564cbb43f3534be9a765d5c4a07bac zshrc: Add function cdt() to create a temporary directory and change current working directory to it. Thanks to Bernhard Tittelbach for the suggestion, thanks to Julius Plenz for his initial idea at http://www.plenz.com/tmp/setup/zshrc and to Carsten Hey for the idea naming it 'cdt' (instead of cdtemp). --- diff --git a/doc/grmlzshrc.t2t b/doc/grmlzshrc.t2t index 0f83c7b..7f62c1b 100644 --- a/doc/grmlzshrc.t2t +++ b/doc/grmlzshrc.t2t @@ -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. diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 3271ee8..3e20e5b 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -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"