git module

This commit is contained in:
Bryan Ramos 2024-05-12 11:05:08 -04:00
parent b3714ed696
commit 5c80915d81
Signed by: bryan
GPG key ID: 6ABDCD144D6643C8
2 changed files with 2 additions and 3 deletions

View file

@ -0,0 +1,25 @@
''
function cdg() {
if [[ $1 == "--help" ]]; then
echo "A simple utility for navigating to the root of a git repo"
return 0
fi
# Check for invalid command
if [[ -n "$1" ]]; then
echo "Invalid command: $1. Try 'cdg --help'."
return 1
fi
local root_dir
root_dir=$(git rev-parse --show-toplevel 2>/dev/null)
local git_status=$?
if [ $git_status -ne 0 ]; then
echo "Error: Not a git repo."
return 1
fi
cd "$root_dir"
}
''