From 6de647b88df2d25e80e9016c5a9e75122488e7d0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 14 Mar 2024 20:45:01 -0700 Subject: cdr: delete unwanted contexts with d prefix. * cdlog.sh (cdlog.recover): Support d prefix. We only mention it in the prompt if there are two or more contexts. * README.md: Documented. --- README.md | 3 ++- cdlog.sh | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a23697b..d0b26b0 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,8 @@ that point to the bottom. * The `cdr` command is used for recovering previous sessions. It presents you with a numbered list of these sessions. You can recover to one of the sessions, use a `c` prefix on the number to clone the session into -the current session, or press Enter to do nothing. +the current session, or press Enter to do nothing. Deleting unwanted +sessions is possible with a `d` prefix. * The `cdalias` command is used for defining "cd aliases"; see below. diff --git a/cdlog.sh b/cdlog.sh index 503c203..626189a 100644 --- a/cdlog.sh +++ b/cdlog.sh @@ -108,7 +108,9 @@ cdlog.recover() if [ $i -eq 1 ] ; then printf "Use 1 to select context, c1 to clone,\n" else - printf "Use 1-%s to select context, c1-c%s to clone,\n" $i $i + printf "Use 1-%s to select context,\n" $i + printf "c1-c%s to clone,\n" $i + printf "d1-d%s to delete,\n" $i fi printf "or Enter to keep current context: " read sel @@ -127,6 +129,12 @@ cdlog.recover() break fi ;; + ( d[1-9] ) + sel=$(cdlog.get_param ${sel#d} "$@") + if [ -n "$sel" ] ; then + rm "$sel" && printf "Deleted!\n" + fi + ;; ( "" ) break ;; -- cgit v1.2.3