Skip to content

Commit

Permalink
add vim shell-out function
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Pearson committed Apr 17, 2012
1 parent 751b4f2 commit 9ef332e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions vimrc
Expand Up @@ -44,3 +44,23 @@ set guifont=Inconsolata-g:h14

" CTRLP customization
let g:ctrlp_working_path_mode = 0

command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
echo a:cmdline
let expanded_cmdline = a:cmdline
for part in split(a:cmdline, ' ')
if part[0] =~ '\v[%#<]'
let expanded_part = fnameescape(expand(part))
let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '')
endif
endfor
botright new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
call setline(1, 'You entered: ' . a:cmdline)
call setline(2, 'Expanded Form: ' .expanded_cmdline)
call setline(3,substitute(getline(2),'.','=','g'))
execute '$read !'. expanded_cmdline
setlocal nomodifiable
1
endfunction

0 comments on commit 9ef332e

Please sign in to comment.