Last active
April 2, 2022 21:52
-
-
Save da99/576c3e179ce1795c7b1c9a7db7b43d4f to your computer and use it in GitHub Desktop.
Close NeoVim terminal on Exit 0 (successful exit), but keep it open when the command/shell exits with a failure.
This file contains 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
" Start terminal in insert mode: | |
autocmd TermOpen * IndentLinesDisable | startinsert | |
" In NeoVim, lookup `terminal-status` | |
:help terminal-status | |
"This will give you information on how to auto-close the terminal on succesful exit: | |
" | |
" From the Neovim help documentation: | |
"- The TermClose event gives the terminal job exit code in the v:event | |
" "status" field. For example, this autocmd closes terminal buffers if the job | |
" exited without error: | |
" autocmd TermClose * if !v:event.status | exe 'bdelete! '..expand('<abuf>') | endif | |
" | |
autocmd TermClose * if !v:event.status | exe 'bdelete! '..expand('<abuf>') | endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment