From: Alexander Barton Date: Sat, 20 Jan 2024 22:38:47 +0000 (+0100) Subject: std_functions: Further tweak untake() X-Git-Url: https://arthur.barton.de/gitweb/?a=commitdiff_plain;h=d4b0a6ddff9f505b5f1147324b1446bdc70de592;hp=6e9973ba3ee1c22f3c584bccb9abb317fbed5f35;p=ax-zsh.git std_functions: Further tweak untake() --- diff --git a/default_plugins/std_functions/std_functions.zshrc b/default_plugins/std_functions/std_functions.zshrc index 69d6511..47ca912 100644 --- a/default_plugins/std_functions/std_functions.zshrc +++ b/default_plugins/std_functions/std_functions.zshrc @@ -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 }