Permalink
Browse files

adding prefix

  • Loading branch information...
1 parent e12a649 commit 015d65e89a060b13b5cc68088180364e7635125d @tenderlove committed Oct 15, 2010
Showing with 22 additions and 1 deletion.
  1. +2 −0 .gitignore
  2. +6 −1 .netrwhist
  3. +14 −0 plugin/githublink.vim
View
@@ -0,0 +1,2 @@
+.netrwhist
+
View
@@ -1,5 +1,10 @@
let g:netrw_dirhistmax =10
-let g:netrw_dirhist_cnt =3
+let g:netrw_dirhist_cnt =8
let g:netrw_dirhist_1='/Users/apatterson/git/crazy/ext'
let g:netrw_dirhist_2='/Users/apatterson/git/crazy/ext/crazy'
let g:netrw_dirhist_3='/Users/apatterson/foo'
+let g:netrw_dirhist_4='/Users/apatterson/git/arel/lib/arel/visitors'
+let g:netrw_dirhist_5='/Users/apatterson/git/sqlite3-ruby/test'
+let g:netrw_dirhist_6='/Users/apatterson/git/rails/activerecord'
+let g:netrw_dirhist_7='/Users/apatterson/.vim'
+let g:netrw_dirhist_8='/Users/apatterson/.vim/plugin'
View
@@ -0,0 +1,14 @@
+function! GithubLink() range
+ let l:giturl = system('git config remote.origin.url')
+ let l:prefix = substitute(system('git rev-parse --show-prefix'), "\n", '', '')
+ let l:repo = get(split(matchstr(l:giturl, '\w*\/\w*\.git'), '\.'), 0)
+ let l:url = 'http://github.com/' . l:repo
+ let l:branch = get(split(substitute(system('git symbolic-ref HEAD'), "\n", '', '') , '/'), -1)
+ let l:filename = l:prefix . @%
+
+ let l:full = join([l:url, 'blob', l:branch, l:filename], '/')
+
+ let @* = l:full . '#L' . a:firstline . '-' . a:lastline
+endfunction
+
+vnoremap <silent> <Leader>gh :call GithubLink()<CR>

0 comments on commit 015d65e

Please sign in to comment.