Created
July 14, 2014 16:12
-
-
Save skahack/17fd66bf0d15dfa5d547 to your computer and use it in GitHub Desktop.
open a GitHub page
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
function! g:open_github() "{{{ | |
let commit = system("git rev-parse HEAD") | |
let commit = substitute(commit, '^[ \t\n]\+', '', 'g') | |
let commit = substitute(commit, '[ \t\n]\+$', '', 'g') | |
let top = system('git rev-parse --show-toplevel') | |
let top = substitute(top, '^[ \t\n]\+', '', 'g') | |
let top = substitute(top, '[ \t\n]\+$', '', 'g') | |
let filepath = expand('%:p') | |
let path = substitute(filepath, top, '', 'g') | |
silent exec(join(['!hub browse -- tree/', commit, path], '')) | |
redraw! | |
endfunction "}}} | |
command! OpenGithubFile call g:open_github() | |
nmap <Space>g :OpenGithubFile<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment