Requirements

My requirements for a terminal multiplexer:

  • Organization of workspaces using sessions
    • Quickly create vertical and horizontal panes
    • Seamless movement between my editor and my terminals
    • Seamless integration with neovim
  • Switch sessions effectively
    • Single keybind to switch between sessions
    • Use a list of known workspaces as input to start/switch sessions

Learning Zellij

Zellij’s introduces modes similar to vi where each mode has its own separate keybindings, for more info about the modes read https://zellij.dev/documentation/keybindings-modes.html

I mapped Ctrl + Space to enter switch from Normal mode to Tmux mode and back.

Organization of workspaces using sessions

I mapped Ctrl + Space+- to create a horizontal pane and Ctrl + Space+\ to create a vertical pane.

Because of the different modes that zellij has I also use the zellij-autolock plugin to provide a single keybind combination to move across panes, while this is possible to do with zellij without plugins the plugin is needed for zellij to be aware of switching modes when entering a pane running a program.

My zellij-autolock setup is very similar to the one in the repo .

Neovim needs to be aware of the plugin, fortunately, the same author created zellij.vim which I included through my preferred package manager.

Single keybind launcher to switch sessions

Demo of switching sessions with Zellij

I want a system that helps me find my preferred session to launch or to switch too, the sessions to display are my preferred list of sessions and the currently opened sessions, After I make the selection in the fuzzy finder, I want to switch to that session.

With tmux, I have this setup with this one liner:

# This is a simplified version of my setup, it doesn't run it as it is.
( cat $bookmarks && tmux ls ) | fzf --tmux | xargs tmux switch-client -t

Zellij doesn’t have a subcommand similar to tmux switch-client. There’s this reddit thread where Zellij’s author mention that the way to do this is with a plugin. Fortunately, the plugin zellij-switch already does this.

# This is a simplified version of my setup, it doesn't run it as it is.
( cat $bookmarks && zellij list-sessions -n ) | fzf | \
  xargs -I {} zellij pipe --plugin https://github.com/mostafaqanbaryan/zellij-switch/releases/download/0.2.1/zellij-switch.wasm \
  -- "session $(basename {}) --cwd {} --layout default"

I map the above the the keybinding Ctrl + Space+Ctrl J with the following zellij config.

        bind "Ctrl j" {
            SwitchToMode "normal";
            Run "zellij-switch-session" {
                direction "Down";
                close_on_exit true;
            }
        }

zellij-switch-session is a bash script that wraps the above one zellij one liner.