From 0bbe75fd3b73c309df0f1c76b38b7692f983cd19 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 14 Jan 2025 22:55:05 -0800 Subject: Add n command to cdr. * cdlog.sh (cdlog.init): Keep the identity of the freshly allocated session in the variable cdlog_new_dirs. (cdlog.recover): Allow the user to use 'n' to select the newly allocated session. * README.md: Documented. --- README.md | 14 +++++++++----- cdlog.sh | 6 ++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7e1909a..46f5e3d 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,15 @@ pick which directory to change to or swap with. The terminal cursor is then retraced back to the top of the menu, and the screen is erased from 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. Deleting unwanted -sessions is possible with a `d` prefix. +* The `cdr` command is used for recovering previous sessions. +When `cdlog` started, it allocated a new session. +The `cdr` recovery command presents you with a numbered list of previous +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. Deleting +unwanted sessions is possible with a `d` prefix. The `n` choice will select +again the new session that `cdlog` had allocated on startup, and that one +won't appear in the list of recoverable sessions unless it has been already +persisted by the execution of a directory-changing command. * The `cdalias` command is used for defining "cd aliases"; see below. diff --git a/cdlog.sh b/cdlog.sh index f3661f1..888a858 100644 --- a/cdlog.sh +++ b/cdlog.sh @@ -80,6 +80,7 @@ cdlog.init() fi cdlog_dirs=~/.cdlog.$context.dirs + cdlog_new_dirs=$cdlog_dirs rm -f $cdlog_dirs set -- ~/.cdlog.*.dirs @@ -116,6 +117,7 @@ cdlog.recover() 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 + printf "n to use newly allocated,\n" $i fi printf "or Enter to keep current context: " read sel @@ -140,6 +142,10 @@ cdlog.recover() rm "$sel" && printf "Deleted!\n" fi ;; + ( n ) + cdlog_dirs=$cdlog_new_dirs + break + ;; ( "" ) break ;; -- cgit v1.2.3