Skip to content

Instantly share code, notes, and snippets.

@weeble
Created February 3, 2022 14:38
Show Gist options
  • Save weeble/3f511ab145e93a33177cf9c6542b9460 to your computer and use it in GitHub Desktop.
Save weeble/3f511ab145e93a33177cf9c6542b9460 to your computer and use it in GitHub Desktop.
Short shell script to run a command at the top level directory of a git repo
#!/bin/sh
if toplevel="$(git rev-parse --show-toplevel)"
then
if cd "$toplevel"
then
exec "$@"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment