Skip to content

Instantly share code, notes, and snippets.

@jimsynz
Created April 3, 2012 02:04
Show Gist options
  • Save jimsynz/2288773 to your computer and use it in GitHub Desktop.
Save jimsynz/2288773 to your computer and use it in GitHub Desktop.
" Function which runs a command using ConqueTerm in the
" current or split buffer.
" If no command is given it just runs bash.
function! RunCommandInBuffer(where,...)
" Can split the buffer if you want.
if a:where == 'new'
exec ':new'
elseif a:where == 'vnew'
exec ':vnew'
end
" run a shell if no other arguments are supplied
if a:0 == 0
exec ':ConqueTerm bash'
else
exec ':ConqueTerm ' . join(a:000, ' ')
endif
endfunction
" User commands to call RunCommandInBuffer nicely.
command! -nargs=* Exec :call RunCommandInBuffer('here',<f-args>)
command! -nargs=* SplitExec :call RunCommandInBuffer('new',<f-args>)
command! -nargs=* VSplitExec :call RunCommandInBuffer('vnew',<f-args>)
" Command Aliases via cmdalias:
call CmdAlias('exec', 'Exec')
call CmdAlias('splitexec', 'SplitExec')
call CmdAlias('vsplitexec', 'VSplitExec')
call CmdAlias('se', 'SplitExec')
call CmdAlias('vse', 'VSplitExec')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment