Created
October 20, 2009 08:37
-
-
Save Shougo/214112 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
" vimrcbox.vim | |
" Author: Sora harakami <sora134@gmail.com> | |
" Modified by: thinca <thinca@gmail.com> thanks! | |
" Modified by: Shougo <Shougo.Matsu@gmail.com> thanks! | |
" Require: curl | |
" Licence: MIT Licence | |
if exists('g:loaded_vimrcbox') | |
finish | |
endif | |
let g:loaded_vimrcbox = 1 | |
let s:save_cpo = &cpo | |
set cpo&vim | |
if !exists('g:vimrcbox_user') | |
let g:vimrcbox_user = '' | |
endif | |
if !exists('g:vimrcbox_pass') | |
let g:vimrcbox_pass = '' | |
endif | |
if !exists('g:vimrcbox_vimrc') | |
let g:vimrcbox_vimrc = '' | |
endif | |
if !exists('g:vimrcbox_gvimrc') | |
let g:vimrcbox_gvimrc = '' | |
endif | |
if !exists('g:vimrcbox_baseurl') | |
let g:vimrcbox_baseurl = 'http://soralabo.net/s/vrcb/' | |
endif | |
function! s:VrbUpdate(postfile, gvim) | |
if !executable('curl') | |
echoerr 'This script needs "curl". Please install.' | |
endif | |
let user = (g:vimrcbox_user)? g:vimrcbox_user : input("Username: ") | |
let pass = (g:vimrcbox_pass)? g:vimrcbox_pass : inputsecret("Password: ") | |
if user == '' || pass == '' | |
echo "Cancel" | |
return | |
endif | |
if a:postfile != '' | |
let postfile = a:postfile | |
else | |
let postfile = a:gvim ? | |
\(g:vimrcbox_gvimrc != '' ? g:vimrcbox_gvimrc : $MYGVIMRC) | |
\: (g:vimrcbox_vimrc != '' ? g:vimrcbox_vimrc : $MYVIMRC) | |
endif | |
"post | |
let result = system('curl -s ' . join(values(map({ | |
\ 'vimrc': '@' . fnamemodify(expand(postfile), ':p'), | |
\ 'user': user, | |
\ 'pass': pass, | |
\ 'gvim': a:gvim, | |
\ }, '"-F " . shellescape(v:key . "=" . v:val)')), ' ') | |
\ . ' ' . shellescape(g:vimrcbox_baseurl . 'api/register')) | |
if result =~ '1' | |
echo "Update success" | |
else | |
echo "Update failure" | |
end | |
endfunction | |
command! -nargs=? -complete=file RcbVimrc call s:VrbUpdate(<q-args>, 0) | |
command! -nargs=? -complete=file RcbGVimrc call s:VrbUpdate(<q-args>, 1) | |
let &cpo = s:save_cpo | |
unlet s:save_cpo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment