Skip to content

Instantly share code, notes, and snippets.

@elijahmanor
Last active December 19, 2023 17:49
Show Gist options
  • Save elijahmanor/19832f408c91fa9307a2c0e34cd4a632 to your computer and use it in GitHub Desktop.
Save elijahmanor/19832f408c91fa9307a2c0e34cd4a632 to your computer and use it in GitHub Desktop.
Zellij FAQs

Zellij FAQs

Zellij doesn't seem to work in iTerm2

It does work, but you need to update your Profiles → Keys → General → Left Option key: to Esc+

Screenshot 2023-03-08 at 2 42 18 PM

Can I script a Zellij session and automatically create panes with commands?

Yes, you can create a custom layout and define your own panes and commands.

There is a great tutorial with a video that you can follow that shows you how.

As an example, I created the following kdl file...

layout.kdl

layout {
  pane size=1 borderless=true {
    plugin location="zellij:tab-bar"
  }
  pane split_direction="vertical" {
    pane edit="README.md"
    pane split_direction="horizontal" {
      pane command="cowsay" {
        args "Hello, world!"
      }
      pane command="archey"
      pane command="exa" {
        args "--long"
        args "--header"
        args "--git"
        args "--icons"
      }
    }
  }
  pane size=2 borderless=true {
    plugin location="zellij:status-bar"
  }
}

And assuming you had the above layout.kdl file, you could run something like...

zellij --layout layout.kdl

And the result would be like the following...

Screenshot 2023-03-08 at 3 41 32 PM

How can Zellij and Neovim exist together?

The simpliest way to help zellij not conflict with existing Neovim bindings is to lock the interface with Ctrl + g when using Neovim.

Or you could adjust your keybindings to not use things such as Ctrl + p and Ctrl + n which I heavily use when navigating up and down through lists.

I've seen some go the extra mile and create a custom layout to handle forcing a locked primary tab that is meant for editing. You an look for inspiration from the following reddit post. His editor.kdl file binds the Insert key to swap between tabs and locks or unlocks the tab.

Some others have changed most of the Ctrl- bindings to Alt- instead, which is much less likely to conflict with existing vim or neovim keymaps. See the following for what that could look like.

  normal {
      bind "Alt n" { NewPane; }

      bind "Alt H" { MovePane "Left"; }
      bind "Alt L" { MovePane "Right"; }
      bind "Alt J" { MovePane "Down"; }
      bind "Alt K" { MovePane "Up"; }

      bind "Alt Right" { GoToNextTab; }
      bind "Alt Left" { GoToPreviousTab; }

      bind "Alt f" { ToggleFocusFullscreen; }
      bind "Alt 1" { GoToTab 1; SwitchToMode "Normal"; }
      bind "Alt 2" { GoToTab 2; SwitchToMode "Normal"; }
      bind "Alt 3" { GoToTab 3; SwitchToMode "Normal"; }
      bind "Alt 4" { GoToTab 4; SwitchToMode "Normal"; }
      bind "Alt 5" { GoToTab 5; SwitchToMode "Normal"; }
      bind "Alt 6" { GoToTab 6; SwitchToMode "Normal"; }
      bind "Alt 7" { GoToTab 7; SwitchToMode "Normal"; }
      bind "Alt w" { ToggleFloatingPanes; SwitchToMode "Normal"; }
    }

I saw another technique of leaning on the tmux mode and remapped keys in Alacritty since zellij is limited in what keys it can detect.

All that said, the zellij maintainers are aware that this is not ideal, but I'm not sure how or when that will be addressed.

How do I make the UI more minimal?

You can launch zellij with the compact layout using the following: ``zellij --layout compact`.

While you are using zellij, you can disable pane frames by hitting the Ctrl + <p> + <z> keycombo.

If you like these settings, you can make them the default in your zellij config file (see options doc).

default_layout "compact"
pane_frames false

If you don't already have a config, you can create one with the following command:

 zellij setup --dump-config > ~/.config/zellij/config.kdl

@marcelarie
Copy link

Wow thanks for all the info!!

@marcelarie
Copy link

marcelarie commented Mar 23, 2023

On the → How can Zellij and Neovim exist together?

Some others have changed most of the Ctrl- bindings to Alt- instead, which is much less likely to conflict with existing vim or neovim keymaps. See the following for what that could look like.

Do you know how this can be done?
Do I need to manually change all the key binds, or can I use something like zellij_leader = Cntrl + Space ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment