From d4b0a6ddff9f505b5f1147324b1446bdc70de592 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sat, 20 Jan 2024 23:38:47 +0100 Subject: [PATCH] std_functions: Further tweak untake() --- default_plugins/std_functions/std_functions.zshrc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 } -- 2.39.2