diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-03-25 17:00:26 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-03-25 17:00:26 -0700 |
commit | 285220820eb842b4dfe52c19852bf71fca517c74 (patch) | |
tree | fc9696737d89ad0944c7f25f6be8729e34dd3977 | |
parent | 5f1605f8cc791ac2fe3700484ae9ebf92db47f73 (diff) | |
download | cdlog-285220820eb842b4dfe52c19852bf71fca517c74.tar.gz cdlog-285220820eb842b4dfe52c19852bf71fca517c74.tar.bz2 cdlog-285220820eb842b4dfe52c19852bf71fca517c74.zip |
cd: when using alias or number, print new PWD.
* cdlog.sh (cdlog.chdir): New local variale print
indicates whether we should print the new $PWD
after a successful cd. We set this when resolving
a numeric argument, or cdalias. Some other commands
already print. The purpose of this to leave a visible
trail in the terminal confirming where the directory
was change, for those users who don't have the directory
in the shell prompt. Note that "cd -" in Bash has this
behavior built in: it prints the path, for the same
reason we are doing.
-rw-r--r-- | cdlog.sh | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -157,6 +157,7 @@ cdlog.chdir() { local cur=$PWD local def + local print= declare -n d=cdlog_hist if [ $# -eq 2 -a "$1" = -P ] ; then @@ -165,11 +166,13 @@ cdlog.chdir() ;; ( [1-9] ) set -- -P "${d[$2]}" + print=y ;; ( ?* ) def=${cdlog_alias[$2]} if [ -n "$def" ] ; then - set -- -P "$def" + set -- -P "$def" + print=y fi ;; ( * ) @@ -181,6 +184,7 @@ cdlog.chdir() if command cd "$@" && [ "$PWD" != "$cur" ]; then # only if we successfully change to a different # directory do the following + [ $print ] && printf "%s\n" "$PWD" if [ $cdlog_lru ] ; then local nx= |