by archi42 · 4y ago · 0 comments
> up
Does a `cd ..` on every keypress except ESC or space.
> up $n
Does a total of $n `cd ..` and (important!) set OLDPWD to the initial directory for proper `cd -`.
# Provide 'up', so instead of e.g. 'cd ../../../' you simply type 'up 3'
up() {
case "${1}" in
(*[!0-9]*) : ;;
("") cd || return ;;
(1) cd .. || return ;;
(*) cd "$(eval "printf -- '../'%.0s {1..$1}")" || return ;;
esac
pwd
}