Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Woot, clickable (in iTerm) per-commit GitHub URLs.

  • Loading branch information...
commit 78fde838a429250e923f5611e233c6e4e942b377 1 parent 6ca9534
@cowboy authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 source/50_vcs.sh
View
16 source/50_vcs.sh
@@ -35,6 +35,22 @@ function gra() {
gr add "$1" "git://github.com/$1/$repo"
}
+# git log with per-commit cmd-clickable GitHub URLs (iTerm)
+function gf() {
+ local remote="$(git remote -v | awk '/^origin.*\(push\)$/ {print $2}')"
+ [[ "$remote" ]] || return
+ local user_repo="$(echo "$remote" | perl -pe 's/.*://;s/\.git$//')"
+ git log $* --name-status --color | awk "$(cat <<AWK
+ /^.*commit [0-9a-f]{40}/ {sha=substr(\$2,1,7)}
+ /^[MA]\t/ {printf "%s\thttps://github.com/$user_repo/blob/%s/%s\n", \$1, sha, \$2; next}
+ /.*/ {print \$0}
+AWK
+ )" | less -F
+}
+
+# Just the last few commits, please!
+for n in {1..5}; do alias gf$n="gf -n $n"; done
+
# OSX-specific Git shortcuts
if [[ "$OSTYPE" =~ ^darwin ]]; then
alias gdk='git ksdiff'

0 comments on commit 78fde83

Please sign in to comment.
Something went wrong with that request. Please try again.