Created
May 8, 2024 20:29
-
-
Save suchipi/287625610a6fc69854ba72b54558cdc2 to your computer and use it in GitHub Desktop.
bash "go to repo root" snippet
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
#!/usr/bin/env bash | |
# This isn't 100% foolproof, but it's probably good enough for random scripts in your git repo | |
THIS_FILE="$BASH_SOURCE" | |
THIS_DIR=$(dirname "$THIS_FILE") | |
ROOT_DIR=$(realpath "$THIS_DIR/..") | |
cd "$ROOT_DIR" | |
# and then you can do stuff with guarantees about $PWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment