diff --git a/.gitmodules b/.gitmodules index f264152..6be80c1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "vim/.vim/bundle/fugitive"] path = vim/.vim/bundle/fugitive url = https://github.com/tpope/vim-fugitive +[submodule "vim/.vim/bundle/eunuch"] + path = vim/.vim/bundle/eunuch + url = https://github.com/tpope/vim-eunuch diff --git a/vim/.vim/bundle/eunuch b/vim/.vim/bundle/eunuch new file mode 160000 index 0000000..dcd29a0 --- /dev/null +++ b/vim/.vim/bundle/eunuch @@ -0,0 +1 @@ +Subproject commit dcd29a00eb708be211d856afd3fddfbff7bc6208 diff --git a/vim/.vim/bundle/eunuch/README.markdown b/vim/.vim/bundle/eunuch/README.markdown deleted file mode 100644 index 5f64b06..0000000 --- a/vim/.vim/bundle/eunuch/README.markdown +++ /dev/null @@ -1,52 +0,0 @@ -# eunuch.vim - -Vim sugar for the UNIX shell commands that need it the most. Features -include: - -* `:Remove`: Delete a buffer and the file on disk simultaneously. -* `:Unlink`: Like `:Remove`, but keeps the now empty buffer. -* `:Move`: Rename a buffer and the file on disk simultaneously. -* `:Rename`: Like `:Move`, but relative to the current file's containing directory. -* `:Chmod`: Change the permissions of the current file. -* `:Mkdir`: Create a directory, defaulting to the parent of the current file. -* `:Find`: Run `find` and load the results into the quickfix list. -* `:Locate`: Run `locate` and load the results into the quickfix list. -* `:Wall`: Write every open window. Handy for kicking off tools like [guard][]. -* `:SudoWrite`: Write a privileged file with `sudo`. -* `:SudoEdit`: Edit a privileged file with `sudo`. -* File type detection for `sudo -e` is based on original file name. -* New files created with a shebang line are automatically made executable. -* New init scripts are automatically prepopulated with `/etc/init.d/skeleton`. - -[guard]: https://github.com/guard/guard - -## Installation - -If you don't have a preferred installation method, I recommend -installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and -then simply copy and paste: - - cd ~/.vim/bundle - git clone git://github.com/tpope/vim-eunuch.git - -Once help tags have been generated, you can view the manual with -`:help eunuch`. - -## Contributing - -See the contribution guidelines for -[pathogen.vim](https://github.com/tpope/vim-pathogen#readme). - -## Self-Promotion - -Like eunuch.vim? Follow the repository on -[GitHub](https://github.com/tpope/vim-eunuch) and vote for it on -[vim.org](http://www.vim.org/scripts/script.php?script_id=4300). And if -you're feeling especially charitable, follow [tpope](http://tpo.pe/) on -[Twitter](http://twitter.com/tpope) and -[GitHub](https://github.com/tpope). - -## License - -Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. -See `:help license`. diff --git a/vim/.vim/bundle/eunuch/plugin/eunuch.vim b/vim/.vim/bundle/eunuch/plugin/eunuch.vim deleted file mode 100644 index 2dab31c..0000000 --- a/vim/.vim/bundle/eunuch/plugin/eunuch.vim +++ /dev/null @@ -1,213 +0,0 @@ -" eunuch.vim - Helpers for UNIX -" Maintainer: Tim Pope -" Version: 1.1 - -if exists('g:loaded_eunuch') || &cp || v:version < 700 - finish -endif -let g:loaded_eunuch = 1 - -function! s:fnameescape(string) abort - if exists('*fnameescape') - return fnameescape(a:string) - elseif a:string ==# '-' - return '\-' - else - return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','') - endif -endfunction - -function! s:separator() - return !exists('+shellslash') || &shellslash ? '/' : '\\' -endfunction - -command! -bar -bang Unlink - \ if 1 && &modified | - \ edit | - \ elseif delete(expand('%')) | - \ echoerr 'Failed to delete "'.expand('%').'"' | - \ else | - \ edit! | - \ endif - -command! -bar -bang Remove - \ let s:file = fnamemodify(bufname(),':p') | - \ execute 'bdelete' | - \ if !bufloaded(s:file) && delete(s:file) | - \ echoerr 'Failed to delete "'.s:file.'"' | - \ endif | - \ unlet s:file - -command! -bar -nargs=1 -bang -complete=file Move : - \ let s:src = expand('%:p') | - \ let s:dst = expand() | - \ if isdirectory(s:dst) || s:dst[-1:-1] =~# '[\\/]' | - \ let s:dst .= (s:dst[-1:-1] =~# '[\\/]' ? '' : s:separator()) . - \ fnamemodify(s:src, ':t') | - \ endif | - \ if !isdirectory(fnamemodify(s:dst, ':h')) | - \ call mkdir(fnamemodify(s:dst, ':h'), 'p') | - \ endif | - \ let s:dst = substitute(simplify(s:dst), '^\.\'.s:separator(), '', '') | - \ if 1 && filereadable(s:dst) | - \ exe 'keepalt saveas '.s:fnameescape(s:dst) | - \ elseif rename(s:src, s:dst) | - \ echoerr 'Failed to rename "'.s:src.'" to "'.s:dst.'"' | - \ else | - \ setlocal modified | - \ exe 'keepalt saveas! '.s:fnameescape(s:dst) | - \ if s:src !=# expand('%:p') | - \ execute 'bwipe '.s:fnameescape(s:src) | - \ endif | - \ endif | - \ unlet s:src | - \ unlet s:dst | - \ filetype detect - -function! s:Rename_complete(A, L, P) abort - let sep = s:separator() - let prefix = expand('%:p:h').sep - let files = split(glob(prefix.a:A.'*'), "\n") - call filter(files, 'simplify(v:val) !=# simplify(expand("%:p"))') - call map(files, 'v:val[strlen(prefix) : -1] . (isdirectory(v:val) ? sep : "")') - return join(files + ['..'.s:separator()], "\n") -endfunction - -command! -bar -nargs=1 -bang -complete=custom,s:Rename_complete Rename - \ Move %:h/ - -command! -bar -nargs=1 Chmod : - \ echoerr get(split(system('chmod '..' '.shellescape(expand('%'))), "\n"), 0, '') | - -command! -bar -bang -nargs=? -complete=dir Mkdir - \ call mkdir(empty() ? expand('%:h') : , 0 ? 'p' : '') | - \ if empty() | - \ silent keepalt execute 'file' s:fnameescape(expand('%')) | - \ endif - -command! -bar -bang -complete=file -nargs=+ Find exe s:Grep(, , 'find') -command! -bar -bang -complete=file -nargs=+ Locate exe s:Grep(, , 'locate') -function! s:Grep(bang,args,prg) abort - let grepprg = &l:grepprg - let grepformat = &l:grepformat - let shellpipe = &shellpipe - try - let &l:grepprg = a:prg - setlocal grepformat=%f - if &shellpipe ==# '2>&1| tee' || &shellpipe ==# '|& tee' - let &shellpipe = "| tee" - endif - execute 'grep! '.a:args - if empty(a:bang) && !empty(getqflist()) - return 'cfirst' - else - return '' - endif - finally - let &l:grepprg = grepprg - let &l:grepformat = grepformat - let &shellpipe = shellpipe - endtry -endfunction - -function! s:SudoSetup(file) abort - if !filereadable(a:file) && !exists('#BufReadCmd#'.s:fnameescape(a:file)) - execute 'autocmd BufReadCmd ' s:fnameescape(a:file) 'call s:SudoReadCmd()' - endif - if !filewritable(a:file) && !exists('#BufWriteCmd#'.s:fnameescape(a:file)) - execute 'autocmd BufReadPost ' s:fnameescape(a:file) 'set noreadonly' - execute 'autocmd BufWriteCmd ' s:fnameescape(a:file) 'call s:SudoWriteCmd()' - endif -endfunction - -function! s:SudoReadCmd() abort - silent %delete_ - let pipe = printf(&shellpipe . (&shellpipe =~ '%s' ? '' : ' %s'), '/dev/null') - execute (has('gui_running') ? '' : 'silent') 'read !env SUDO_EDITOR=cat VISUAL=cat sudo -e "%" ' . pipe - silent 1delete_ - set nomodified -endfunction - -function! s:SudoWriteCmd() abort - execute (has('gui_running') ? '' : 'silent') 'write !env SUDO_EDITOR=tee VISUAL=tee sudo -e "%" >/dev/null' - let &modified = v:shell_error -endfunction - -command! -bar -bang -complete=file -nargs=? SudoEdit - \ call s:SudoSetup(fnamemodify(empty() ? expand('%') : , ':p')) | - \ if !&modified || !empty() | - \ edit | - \ endif | - \ if empty() || expand('%:p') ==# fnamemodify(, ':p') | - \ set noreadonly | - \ endif - -if exists(':SudoWrite') != 2 -command! -bar SudoWrite - \ call s:SudoSetup(expand('%:p')) | - \ write! -endif - -function! s:SudoEditInit() abort - let files = split($SUDO_COMMAND, ' ')[1:-1] - if len(files) ==# argc() - for i in range(argc()) - execute 'autocmd BufEnter' s:fnameescape(argv(i)) - \ 'if empty(&filetype) || &filetype ==# "conf"' - \ '|doautocmd filetypedetect BufReadPost' s:fnameescape(files[i]) - \ '|endif' - endfor - endif -endfunction -if $SUDO_COMMAND =~# '^sudoedit ' - call s:SudoEditInit() -endif - -command! -bar -nargs=? Wall - \ if empty() | - \ call s:Wall() | - \ else | - \ call system('wall', ) | - \ endif -if exists(':W') !=# 2 - command! -bar W Wall -endif -function! s:Wall() abort - let tab = tabpagenr() - let win = winnr() - let seen = {} - if !&readonly && expand('%') !=# '' - let seen[bufnr('')] = 1 - write - endif - tabdo windo if !&readonly && &buftype =~# '^\%(acwrite\)\=$' && expand('%') !=# '' && !has_key(seen, bufnr('')) | silent write | let seen[bufnr('')] = 1 | endif - execute 'tabnext '.tab - execute win.'wincmd w' -endfunction - -augroup eunuch - autocmd! - autocmd BufNewFile * let b:brand_new_file = 1 - autocmd BufWritePost * unlet! b:brand_new_file - autocmd BufWritePre * - \ if exists('b:brand_new_file') | - \ if getline(1) =~ '^#!' | - \ let b:chmod_post = '+x' | - \ endif | - \ endif - autocmd BufWritePost,FileWritePost * nested - \ if exists('b:chmod_post') && executable('chmod') | - \ silent! execute '!chmod '.b:chmod_post.' ""' | - \ edit | - \ unlet b:chmod_post | - \ endif - - autocmd BufNewFile */init.d/* - \ if filereadable("/etc/init.d/skeleton") | - \ keepalt read /etc/init.d/skeleton | - \ 1delete_ | - \ endif | - \ set ft=sh -augroup END - -" vim:set sw=2 sts=2: