vmux logo

Discord Crates.io

Helper to use vim/neovim as a terminal multiplexer

video demos

Neovim conf '22 presentation session switching CLI + functionalities inside vim

docker demo

docker run -it yazgoo/vmux:master (more info on how to use it, based on Dockerfile)

install

You will need rust and cargo installed.

Install the plugin with post-update hook to install vmux crate:

with vim-plug

vim Plug 'yazgoo/vmux', {'do': 'cargo install vmux' }

with lazy.nvim

lua { 'yazgoo/vmux', build = 'cargo install vmux' }

with packer.nvim

lua use { 'yazgoo/vmux', run = 'cargo install vmux' }

Add the following to your .zshrc or .bashrc (replace <your_editor> with vim or nvim (default)).
(For vim you'll need it compiled with +clientserver flag)

with vim-plug

bash source ~/.config/nvim/plugged/vmux/plugin/setup_vmux.sh <your_editor>

with lazy.nvim

bash source ~/.local/share/nvim/lazy/vmux/plugin/setup_vmux.sh <your_editor>

with packer.nvim

bash source ~/.local/share/nvim/site/pack/packer/start/vmux/plugin/setup_vmux.sh <your_editor>

Note: if you are using Fish shell, consider using bass with the following added to config.fish:

fish bass source <path-to-setup_vmux.sh> <your_editor>

usage

interactive usage

video demo

vmux new or vmux will start vmux in interactive mode. You'll be prompted to:

You can leave current session with CTRL+g. (you can change default escape key from CTRL+g (with -e a) to CTRL+a ).

usage within vim/neovim

video demo

Within vim, vmux provides integration between vim and terminal. Run :help vmux from within vim for more info. Here is an example configuration.

cli usage

customizing

For an optimal experience, you should at least add list_sessions_names and session_name hook files described below.

Both files must be executable (if they are a script, they should have a shebang).

list sessions names

You can define a list of new session names via ~/.config/vmux/hooks/list_sessions_names The script just needs to output session names one per line, see this for an example.

session setup

You can define a custom way to setup a new session via ~/.config/vmux/hooks/session_name.
The script takes the session name as argument and should print environment variables of the form key=value.

For example, this script will print the content of .envrc and set working directory to ~/dev/$1 (via PWD line).

wallpaper

You can put images which will be used as wallpapers inside ~/.config/vmux/wallpapers/.

detach / attach callbacks

You can define callbacks on attach / detach session. For example, to share data between (n)vim instances (including registers content), you can use shared data files (Shada), by adding in your vim conf:

```vim function! VmuxCustomDetachCallback() wshada endfunction

function! VmuxCustomAttachCallback() rshada endfunction ```

you can get info about current session via the following env var: