6 ms·
I do the same in bash, but it's a bit wordier: _chpwd_hook() { if [[ "$PWD" != "$PREVPWD" ]]; then ls PREVPWD="$PWD" fi } PROMPT_COM
by tutipop 2y ago
I do the same in bash, but it's a bit wordier:
_chpwd_hook() {
if [[ "$PWD" != "$PREVPWD" ]]; then
ls
PREVPWD="$PWD"
fi
}
PROMPT_COMMAND=(_chpwd_hook)
Goes well with
shopt -s autocd
alias r='cd -'
- mbivert 2y agoNot strictly equivalent, but shorter (and should work with multiple shells): $ cd() { builtin cd $* && ls; } $ cd / bin boot cdrom dev etc home lib lib64 [...]
- oxygen_crisis 2y ago$* will break on directory names containing spaces and other bash "word" delimiters, use "$@": cd() { builtin cd "$@" && ls; }