diff options
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | cdlog.sh | 21 |
2 files changed, 29 insertions, 0 deletions
@@ -62,6 +62,14 @@ sessions is possible with a `d` prefix. * The `cdunalias` command removes a cd alias. +* The `c` command takes one argument. If it successfully, resolves to a path, +that path it is printed, and the termination status is successful. Otherwise +nothing is printed and the termination status is failed. If the argument is a +digit in the range 1 to 9, then it resolves to the specified element in the +`cdlog` history, if it is nonblank. If the argument begins with `@`, then it +resolves as a search; see Searches below. Otherwise, it is resolved as a +`cdlog` alias; see Aliases below. + In addition, the `cdlog.sh` script sets the bash `direxpand` option. With the `direxpand` option, Tab completion on a directory coming from a variable name will expand that variable into the command line. @@ -461,6 +461,26 @@ cdlog.unalias() done } +cdlog.lookup() +{ + local out + + case $1 in + ( [1-9] ) + out=${cdlog_hist[$1]} + [ -n "$out" ] && printf "%s\n" "$out" || false + ;; + ( @* ) + cdlog.at2path "$1" + ;; + ( * ) + out=${cdlog_alias[$1]} + [ -n "$out" ] && printf "%s\n" "$out" || false + ;; + esac +} + + # Tab completion for cd aliases cdlog.complete() @@ -502,6 +522,7 @@ alias cdr='cdlog.recover' alias cdalias='cdlog.alias' alias cdaliases='cdlog.aliases' alias cdunalias='cdlog.unalias' +alias c='cdlog.lookup' # Better completion for $x[Tab] shopt -s direxpand |