]> git.donarmstrong.com Git - zsh.git/blobdiff - .zsh/zshrc/39_tempfuncs
tempfuncs can now incorporate a keyword into the file/dirname
[zsh.git] / .zsh / zshrc / 39_tempfuncs
index de2e2320c23917a30d09fad6fcea1ca129fac4e7..0350925180837e2fa0b17eeae304bbc1d509a6ab 100644 (file)
@@ -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 >/dev/tty
   echo $tmpfile
 }