]> arthur.barton.de Git - ax-zsh.git/blobdiff - default_plugins/std_functions/std_functions.zshrc
std_functions: Further tweak untake()
[ax-zsh.git] / default_plugins / std_functions / std_functions.zshrc
index 69d65113ffa2baff69339ebb65560cd75c86ffe5..47ca9123062a867099222e7139de76db172cebd2 100644 (file)
@@ -33,12 +33,16 @@ function take() {
 }
 
 function untake() {
-       if [[ "${PWD%tmp.*}" = "${TMPDIR}" ]]; then
-               pwd
+       pwd="${PWD}/"
+       subdir="${pwd##$TMPDIR}"
+       if [[ "${PWD%tmp.*}" = "${TMPDIR}" && -n "$subdir" ]]; then
+               tmp_d="${TMPDIR}${subdir%%/*}"
+               echo "$tmp_d"
                cd
-               rm -fri "$@" "${OLDPWD}"
+               rm -fr "$@" "${tmp_d}"
        else
                echo 'Sorry, not a temporarily taken directory!' >&2
+               return 1
        fi
 }