Skip to content

Instantly share code, notes, and snippets.

@coot
Created September 17, 2017 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coot/734cea2d71dcef0998b5fafcac64ddd3 to your computer and use it in GitHub Desktop.
Save coot/734cea2d71dcef0998b5fafcac64ddd3 to your computer and use it in GitHub Desktop.
Vim 8.1112 terminal helper
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