Permalink
Browse files

gh-grep: account for ssh or http remotes

  • Loading branch information...
1 parent b46c758 commit b49b833e81143aeb5f983be8aff8727f8686a0e9 @sshaw committed Nov 8, 2013
Showing with 4 additions and 2 deletions.
  1. +4 −2 bashrc
View
@@ -108,7 +108,7 @@ _error()
# usage: gh-grep [OPTIONS] pattern
gh-grep()
{
- local github="http://github.com"
+ local github="https://github.com"
local remote="origin"
local branch=$(git symbolic-ref HEAD 2>/dev/null)
@@ -119,11 +119,13 @@ gh-grep()
local dir=$(git config --get "remote.$remote.url")
[ -z "$dir" ] && _error "No remote named $remote"
+ # account for https://... and git@...
+ dir=${dir#$github/}
dir=${dir##*:}
dir=${dir%.*}
# Not sure about color=always
- git grep -n --full-name --color=always "$@" | perl -laF'(:)' -ne"BEGIN{\$\"=undef}; print qq{https://github.com/sshaw/jaxb2ruby/tree/master/\$F[0]#L\$F[2]@F[3..\$#F]}"
+ git grep -n --full-name --color=always "$@" | perl -laF'(:)' -ne"BEGIN{\$\"=undef}; print qq{$github/$dir/tree/$branch/\$F[0]#L\$F[2]@F[3..\$#F]}"
}
# ls recent

0 comments on commit b49b833

Please sign in to comment.