Skip to content

Instantly share code, notes, and snippets.

@corbanb
Created April 17, 2016 22:09
Show Gist options
  • Save corbanb/e89b5dddbed0158f144a670869bb98b9 to your computer and use it in GitHub Desktop.
Save corbanb/e89b5dddbed0158f144a670869bb98b9 to your computer and use it in GitHub Desktop.
# Opens the bitbucket page for the current git repository in your browser
function bit() {
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\@bitbucket\.org\:/https://bitbucket.org/}
giturl=${giturl/\.git/}
branch="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch="(unnamed branch)" # detached HEAD
branch=${branch##refs/heads/}
giturl=$giturl/src/?at=$branch
open $giturl
}
@corbanb
Copy link
Author

corbanb commented Apr 17, 2016

Add this to your oh-my-zsh custom/plugins to open files on bitbucket easily.

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