6
You may find the shell $OLDPWD shell variable useful (defined by POSIX). For example, you could define a shell function overriding the original cd command:
cd() { command cd "$@" && printf '%s -> %s\n' "${OLDPWD}" "${PWD}"; }
Excerpt from the Unix man page you should read:
If, during the execution of the above steps, the PWD environment ...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
macos × 2018bash × 285
linux × 195
terminal × 164
shell-script × 119
shell × 105
command-line × 101
ssh × 96
ubuntu × 70
macintosh × 68
find × 64
sed × 63
files × 61
permissions × 61
zsh × 58
grep × 43
text-processing × 41
filesystems × 41
networking × 37
ls × 37
bsd × 37
x11 × 33
vim × 33
awk × 32
debian × 30