! #tell git that this isn't an internal alias, but should be run as a bash command
f() { #create a bash function called "f"
echo \" #print the string we're creating (added backslash now in breakdown for syntax highlighting to look better)
https:// #start the url with "https://"
$( #start a subcommand
git config #git config makes it easy to read repository settings
--get #get a setting...
remote.origin.url #...called remote.origin.url
| #pipe the output of the git config command to...
grep #...grep
--color=never #...don't print with colors
-o #...print only what was matched
-E #use extended grep regex syntax
'github.com[:/][^\\.]+' #this is the pattern grep will look for. It removes git@ and .git from the url
| #pipe the output of grep...
sed #...to sed
s/\\:/\\\\// #which using this (heavily backspace) escaped pattern replaces : with /
) #end the subcommand
/commit/ #this is the next part of the url
$( #start another subcommand
git rev-parse @{u} #this prints out the last commit hash on the current branch's upstream branch, i.e. the hash of the last pushed commit in your current branch
) #end subcommand
\" #end the string we're echoing (backslash added here too)
; #end the line with semicolon, as we've got a oneliner
}; #close the function
open $(f) #call open, with the output of the function
Last active
August 29, 2015 14:03
-
-
Save magnusdahlstrand/d9ccb28153158944e3c1 to your computer and use it in GitHub Desktop.
git permalink oneliner breakdown
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment