Skip to content

Instantly share code, notes, and snippets.

@imambungo
Forked from igrigorik/github.bash
Last active March 12, 2021 07:13
Show Gist options
  • Save imambungo/6aec26ddc4eff6aeaaea0acc1256cc42 to your computer and use it in GitHub Desktop.
Save imambungo/6aec26ddc4eff6aeaaea0acc1256cc42 to your computer and use it in GitHub Desktop.
Open GitHub URL for current directory/repo...
#!/usr/bin/env bash
# usage: gh [file]
gh() {
repoURL=$(git config remote.origin.url | sed "s~git@\(.*\):\(.*\)~https://\1/\2~" | sed "s~\(.*\).git\$~\1~")
branch=$(git branch | grep \* | cut -d ' ' -f2)
relativePath=$(git rev-parse --show-prefix)
google-chrome "$repoURL/tree/$branch/$relativePath$1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment