News for hackers. Stuff that matters.
Re:Ask HN: Can I see your scripts? by archi42 on Monday August 15, 2022 @05:59PM (#32475996)
I lost the script (bash function) when I changed job, but inspired by a co-worker:

> 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 -`.

Re:Ask HN: Can I see your scripts? by whetu on Monday August 15, 2022 @11:18PM (#32478833)
I've seen a few examples of this function over the years, here's a recent variant of mine (I'm accepting the use of eval here):

    # 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
    }