Skip to content

Instantly share code, notes, and snippets.

@tyru
Created June 3, 2018 16:29
Show Gist options
  • Select an option

  • Save tyru/448cd0c5839236a2390be2e042b35dd0 to your computer and use it in GitHub Desktop.

Select an option

Save tyru/448cd0c5839236a2390be2e042b35dd0 to your computer and use it in GitHub Desktop.
:set buftype=prompt
function! s:run() abort
new
setlocal buftype=prompt
function! s:TextEntered(text)
if a:text == 'exit' || a:text == 'quit'
stopinsert
close
else
call append(line('$') - 1, 'Entered: "' . a:text . '"')
" Reset 'modified' to allow the buffer to be closed.
set nomodified
endif
endfunction
call prompt_setcallback(bufnr(''), function('s:TextEntered'))
call prompt_setprompt(bufnr(''), 'vimshell> ')
endfunction
call s:run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment