Skip to content

Instantly share code, notes, and snippets.

@icgood
Last active October 27, 2020 17:48
Show Gist options
  • Save icgood/d9eea6eea9686f331bebf3f025d2e869 to your computer and use it in GitHub Desktop.
Save icgood/d9eea6eea9686f331bebf3f025d2e869 to your computer and use it in GitHub Desktop.
#!/bin/bash
branch=${BRANCH:-$(git symbolic-ref -q --short HEAD)}
remote=${REMOTE:-$(git config "branch.$branch.remote")}
remote=${remote:-origin}
default_branch=${DEFAULT_BRANCH:-$(git config "remote.$remote.defaultBranchName")}
default_branch=${default_branch:-$(git remote show $remote | awk '/HEAD branch/ {print $NF}')}
if [ -z "$@" ]; then
echo "usage: git open-path path/to/file"
exit 2
fi
exec git open $remote $default_branch --suffix "blob/$branch/$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment