Last active
October 27, 2020 17:48
-
-
Save icgood/d9eea6eea9686f331bebf3f025d2e869 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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