Hacker News new | past | comments | ask | show | jobs | submit login

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
    }



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: