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