Created
September 17, 2017 22:12
-
-
Save coot/734cea2d71dcef0998b5fafcac64ddd3 to your computer and use it in GitHub Desktop.
Vim 8.1112 terminal helper
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
set tk=<C-L> | |
tmap <c-x> <c-l>:hide<cr> | |
tmap <c-w><c-x> <c-l>:bd!<cr> | |
" Find first terminal buffer | |
fun! TermBufNr() | |
redi => ls | |
filter #\v<(zsh|bash)># ls | |
redi END | |
let lines = split(ls, '\n') | |
if empty(lines) | |
return v:null | |
endif | |
let bnr = str2nr(get(split(lines[0]), 0, v:null)) | |
if empty(bnr) | |
return v:null | |
else | |
return bnr | |
endif | |
endfun | |
fun! Term() | |
let bnr = TermBufNr() | |
if empty(bnr) | |
term | |
else | |
exe "sb " . bnr | |
endif | |
endfun | |
com! Term call Term() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment