diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | cdlog.sh | 9 |
2 files changed, 10 insertions, 2 deletions
@@ -34,6 +34,9 @@ most recent directory in the log, and removes that entry from the log. The secon recent directory becomes most recent and so on. If it is given an argument value in the range 1 to 9, it changes to the specified entry, and removes it, moving the others down to close the gap. Thus `pd 1` is equivalent to `pd`. +`pd` takes a `-f` option which means "force". This is useful when it's +not possible to change to the indicated directory, in which case `-f` +causes it to be removed in spite of this. * `cdlog` function shows a listing of the four most recent entries in the log, or all nine if given the `-l` argument. The `cl` command is an alias for @@ -233,13 +233,18 @@ cdlog.rot() } -# Change to most recent diretory in cdlog and remove it +# Change to most recent directory in cdlog and remove it # from the log. cdlog.pop() { declare -n d=cdlog_hist local n=1 local i + local force= + + if [ $# -gt 0 -a "$1" = "-f" ] ; then + force=y; shift + fi if [ $# -gt 0 ] ; then n=$1; shift @@ -247,7 +252,7 @@ cdlog.pop() case $n in ( [1-9] ) - if command cd "${d[$n]}" ; then + if command cd "${d[$n]}" || [ $force ]; then for ((i = n; i < ${#d[@]}; i++)); do d[$i]=${d[$((i + 1))]} done |