Last active
August 29, 2015 14:07
-
-
Save zdennis/fe8e96109d95eab8e518 to your computer and use it in GitHub Desktop.
gitconfig aliases
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
# +cbranch+ returns the current branch you are on | |
cbranch = !"git branch | grep '*' | cut -f2 -d' '" | |
# +open-url+ opens the home page for this repository | |
open-url = !"open `git remote show origin | grep 'Fetch URL' | ruby -e \"puts 'http://' + STDIN.read.scan(/Fetch URL: git@(.*)/).join.sub(':', '/').sub('.git','')\"`" | |
# +open-branch+ opens the current branch in your default browser | |
open-branch = !"open `git remote show origin | grep 'Fetch URL' | ruby -e \"puts 'http://' + STDIN.read.scan(/Fetch URL: git@(.*)/).join.sub(':', '/').sub('.git','') + \\\\\"/tree/#{%x|git cbranch|}\\\\\"\"`" | |
# +open-sha+ opens the current SHA in your default browser | |
open-sha = !"open `git remote show origin | grep 'Fetch URL' | ruby -e \"puts 'http://' + STDIN.read.scan(/Fetch URL: git@(.*)/).join.sub(':', '/').sub('.git','') + \\\\\"/commit/#{%x| git log -n1 --pretty=%H|}\\\\\"\"`" | |
# e.g. - https://github.com/account/repos/pull/new/chore/branch-name-here | |
open-pull = !"open `git remote show origin | grep 'Fetch URL' | ruby -e \"puts 'http://' + STDIN.read.scan(/Fetch URL: git@(.*)/).join.sub(':', '/').sub('.git','') + \\\"/pull/new/#{%x|git cbranch|}\\\"\"`" | |
# +add-ignore+ downloads ignore files from Github and adds them to your local | |
# .gitignore. TODO: This can be way awesomer. | |
add-ignore = !"g(){ url="https://raw.github.com/github/gitignore/master/$1.gitignore" ; curl --output /dev/null --silent --head --fail "$url" ; if [ $? -eq 0 ]; then curl "$url" >> .gitignore && echo "Appended .gitignore with $url" ; else echo "$url doesnt exist." ; fi ; }; g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you could avoid the piping & filtering in
cbranch
using this instead: