X-Git-Url: https://git.madduck.net/etc/zsh.git/blobdiff_plain/3857a686b5a0aaa4937eb50f982d7b290561a223..0c9316ff202057714df19a8b295967691dba72e9:/.zsh/zshrc/39_tempfuncs?ds=sidebyside diff --git a/.zsh/zshrc/39_tempfuncs b/.zsh/zshrc/39_tempfuncs index dd4eb07..d3391f6 100644 --- a/.zsh/zshrc/39_tempfuncs +++ b/.zsh/zshrc/39_tempfuncs @@ -5,19 +5,37 @@ # Copyright © 1994–2008 martin f. krafft # Released under the terms of the Artistic Licence 2.0 # -# Source repository: http://git.madduck.net/v/etc/zsh.git +# Source repository: git://git.madduck.net/etc/zsh.git # cdt () { - cd $(mktemp -td cdt.XXXXXXXX) + local tmpdir + tmpdir=$(mktemp -td ${1:-cdt}.XXXXXX) + builtin cd $tmpdir pwd + rm -f ${TMPDIR:-/tmp}/cdt.latest + ln -s $tmpdir ${TMPDIR:-/tmp}/cdt.latest } 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 + ln -sf $tmpfile ${TMPDIR:-/tmp}/vit.latest } # vim:ft=zsh