Controlling Zellij through the CLI

Zellij can be controlled through the CLI. Whether inside or outside a zellij session, one can issue commands from the terminal to interact with any session running on the machine.

eg.

$ zellij action new-pane

Commands can also be issued to a different Zellij session:

$ zellij --session pretentious-cat action new-pane

  • Zellij Run & Edit - Launch commands in new panes or open files in your default editor
  • Zellij Action - Full reference of all zellij action subcommands for controlling panes, tabs, layouts, and more
  • Zellij Plugin & Pipe - Load plugins and send data to them from the command line
  • Zellij Subscribe - Stream the rendered output of one or more panes to stdout in real time
  • Zellij Watch - Watch a session in read-only mode
  • CLI Recipes & Scripting - Task-oriented examples and common workflows for scripting with Zellij
  • Programmatic Control - Patterns for non-interactive, machine-driven control of Zellij sessions

Zellij Watch

The zellij watch command provides a read-only view of a session:

$ zellij watch my-session-name

This attaches to the specified session in read-only mode - the terminal output is visible but no input can be sent.


Completions

For convenience, zellij provides cli completions for popular shells.

You can dump these completions to STDOUT and then append them to your shell's configuration file with:

$ zellij setup --generate-completion fish
$ zellij setup --generate-completion bash
$ zellij setup --generate-completion zsh

These completions also include aliases for running a command in a new pane and editing a file in a new pane:

$ zr tail -f /path/to/my/file # open a new pane tailing this file
$ zrf htop # open a new floating pane with htop
$ ze ./main.rs # open a new pane with your editor (eg. vim) pointed at ./main.rs

See your shell's documentation for information on where to append these.