Zellij, an alternative to screen and tmux

Posted December 5, 2021 by Adrian Wyssmann ‐ 3 min read

Terminal window managers are very helpful. I found Zellij, which seems to be a very nice alternative to tmux and screen

In Linux, terminal window managers improve the work on the shell by allowing to have persistency, multiplex a terminal window and session sharing. Most prominent screen managers are screen - released in 1987, tmux - released in 2007, and byobu - released in 2009.

  • Persistency: When a network connection is dropped, it typically terminates all programs the user was running (child processes of the login session). With a terminal manager this does not happen, but rather the session is just detached, which allows you to reattach the session later and continue working from where they left off. This is especially useful if you are working on a unstable network connection.
  • Multiple Windows: Basically, you open a single window on a terminal, from where you could create new windows or split the window in multiple areas. Programs in the window(s) run independently of each other and also run in the background, even so the window is not visible. The programs also run when the whole session is detached from the user’s terminal, as mentioned above.
  • Session Sharing: Multiple computers can connext to the same session at once, enabling collaboration for multiple users.

While I personally use tmux, I always struggle to remember the keystrokes necessary to navigate among the windows, I found with zellij a nice alternative which makes the usage imho very easy. It offers the following features:

  • panes and tabs: You can split your terminal in different panes and tabs
  • layout engine: You can define a map of panes in a yaml file and load it when Zellij starts
  • plugins: Zellij can be extend by plugins - however currently there are not much available

Nevertheless, if you have a look at the interface it’s pretty clear how you can work with Zellij, when you are using the default layout:

zellij with multiple tabs and panes
zellij with multiple tabs and panes

The default layout takes use of the tab-bar and status-bar plugins:

zellij setup --dump-layout default
---
template:
  direction: Horizontal
  parts:
    - direction: Vertical
      borderless: true
      split_size:
        Fixed: 1
      run:
        plugin:
          location: "zellij:tab-bar"
    - direction: Vertical
      body: true
    - direction: Vertical
      borderless: true
      split_size:
        Fixed: 2
      run:
        plugin:
          location: "zellij:status-bar"
tabs:
  - direction: Vertical

Based on this, you can extend the layout definition and do something like this

---
template:
  direction: Horizontal
  parts:
    - direction: Vertical  # part 1
      borderless: true
      split_size:
        Fixed: 1
      run:
        plugin:
          location: "zellij:tab-bar"
    - direction: Vertical # part 2
      body: true
    - direction: Vertical # part 3
      borderless: true
      split_size:
        Fixed: 2
      run:
        plugin:
          location: "zellij:status-bar"
tabs:
  - name: "tab 1" # tab 1
  - name: "tab 2" # tab 2
    direction: Vertical
    parts:
      - direction: Horizontal
      - direction: Horizontal
  - name: "tab 3" # tab 3
    direction: Vertical
    parts:
      - direction: Horizontal
      - direction: Horizontal
        parts:
          - direction: Horizontal
          - direction: Vertical

So if you go to tab 3 you would see this arrangement:

example pane 1, tab 3
Layout of tab 3 form the example above

You can also customize the keybindings and the apperance aka themes. As you see, it’s a nice alternative to tmux so you might give it a try.