From: martin f. krafft Date: Wed, 23 Feb 2011 09:39:02 +0000 (+0100) Subject: tempfuncs can now incorporate a keyword into the file/dirname X-Git-Url: https://git.madduck.net/etc/zsh.git/commitdiff_plain/dffaced336ebd944972a3bd0be6a5ab21905eff4?ds=inline;hp=-c tempfuncs can now incorporate a keyword into the file/dirname --- dffaced336ebd944972a3bd0be6a5ab21905eff4 diff --git a/.zsh/zshrc/39_tempfuncs b/.zsh/zshrc/39_tempfuncs index de2e232..0350925 100644 --- a/.zsh/zshrc/39_tempfuncs +++ b/.zsh/zshrc/39_tempfuncs @@ -9,13 +9,26 @@ # cdt () { - builtin cd $(mktemp -td cdt.XXXXXX) + builtin cd $(mktemp -td ${1:-cdt}.XXXXXX) pwd } vit () { - local tmpfile=$(mktemp -t vit.XXXXXX) - [ "$1" = '-' ] && cat >| $tmpfile + local prefix + for i in "$@"; do + case "$i" in + -) local stdin=1; shift;; + *) if [ -z "${prefix:-}" ]; then + prefix="$i"; shift + else + error "prefix already specified: $prefix" + return 1 + fi + ;; + esac + done + local tmpfile=$(mktemp -t ${prefix}.XXXXXX) + [ -n "$stdin" ] && cat >| $tmpfile sensible-editor $tmpfile /dev/tty echo $tmpfile }