Hello! I’m bubstance, meatspace username K.G. Roberts.

    ¡ACHTUNG!
    - profanity
    - recovering linux user
    - subgenius intellect

finger://9p.sdf.org/bubstance

mailto://[email protected]

  • 0 Posts
  • 3 Comments
Joined 1 year ago
cake
Cake day: June 3rd, 2023

help-circle


  • A different way to do the usual ..="cd .." and endless chains of ...="cd ../.." types of aliases:

    bash/ksh version:

    ..() {
        local count="${1:-1}"
        local path="../"
        while (( --count > 0 )); do
            path="$path../"
        done
        cd -- "$path"
    }
    

    zsh single-line version:

    ..() { cd $(printf "../%.s" {1..${1:-1}}) }
    

    These take the number of directories that you want to move up as an argument (e.g. .. 3), otherwise they move you up one directory when used with no arguments.