Skip to content

Instantly share code, notes, and snippets.

@elfsternberg
Last active December 7, 2020 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elfsternberg/00ac0e7a710c477b03ed789d841de02e to your computer and use it in GitHub Desktop.
Save elfsternberg/00ac0e7a710c477b03ed789d841de02e to your computer and use it in GitHub Desktop.
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