Skip to content

Instantly share code, notes, and snippets.

@0x000000
Created March 13, 2012 09:39
Show Gist options
  • Save 0x000000/2027857 to your computer and use it in GitHub Desktop.
Save 0x000000/2027857 to your computer and use it in GitHub Desktop.
Open current github repo from console
function git_branch() {
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function github() {
giturl=$(git config --get remote.origin.url)
if [ "$giturl" == "" ]
then
echo "Not a git repository or no remote.origin.url set"
exit 1;
fi
giturl=${giturl/git\@github\.com\:/https://github.com/}
giturl=${giturl/\.git//}
giturl=$giturl"tree/"$(git_branch)
echo $giturl
open $giturl
}
# In addition:
export PS1="\w [\$(git_branch)]\$ "
@0x000000
Copy link
Author

By simple typing $ github in console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment