/ › JDHQ › cd directly to a folder
    Sign in

    On this page

    • cd directly to a folder
      • Usage
      • Note: the CLI is also jd

    Settings

    Command line

    • The 'jd' command-line app
    • Environment variable standards
    • cd directly to a folder
    • Zsh prompt improvements

    cd directly to a folder

    Tab completion and unambiguous folder names make navigating to a Johnny.Decimal folder trivial.

    cd 2β‡₯ 21β‡₯ 21.13β‡₯⏎
    # /Users/john/Documents/20-29 Create & collect/21 Imaginarium 🧠/21.13 Flight records & boarding passes

    That gets you to folder 21.13 by way of 20-29 then 21. Pretty quick, but we can make it quicker.

    Add this to ~/.zshrc.

    # ⚠️ Set your own path
    export JD_PATH="/Users/john/Documents"
    
    jd() {
      local root="${JD_PATH:?JD_PATH not set}" id="$1"
      if [[ -z "$id" ]]; then
        cd "$root"
        return
      fi
      local match
      match=$(find "$root" -maxdepth 3 -type d -name "$id *" -print -quit)
      if [[ -n "$match" ]]; then
        cd "$match"
      else
        echo "No folder found for $id" >&2
        return 1
      fi
    }
    
    # Extension for multiple systems
    # ⚠️ Set your own paths
    export JD_D25_PATH="/Users/john/Documents/D25"
    export JD_P76_PATH="/Users/john/Documents/P76"
    
    d25() { JD_PATH="$JD_D25_PATH" jd "$@" }
    p76() { JD_PATH="$JD_P76_PATH" jd "$@" }

    Usage

    Single systems

    jd 21.13
    # /Users/john/Documents/20-29 Create & collect/21 Imaginarium 🧠/21.13 Flight records & boarding passes

    Multiple systems

    p76 21.13
    pwd
    # /Users/john/Documents/P76/20-29 Create & collect/21 Imaginarium 🧠/21.13 Flight records & boarding passes

    Note: the CLI is also jd

    The in-development CLI utility will eventually perform this function. If you want to try the CLI, give the function described above a different name (e.g. jdcd).


    β—€ Back Environment variable st… Zsh prompt improvements Next β–Ά (Use the ← arrow keys β†’)

    Written by humans • Search • Support