Skip to content

bronzehedwick/vim-primary-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Primary Terminal

Simple terminal management for Neovim.

Why another terminal manager?

I wanted something very minimal, that only took control of a single :terminal instance at a time; this served my use case well.

I prefer the flyweight simplicity of that approach, since 90% of the time I only want to interact with the same terminal instance.

If I do need another one, it's easy enough to create another un-managed :terminal, or a process-specific :e term://my-command.

Installation

If you're using a plugin manager, follow the instructions in their documentation.

For example, if you're using Packer, you would add the following to your configuration:

use 'bronzehedwick/vim-primary-terminal'

Otherwise, use native package support by cloning vim-primary-terminal to packpath.

git clone https://github.com/bronzehedwick/vim-primary-terminal \
    ${XDG_DATA_HOME:-$HOME/.local/share}/nvim/site/pack/plugins/start/vim-primary-terminal

Commands

vim-primary-terminal provides the following commands:

  • :PrimaryTerminalOpen: Open the primary terminal in the current window.
  • :PrimaryTerminalOpenSplit: Open the primary terminal in a horizontal split window.
  • :PrimaryTerminalOpenVsplit: Open the primary terminal in a vertical split window.
  • :T[!] {args}: Pass {args} to the primary terminal. If ! is passed, load the primary terminal in the preview window as well.
  • :Tkill: Kill the current process running in the primary terminal by sending Ctrl+c

Key mappings

vim-primary-terminal provides the following <Plug> mappings:

  • <Plug>(PrimaryTerminalOpen): Execute :PrimaryTerminalOpen
  • <Plug>(PrimaryTerminalOpenSplit): Execute :PrimaryTerminalOpenSplit
  • <Plug>(PrimaryTerminalOpenVsplit): Execute :PrimaryTerminalOpenVsplit
  • <Plug>(PrimaryTerminalOpenDynamic): Execute :PrimaryTerminalOpenDynamic

Using <Plug> allows you to customize if and what key sequences to map to.

However, if you don't have a preference, add the following mappings to your init.vim:

nmap <unique> <silent> <leader>t <Plug>(PrimaryTerminalOpen)
nmap <unique> <silent> <leader>r <Plug>(PrimaryTerminalOpenSplit)
nmap <unique> <silent> <leader>y <Plug>(PrimaryTerminalOpenVsplit)
nmap <unique> <silent> <leader>d <Plug>(PrimaryTerminalOpenDynamic)

See :help primary-terminal for more.

Similar projects

License

Copyright © 2019–2022 Chris DeLuca

Licensed under the same terms as Vim itself.