Shell Snippets
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
main() { cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"
# do things...}
main "$@"
References
Section titled “References”- Getting the current script directory: https://stackoverflow.com/a/246128