aboutsummaryrefslogtreecommitdiffstats
path: root/cdlog.sh
diff options
context:
space:
mode:
Diffstat (limited to 'cdlog.sh')
-rw-r--r--cdlog.sh23
1 files changed, 17 insertions, 6 deletions
diff --git a/cdlog.sh b/cdlog.sh
index 99c3338..5db4ad7 100644
--- a/cdlog.sh
+++ b/cdlog.sh
@@ -42,15 +42,13 @@ cdlog.get_param()
fi
}
-# Read state from ~/.cdlog.dirs
+# Initialize state, allocating new ~/.cdlog.N.dirs storage,
+# with LRU replacement.
cdlog.init()
{
- local -a d
- local dir
local i
local oldest
local context
- local sel
c9=; c8=; c7=
c6=; c5=; c4=
@@ -77,10 +75,22 @@ cdlog.init()
fi
cdlog_dirs=~/.cdlog.$context.dirs
-
rm -f $cdlog_dirs
set -- ~/.cdlog.*.dirs
+ if [ $# -gt 0 -a $1 != ~/.cdlog.'*'.dirs ] ; then
+ printf "Use 'cdr' or 'cdlog.recover' to switch to prior cdlog context.\n"
+ fi
+}
+
+cdlog.recover()
+{
+ local -a d
+ local dir
+ local i
+ local sel
+
+ set -- ~/.cdlog.*.dirs
if [ $# -gt 0 -a $1 != ~/.cdlog.'*'.dirs ] ; then
printf "These cdlog contexts exist:\n"
@@ -96,7 +106,7 @@ cdlog.init()
else
printf "Use 1-%s to select context, c1-c%s to clone,\n" $i $i
fi
- printf "or Enter for new blank ontext: "
+ printf "or Enter to keep current context: "
read sel
case $sel in
( [1-9] )
@@ -282,6 +292,7 @@ alias cl='cdlog'
alias cll='cdlog -l'
alias mcd='cdlog.mcd'
alias mcs='cdlog.mcd -s'
+alias cdr='cdlog.recover'
# Better completion for $x[Tab]
shopt -s direxpand