aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--cdlog.sh6
2 files changed, 8 insertions, 4 deletions
diff --git a/README.md b/README.md
index 8fd46a7..a23697b 100644
--- a/README.md
+++ b/README.md
@@ -12,12 +12,14 @@ Install the file `cdlog.sh` somewhere, and source it from your
The user interface consists of three commands:
-* `cd` is now an alias which calls the function `cdlog.chdir`.
+* `cd` is an alias which calls the function `cdlog.chdir`.
Every time you change directory, it pushes the previous directory
-into a history log which is stored in the `cdlog_fifo` array. The log maintains
+into a history log which is stored in the `cdlog_hist` array. The log maintains
nine entries. The ninth entry is erased. The entries are copied into
the variables `c1` through `c9`. The first four entries are also
copied into the variables `x`, `y`, `z` and `w` for shorter access.
+If the argument of `cd` is a number from 1 to 9, it changes to the
+specified `cdlog` history element.
* `cs` (cd swap) is an alias for a command which exchanges
the current directory with a selected `cslog` entry selected
diff --git a/cdlog.sh b/cdlog.sh
index 81126bb..503c203 100644
--- a/cdlog.sh
+++ b/cdlog.sh
@@ -147,11 +147,15 @@ cdlog.chdir()
{
local cur=$PWD
local def
+ declare -n d=cdlog_hist
if [ $# -eq 2 -a "$1" = -P ] ; then
case $2 in
( */* )
;;
+ ( [1-9] )
+ set -- -P "${d[$2]}"
+ ;;
( ?* )
def=${cdlog_alias[$2]}
if [ -n "$def" ] ; then
@@ -168,8 +172,6 @@ cdlog.chdir()
# only if we successfully change to a different
# directory do the following
- declare -n d=cdlog_hist
-
if [ $cdlog_lru ] ; then
local nx=
local pv=$cur