Created
February 4, 2024 18:27
-
-
Save tforster/0431693f755fadd1c902be6e564676a1 to your computer and use it in GitHub Desktop.
cw - change working directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple way of aliasing short project names to deeper working directories. | |
# - If you work on multiple machines and keep the same directory layout then this becomes very useful | |
# | |
# 1. Create a secret gist called joy.json that looks something like the following. Use your own meaningful project names and create as many entries as you need | |
# | |
# { | |
# "bookmarks": { | |
# "project1": "/full/path/to/the/project1/directory", | |
# "project2": "/full/path/to/the/project2/directory, | |
# } | |
# } | |
# | |
# 2. Add the following to your .zshrc (or .bashrc). Note that docker is required to run jq in a container. You can download and install jq locally instead | |
function cw() {cd $(curl -s https://gist.githubusercontent.com/{username}/{gistId}/raw/joy.json | docker run -i --rm ghcr.io/jqlang/jq -r --arg bookmark "$1" '.bookmarks[$bookmark]') } | |
# 3. Deep cd to project directory with `cw project1`, `cw project2`, etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment