LayoutsTemplates and loading
No narration yet
Module 7 · Lesson 211 min

Templates and loading

Once your layouts get repetitive, factor the repetition into templates. A pane_template names a reusable pane; a tab_template names a reusable tab. Define once, then use the name like a built-in node.

A pane template
pane_template name="htop" {
    command "htop"
}

// then use it just by name:
// htop
A tab template with a sidebar
tab_template name="ranger-on-the-side" {
    pane size=1 borderless=true {
        plugin location="zellij:compact-bar"
    }
    pane split_direction="vertical" {
        pane command="ranger" size="20%"
        children
    }
}

There are three ways to load a layout. Give a path, give a bare name to pull one from your layouts directory, or give a URL (which Zellij will ask you to approve first). Applying a layout inside a running session adds new tabs rather than replacing what's there.

Loading layouts
zellij --layout /path/to/dev.kdl        # by path
zellij --layout dev                     # by name, from ~/.config/zellij/layouts
zellij --layout https://example.com/dev.kdl   # by URL (asks approval)
Practice

Try it yourself

Do

Install a layout you can load by name

Put a layout where Zellij can find it by name.

Tick every step to confirm you did it.

Recall

Recall the slot

Templates hinge on this.

In a tab_template, what does the children keyword do?