Last active
December 7, 2020 17:32
-
-
Save elfsternberg/00ac0e7a710c477b03ed789d841de02e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
RED="0;31m" | |
function cg { | |
CG=$(git rev-parse --show-toplevel 2> /dev/null) | |
if [ $? -eq 0 ] && [ -d "$CG" ]; then | |
cd "$CG" || echo "\033[${RED}WARNING: Could not cd to top directory of git repository\033[00m" | |
else | |
echo -e "\033[${RED}WARNING: Not in a git repository\033[00m" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment