# zshrc/40_tempfuncs # # Helper functions to create temporary files and directories # # Copyright © 1994–2008 martin f. krafft # Released under the terms of the Artistic Licence 2.0 # # Source repository: git://git.madduck.net/etc/zsh.git # cdt () { builtin cd $(mktemp -td ${1:-cdt}.XXXXXX) pwd } vit () { 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 } # vim:ft=zsh