Skip to content

Instantly share code, notes, and snippets.

@kernelsmith
Forked from todb-r7/.gitconfig
Last active December 28, 2015 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kernelsmith/7449293 to your computer and use it in GitHub Desktop.
Save kernelsmith/7449293 to your computer and use it in GitHub Desktop.
git alias for pr-url to open a browser with a PR to the intended user and branch
[user]
uname = ks
[alias]
branch-current = rev-parse --abbrev-ref HEAD
# Usage: git pr-url HISNAME HISBRANCH
# Example: git pr-url rapid7 master
# Example: git pr-url OJ feature/cool_feature_that_also_fixes_bugs
pr-url =!"xdg-open https://github.com/$(git config user.uname)/$(basename $(git rev-parse --show-toplevel))/pull/new/$1:$2...$(git branch-current) #"
# OSX. Use whatever browser you use
#pr-url =!"open -a \"Google Chrome\" https://github.com/$(git config user.uname)/$(basename $(git rev-parse --show-toplevel))/pull/new/$1:$2...$(git branch-current) #"
# NOTE: you may be able to use config user.name if that matches your username
@kernelsmith
Copy link
Author

$ git config remote.origin.url
=> https://github.com/kernelsmith/metasploit-framework.git
This would give us a good starting URL, but you can't rely on the idea that the URL will always be HTTPS, as it could be git, so we'll have to build it, however this does basically give us a good place to get the name of the git repo

However, this works pretty well too, neither are very windows friendly:

git rev-parse --show-toplevel
#   => /home/kernelsmith/gits/metasploit-framework
basename $(git rev-parse --show-toplevel)
#   => metasploit-framework

@todb-r7
Copy link

todb-r7 commented Jan 2, 2014

Thanks @kernelsmith, I did see this, made a minor change to use github.user instead, and it's fantastico. I'm going to be writing a blog post today about all my various and sundry git/github dot files, I just need to remember to also update the documentation on http://r-7.co/MSF-DEV as well.

@todb-r7
Copy link

todb-r7 commented Jan 2, 2014

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