X-Git-Url: https://git.madduck.net/etc/zsh.git/blobdiff_plain/dffaced336ebd944972a3bd0be6a5ab21905eff4..8bb4f01b24bd52f9f8463598c0347afe276d3da4:/.zsh/zshrc/39_tempfuncs?ds=sidebyside diff --git a/.zsh/zshrc/39_tempfuncs b/.zsh/zshrc/39_tempfuncs index 0350925..d3391f6 100644 --- a/.zsh/zshrc/39_tempfuncs +++ b/.zsh/zshrc/39_tempfuncs @@ -9,13 +9,17 @@ # cdt () { - builtin cd $(mktemp -td ${1:-cdt}.XXXXXX) + 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 prefix - for i in "$@"; do + for i in "$@"; do case "$i" in -) local stdin=1; shift;; *) if [ -z "${prefix:-}" ]; then @@ -27,10 +31,11 @@ vit () { ;; esac done - local tmpfile=$(mktemp -t ${prefix}.XXXXXX) + 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