X-Git-Url: https://git.madduck.net/etc/zsh.git/blobdiff_plain/e7aef48f33e934106d1a50201d9f098f9886d7ec..14b8c2d80836b331e0a68ce16df6640f98122f17:/.zsh/zshrc/39_tempfuncs?ds=sidebyside diff --git a/.zsh/zshrc/39_tempfuncs b/.zsh/zshrc/39_tempfuncs index 506f001..4b46a17 100644 --- a/.zsh/zshrc/39_tempfuncs +++ b/.zsh/zshrc/39_tempfuncs @@ -9,13 +9,26 @@ # cdt () { - builtin cd $(mktemp -td cdt.XXXXXXXX) + builtin cd $(mktemp -td ${1:-cdt}.XXXXXX) pwd } vit () { - local tmpfile=$(mktemp -t vit.XXXXXXXX) - [ "$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:-vit}.XXXXXX) + [ -n "$stdin" ] && cat >| $tmpfile sensible-editor $tmpfile /dev/tty echo $tmpfile }