### Setup Zellij Configuration Directory and File Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/configuration.md This command creates the Zellij configuration directory and dumps the default configuration file into it. This is a common starting point for customizing Zellij. ```bash mkdir ~/.config/zellij zellij setup --dump-config > ~/.config/zellij/config.kdl ``` -------------------------------- ### Zellij CLI Command Examples Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/commands.html This section provides examples of how to invoke Zellij commands from the command line. It demonstrates the basic syntax for commands like `attach`, `list-sessions`, `kill-sessions`, `kill-all-sessions`, `options`, and `setup`, along with their short aliases. ```bash # Attach to a session zellij attach [session-name] zellij a [session-name] # List all running sessions zellij list-sessions zellij ls # Kill a specific session zellij kill-sessions [target-session] zellij k [target-session] # Kill all running sessions zellij kill-all-sessions zellij ka # Configure options zellij options # Setup utilities zellij setup ``` -------------------------------- ### Zellij Layout Configuration Example (Zellij Script) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/layouts-with-config.md An example demonstrating how to define a Zellij layout including pane arrangements and keybindings. This configuration allows for custom UI setups and command shortcuts within Zellij sessions. ```zellij-script layout { pane split_direction="vertical" { pane pane split_direction="horizontal" { pane pane } } pane size=1 borderless=true { plugin location="zellij:compact-bar" } } keybinds { shared { bind "Alt 1" { Run "git" "status"; } bind "Alt 2" { Run "git" "diff"; } bind "Alt 3" { Run "exa" "--color" "always"; } } } ``` -------------------------------- ### Start Zellij Web Server from CLI (Shell) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/web-client.html This command starts the Zellij web server from the command-line interface. The web server enables users to share existing Zellij sessions or start new ones through a web browser, providing secure remote access. ```shell $ zellij web ``` -------------------------------- ### Extract and Run Zellij Binary Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/installation.md Steps to download, extract, and make a prebuilt Zellij binary executable. This method is suitable for Linux and macOS users when direct package installation is not available. It involves downloading a tarball, extracting it, setting execute permissions, and optionally adding to the PATH. ```bash tar -xvf zellij*.tar.gz chmod +x zellij ./zellij ``` -------------------------------- ### Zellij Layout Configuration Example Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/layouts-with-config.html Demonstrates a Zellij layout file that includes pane arrangements, UI elements like the compact-bar plugin, and custom keybindings for running commands. ```zellij-layout layout { pane split_direction="vertical" { pane pane split_direction="horizontal" { pane pane } } pane size=1 borderless=true { plugin location="zellij:compact-bar" } } keybinds { shared { bind "Alt 1" { Run "git" "status"; } bind "Alt 2" { Run "git" "diff"; } bind "Alt 3" { Run "exa" "--color" "always"; } } } ``` -------------------------------- ### Applying a Zellij Layout via Command Line Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/layouts.html Demonstrates how to apply a Zellij layout file from the command line. This can be done when starting Zellij or within a running session. ```bash $ zellij --layout /path/to/layout_file.kdl ``` -------------------------------- ### Start Zellij Without Loading Default Configuration Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/configuration.md This command launches Zellij without applying any configuration from the default directories. This is useful for testing or running with a minimal setup. ```bash zellij options --clean ``` -------------------------------- ### Loading a Theme from Command Line Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/themes.html Demonstrates how to load a Zellij theme directly from the command line when starting a new session. This is an alternative method for applying themes. ```bash zellij options --theme [NAME] ``` -------------------------------- ### Plugin API Configuration Examples Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/plugin-api-configuration.html Demonstrates how to configure Zellij plugins using an arbitrary key/value list. Configuration can be provided either directly within the layout file or via the command line interface. This allows for customization of plugin behavior when they are instantiated. ```zellij-config pane { plugin location="file:/path/to/my/plugin.wasm" { some_key "some_value" another_key 1 } } ``` ```bash zellij action launch-or-focus-plugin --configuration "some_key=some_value,another_key=1" ``` -------------------------------- ### Zellij Configuration Bindings Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/keybindings-possible-actions.html Examples of Zellij key bindings for various actions. These configurations map keyboard shortcuts to specific Zellij commands. ```zellij bind "a" { Clear; } bind "a" { CloseFocus; } bind "a" { CloseTab; } bind "a" { Detach; } bind "a" { DumpScreen "/tmp/my-dump.txt"; } bind "a" { EditScrollback; } bind "a" { FocusNextPane; } bind "a" { FocusPreviousPane; } bind "a" { GoToNextTab; } bind "a" { GoToPreviousTab; } bind "a" { GoToTab 1; } bind "a" { HalfPageScrollDown; } bind "a" { HalfPageScrollUp; } bind "a" { LaunchOrFocusPlugin "zellij:strider" { floating true } } ``` -------------------------------- ### Zellij Pane Configuration Examples Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/creating-a-layout.html Illustrates various ways to define 'pane' nodes in a Zellij layout file using KDL syntax. Covers bare panes, panes with commands, and panes with nested configurations. ```kdl layout { pane // panes can be bare pane command="htop" // panes can have arguments on the same line pane { // panes can have arguments inside child-braces command "exa" cwd "/" } pane command="ls" { // or a mixture of same-line and child-braces arguments cwd "/" } } ``` -------------------------------- ### Applying Zellij Layouts via Command Line Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/print.html Examples of how to apply a Zellij layout file from the command line, including local paths and remote URLs. Remote layouts have security restrictions. ```bash $ zellij --layout /path/to/layout_file.kdl ``` ```bash $ zellij --layout https://example.com/layout_file.kdl ``` -------------------------------- ### Zellij Setup Command Options Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/commands.html This section details the options available for the `zellij setup` command, which assists with Zellij's configuration. It includes flags for checking configuration, cleaning setup, dumping default configuration or layouts, and generating shell completions. ```bash # Check the configuration zellij setup --check # Start with default configuration zellij setup --clean # Dump the default configuration file to stdout zellij setup --dump-config # Dump a specified default layout file to stdout zellij setup --dump-layout [LAYOUT] # Generate completions for the specified shell zellij setup --generate-completion [SHELL] ``` -------------------------------- ### Install Zellij using Cargo or Binary Source: https://context7.com/zellij-org/zellij-org.github.io/llms.txt Instructions for installing Zellij via Cargo, cargo-binstall for faster pre-built binaries, or by downloading and extracting a binary archive. ```bash # Install via Cargo cargo install --locked zellij # Install via cargo-binstall (faster, pre-built binary) cargo binstall zellij # Binary download and install tar -xvf zellij*.tar.gz chmod +x zellij ./zellij ``` -------------------------------- ### Basic KDL Layout Example Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/layouts.html A simple KDL layout defining a pane and a split pane with a command. This demonstrates the basic structure for arranging panes and tabs in Zellij. ```kdl // layout_file.kdl layout { pane pane split_direction="vertical" { pane pane command="htop" } } ``` -------------------------------- ### Zellij CLI Flag Examples Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/commands.html This section outlines the global command-line flags available for Zellij. It shows how to use flags like `--help`, `--debug`, and `--version` to get information or modify Zellij's behavior. ```bash # Display help information zellij --help # Gather additional debug information zellij --debug # Print version information zellij --version ``` -------------------------------- ### Zellij Run Command Example Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/zellij-run.html Demonstrates how to use the 'zellij run' command to launch a new Zellij pane that executes a specified command, such as 'git diff'. This functionality allows users to run commands within isolated panes. ```bash $ zellij run -- git diff ``` -------------------------------- ### Zellij Pipe Command Usage Examples Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/zellij-pipe.html Demonstrates various ways to use the 'zellij pipe' command for inter-plugin communication. It shows how to send data to a specific plugin by URL, to all running plugins, and how to pipe data from STDIN to STDOUT through a plugin. ```bash $ zellij plugin -- https://path/to/my/plugin.wasm ``` ```bash zellij pipe --plugin file:/path/to/my/plugin.wasm --name my_pipe_name -- my_arbitrary_data ``` ```bash zellij pipe --name my_pipe_name -- my_arbitrary_data ``` ```bash tail -f /tmp/my-live-logfile | zellij pipe --name logs --plugin https://example.com/my-plugin.wasm | wc -l ``` -------------------------------- ### Bind Keys in Zellij (Rust Example) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/keybindings-binding.html Demonstrates how to bind keys to actions within Zellij using the 'bind' instruction. This is typically done in a Zellij configuration file, often written in a Rust-like syntax. It shows binding a single key to an action and multiple keys to the same action. ```Rust // bind the Alt-n to open a new pane bind "Alt n" { NewPane; } // bind both the "h" key and the left-arrow key to move pane focus left bind "h" "Left" { MoveFocus "Left"; } // bind the "f" key to toggle the focused pane full-screen and switch to normal mode bind "f" { ToggleFocusFullscreen; SwitchToMode "Normal"; } ``` -------------------------------- ### Rendering a Table UI Component with Rust SDK Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/print.html Shows how to create and render a table UI component within a Zellij plugin using the Rust SDK. It includes examples of adding regular rows, styled rows, and selected rows, and demonstrates two methods for printing the table: one at the current cursor position and another at specific coordinates. ```rust #![allow(unused)] fn main() { let table = Table::new() .add_row(vec!["title1", "title2", "title3"]) .add_styled_row(vec![Text::new("content 1").color_range(0, 1..5), Text::new("content 2").color_range(2, ..), Text::new("content 3")]) .add_styled_row(vec![Text::new("content 11").selected(), Text::new("content 22").selected(), Text::new("content 33").selected()]) .add_styled_row(vec![Text::new("content 111"), Text::new("content 222").selected(), Text::new("content 33')]) .add_styled_row(vec![Text::new("content 11"), Text::new("content 22").selected(), Text::new("content 33")]); print_table(table); // will print this table wherever the cursor may be at the moment print_table_with_coordinates(table, 4, 5, None, None); // will print this table at x: 4, y: 5, the last two `Option`s are width/height } ``` -------------------------------- ### start_web_server Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/plugin-api-commands.md Starts the Zellij web server. Requires the `StartWebServer` permission. ```APIDOC ## start_web_server ### Description Start the Zellij [web-server](./web-client.md). ### Method POST ### Endpoint /start_web_server ### Parameters None ### Request Example (No request body for this endpoint) ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Install Zellij with Cargo binstall Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/installation.md Installs Zellij using the cargo-binstall extension, which is useful for systems where compiling from source is not ideal. This method requires Cargo to be installed. ```bash cargo binstall zellij ``` -------------------------------- ### Install Zellij with Cargo Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/installation.md Installs the latest stable version of Zellij using the Cargo package manager. Requires Rust and Cargo to be installed. If errors occur, updating Rustup might resolve them. ```bash cargo install --locked zellij rustup update ``` -------------------------------- ### Zellij Pane command and args Examples Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/creating-a-layout.md Shows how to specify a 'command' to run in a Zellij pane and how to provide 'args' for that command. It highlights that 'args' must be within child braces and provides an example for passing shell arguments. ```javascript layout { pane command="htop" pane { command "/usr/bin/btm" } } ``` ```javascript layout { pane command="tail" { args "-f" "/path/to/my/logfile" } // Hint: include "quoted" shell arguments as a single argument: pane command="bash" { args "-c" "tail -f /path/to/my/logfile" } } ``` -------------------------------- ### Install Zellij with Cargo Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/installation.html Installs the latest stable release of Zellij using the Rust package manager, Cargo. Ensure you have Rust and Cargo installed. If you encounter issues, updating your Rust toolchain with `rustup update` might resolve them. ```bash cargo install --locked zellij ``` -------------------------------- ### Swap Layout Constraints Example (KDL) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/swap-layouts.md Illustrates how to apply constraints like `exact_panes` and `max_panes` within swap layout definitions for both floating and tiled panes. ```javascript // ... floating_panes exact_panes=2 { pane x=1 y=1 pane x=10 y=10 } // ... tab max_panes=2 { pane split_direction="vertical" { pane pane } } // ... ``` -------------------------------- ### Set Scrollback Editor Environment Variable for Zellij Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/faq.html This example shows how to set the EDITOR environment variable, which Zellij uses by default to determine the editor for scrollback buffer editing. Ensure this variable is set before starting Zellij for the `ctrl + s + e` command to function correctly. Alternatively, the scrollback editor can be configured directly in the Zellij config. ```bash export EDITOR=/usr/bin/vim ``` -------------------------------- ### Show Startup Tips Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/options.md Determines whether usage tips are displayed when Zellij starts. These tips can also be accessed later through the `about` plugin. ```shell show_startup_tips true ``` -------------------------------- ### Switch Tab Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/print.html Changes the focused tab to the specified index. Tab indices start at 1. ```APIDOC ## POST /switch_tab_to ### Description Changes the focused tab to the specified index. Tab indices start at 1 (0 is considered as 1). ### Method POST ### Endpoint /switch_tab_to ### Parameters #### Query Parameters - **index** (integer) - Required - The index of the tab to switch to. ### Request Example ```json { "index": 3 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the tab switch operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Applying Zellij Layouts via Command Line Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/layouts.md Demonstrates how to apply a Zellij layout using the `zellij --layout` command. This can be used to load layouts from local files or remote URLs when starting Zellij or within an existing session. ```bash $ zellij --layout /path/to/layout_file.kdl ``` ```bash $ zellij --layout https://example.com/layout_file.kdl ``` ```bash zellij --layout [layout_name] ``` -------------------------------- ### Manage Plugins in Zellij Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/print.html Starts a plugin if it's not loaded or reloads it, bypassing the cache. This is primarily useful for plugin development. The plugin is identified by its URL. ```bash zellij action start-or-reload-plugin zellij:strider ``` -------------------------------- ### Web Server API Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/plugin-api-commands.html Endpoints for managing the Zellij web server, including starting, stopping, sharing sessions, and managing login tokens. ```APIDOC ## POST /start_web_server ### Description Start the Zellij web-server. ### Method POST ### Endpoint /start_web_server ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. ## POST /stop_web_server ### Description Stop the Zellij web-server. ### Method POST ### Endpoint /stop_web_server ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. ## POST /share_current_session ### Description Allows the current session to be shared (attached to) on the Zellij web-server. ### Method POST ### Endpoint /share_current_session ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. ## POST /stop_sharing_current_session ### Description Removes permission for the current session to be shared (attached to) on the Zellij web-server, also disconnects current web clients. ### Method POST ### Endpoint /stop_sharing_current_session ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. ## POST /query_web_server_status ### Description Queries the status of the Zellij web-server, response will be returned as the `WebServerStatus` event (which must also be subscribed to). ### Method POST ### Endpoint /query_web_server_status ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. ## POST /generate_web_login_token ### Description Generates (and returns) a new web login token, optionally with a provided name as a String. (This token is hashed in a local DB, so can never be displayed again). ### Method POST ### Endpoint /generate_web_login_token ### Parameters #### Request Body - **name** (string) - Optional - A name for the login token. ### Response #### Success Response (200) - **token** (string) - The generated web login token. ## POST /revoke_web_login_token ### Description Revoked an existing web login token by its name. ### Method POST ### Endpoint /revoke_web_login_token ### Parameters #### Request Body - **name** (string) - Required - The name of the web login token to revoke. ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. ## POST /revoke_all_web_login_tokens ### Description Revokes all web login tokens. ### Method POST ### Endpoint /revoke_all_web_login_tokens ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. ## GET /list_web_login_tokens ### Description Returns a list of existing web login tokens (their names, the tokens themselves cannot be displayed) and their creation times. ### Method GET ### Endpoint /list_web_login_tokens ### Response #### Success Response (200) - **tokens** (array[object]) - A list of web login tokens with their names and creation times. - **name** (string) - The name of the token. - **created_at** (string) - The creation timestamp of the token. ## POST /rename_web_login_token ### Description Rename a web login token by providing its existing name. ### Method POST ### Endpoint /rename_web_login_token ### Parameters #### Request Body - **old_name** (string) - Required - The current name of the web login token. - **new_name** (string) - Required - The new name for the web login token. ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. ``` -------------------------------- ### Launch Zellij Filepicker from Command Line (Bash) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/content/tutorials/filepicker.md Demonstrates how to launch the Zellij filepicker directly from the command line. This is a straightforward command that initiates the filepicker plugin. ```bash zellij plugin -- filepicker ``` -------------------------------- ### Start or Reload Plugin Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/cli-actions.html Launches a plugin if it's not loaded, or reloads it (skipping cache) if it is. Primarily useful for plugin development. ```APIDOC ## GET / Zellij Actions ### Description Launch a plugin if it is not loaded or reload it (skipping cache) if it is. Mostly useful for plugin development. ### Method GET ### Endpoint /zellij/action/start-or-reload-plugin ### Parameters #### Query Parameters - **plugin_url** (string) - Required - The URL of the plugin (e.g., `file:/path/to/my/plugin.wasm` or `zellij:strider`). ### Request Example ```bash zellij action start-or-reload-plugin zellij:strider ``` ### Response #### Success Response (200) - **plugin_id** (string) - The ID of the plugin that was started or reloaded. #### Response Example ```json { "plugin_id": "zellij:strider" } ``` ``` -------------------------------- ### Update Rust Toolchain Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/print.html If you encounter installation errors with Cargo, this command updates your Rust toolchain through rustup. This can resolve issues related to outdated components or conflicting dependencies. ```bash rustup update ``` -------------------------------- ### Floating Swap Layout Example (KDL) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/swap-layouts.md An example of a KDL configuration for a floating swap layout. It demonstrates different arrangements of floating panes with varying pane counts and positions. ```javascript layout { swap_floating_layout { floating_panes max_panes=1 { pane } floating_panes max_panes=2 { pane x=0 pane x="50%" } floating_panes max_panes=3 { pane x=0 width="25%" pane x="25%" width="25%" pane x="50%" } } } ``` -------------------------------- ### New Tab Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/print.html Creates a new tab, optionally with a specified layout and name. If a layout file is specified, it can be combined with a cwd to set the starting directory for relative paths in the layout. ```APIDOC ## POST /zellij/action/new-tab ### Description Creates a new tab, optionally with a custom layout and name. ### Method POST ### Endpoint /zellij/action/new-tab ### Parameters #### Query Parameters - **name** (string) - Optional - Name of the new tab. - **layout** (string) - Optional - Path to a layout file to use for the new tab. - **cwd** (string) - Optional - Base working directory for relative paths in the layout. ### Response #### Success Response (200) - **tab_id** (string) - The ID of the newly created tab. #### Response Example ```json { "tab_id": "tab-abcd" } ``` ``` -------------------------------- ### Command Line Configuration Options Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/command-line-options.html Zellij can be configured via command-line arguments when starting a session. These options take precedence over the configuration file. ```APIDOC ## GET /zellij/options ### Description This endpoint provides information about the available command-line options for configuring Zellij. ### Method GET ### Endpoint /zellij/options ### Parameters #### Query Parameters - **--attach-to-session** (string) - Optional - Whether to attach to a session specified in "session-name" if it exists. Possible values: true, false. - **--copy-clipboard** (string) - Optional - OSC52 destination clipboard. Possible values: system, primary. - **--copy-command** (string) - Optional - Switch to using a user supplied command for clipboard instead of OSC52. - **--copy-on-select** (string) - Optional - Automatically copy when selecting text. Possible values: true, false. - **--default-layout** (string) - Optional - Set the default layout. - **--default-mode** (string) - Optional - Set the default mode. - **--default-shell** (string) - Optional - Set the default shell. - **--disable-mouse-mode** (boolean) - Optional - Disable handling of mouse events. - **--layout-dir** (string) - Optional - Set the layout_dir, defaults to subdirectory of config dir. - **--mirror-session** (string) - Optional - Mirror session when multiple users are connected. Possible values: true, false. - **--mouse-mode** (string) - Optional - Set the handling of mouse events. Can be temporarily bypassed by the [SHIFT] key. Possible values: true, false. - **--no-pane-frames** (boolean) - Optional - Disable display of pane frames. - **--on-force-close** (string) - Optional - Set behaviour on force close (quit or detach). - **--pane-frames** (string) - Optional - Set display of the pane frames. Possible values: true, false. - **--scroll-buffer-size** (integer) - Optional - Set the scroll buffer size. - **--scrollback-editor** (string) - Optional - Explicit full path to open the scrollback editor (default is $EDITOR or $VISUAL). - **--session-name** (string) - Optional - The name of the session to create when starting Zellij. - **--simplified-ui** (string) - Optional - Allow plugins to use a more simplified layout that is compatible with more fonts. Possible values: true, false. - **--theme** (string) - Optional - Set the default theme. - **--theme-dir** (string) - Optional - Set the theme_dir, defaults to subdirectory of config dir. ### Request Example ```bash zellij --layout my_layout.kdl --theme my_theme.yaml ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the options are recognized. #### Response Example ```json { "message": "Zellij configuration options applied." } ``` ``` -------------------------------- ### Start Zellij Session with Filepicker Layout (Bash) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/content/tutorials/filepicker.md Shows how to start a new Zellij session with a pre-defined layout that includes the filepicker. This can be done from the command line or by selecting the 'strider' layout from the welcome screen. ```bash zellij -l strider ``` -------------------------------- ### Zellij Plugin API: Get Zellij Version (Rust) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/plugin-api-commands.html Fetches the version string of the currently running Zellij instance. This is valuable for ensuring plugin compatibility with the Zellij environment. ```rust // Example usage within a plugin: // let version = get_zellij_version(); ``` -------------------------------- ### Tiled Swap Layout Example (KDL) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/swap-layouts.md An example of a KDL configuration for a tiled swap layout. It defines two tabs with different pane arrangements and constraints. ```javascript layout { swap_tiled_layout name="h2v" { tab max_panes=2 { pane pane } tab { pane split_direction="vertical" { pane pane pane } } } } ``` -------------------------------- ### Zellij Plugin API: Get Plugin IDs (Rust) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/plugin-api-commands.html Retrieves the unique Zellij pane ID for the current plugin and the Zellij process ID. This information can be useful for inter-plugin communication or debugging. ```rust // Example usage within a plugin: // let (plugin_id, process_id) = get_plugin_ids(); ``` -------------------------------- ### Dump Default Swap Layout (Bash) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/swap-layouts.md This command dumps the default swap layout configuration to a specified file. It's a quick way to get a starting point for custom swap layouts. ```bash zellij setup --dump-swap-layout default > /tmp/my-quickstart-swap-layout-file.swap.kdl ``` -------------------------------- ### Zellij Layout Configuration Example Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/content/news/beta.md Demonstrates how to define a custom pane layout for Zellij using a YAML file. This allows users to pre-configure their workspace arrangement for specific tasks or workflows. ```yaml zellij --layout /path/to/your/layout.yaml ``` -------------------------------- ### Zellij Swap Layout Constraints Example Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/swap-layouts.html Demonstrates the use of 'exact_panes' and 'max_panes' constraints within Zellij swap layout definitions. These constraints control the number of panes allowed in floating panes or tabs. ```zellij-config // ... floating_panes exact_panes=2 { pane x=1 y=1 pane x=10 y=10 } // ... tab max_panes=2 { pane split_direction="vertical" { pane pane } } // ... ``` -------------------------------- ### Plugin API Subscribe Example (Rust) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/plugin-api-events.html This Rust code snippet demonstrates how a Zellij plugin can subscribe to various events using the `zellij-tile` crate. It shows the basic structure for subscribing and handling event updates. ```rust // Example of subscribing to events in a Zellij plugin // This is a conceptual example and requires the zellij-tile crate use zellij_tile::prelude::* #[derive(Default)] struct MyPlugin; impl ZellijPlugin for MyPlugin { fn subscribe(&self, subscriptions: &mutSubscriptions) { subscriptions.subscribe( &[EventType::ModeUpdate, EventType::PaneUpdate, EventType::Key], ); } fn update(&mut self, event: Event) -> bool { match event { Event::ModeUpdate(mode_info) => { // Handle ModeUpdate event println!("Mode updated: {:?}", mode_info); } Event::PaneUpdate(pane_info) => { // Handle PaneUpdate event println!("Pane updated: {:?}", pane_info); } Event::Key(key_event) => { // Handle Key event println!("Key pressed: {:?}", key_event); } _ => {} } true } } ``` -------------------------------- ### Specify Configuration File for Zellij Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/docs/src/configuration.md This shows how to pass a specific configuration file to Zellij using a command-line flag or an environment variable. This allows for using different configurations without modifying the default ones. ```bash zellij --config [FILE] ``` ```bash export ZELLIJ_CONFIG_FILE=[FILE] ``` -------------------------------- ### Zellij Web Server CLI Commands Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/print.html Commands to manage the Zellij web server. 'zellij web' starts the server, and 'zellij web --create-token' generates a login token for authentication. These tokens are hashed and displayed only once, and can be revoked. ```bash $ zellij web ``` ```bash zellij web --create-token ``` -------------------------------- ### Rust: Define and Register a Plugin Worker Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/print.html Plugin workers allow for long operations without blocking the main plugin thread. This example shows defining a worker implementing the ZellijWorker trait and registering it using the register_worker macro. ```rust #![allow(unused)] fn main() { pub struct TestWorker { // ... } impl ZellijWorker for TestWorker { // ... } register_worker!( TestWorker, test_worker, // the namespace of the worker TEST_WORKER // a name for static variable used to store the worker state ); } ``` -------------------------------- ### Initialize Theme and Sidebar Preferences (JavaScript) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/404.html This script initializes the theme and sidebar visibility based on user preferences stored in localStorage. It handles potential errors during localStorage access and applies the appropriate CSS classes to the HTML document. It also ensures compatibility with different screen sizes. ```javascript var path_to_root = ""; var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light"; try { var theme = localStorage.getItem('mdbook-theme'); var sidebar = localStorage.getItem('mdbook-sidebar'); if (theme.startsWith('"') && theme.endsWith('"')) { localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1)); } if (sidebar.startsWith('"') && sidebar.endsWith('"')) { localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1)); } } catch (e) { } var theme; try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } if (theme === null || theme === undefined) { theme = default_theme; } const html = document.documentElement; html.classList.remove('light') html.classList.add(theme); html.classList.add("js"); var sidebar = null; var sidebar_toggle = document.getElementById("sidebar-toggle-anchor"); if (document.body.clientWidth >= 1080) { try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } sidebar = sidebar || 'visible'; } else { sidebar = 'hidden'; } sidebar_toggle.checked = sidebar === 'visible'; html.classList.remove('sidebar-visible'); html.classList.add("sidebar-" + sidebar); ``` -------------------------------- ### Try Zellij Without Installing (Fish) Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/themes/hello-friend-ng/layouts/index.html This snippet allows users to try Zellij directly from their terminal without a formal installation. It downloads and executes a launch script using curl and psub. This is intended for the fish shell. ```fish bash (curl -L https://zellij.dev/launch | psub) ``` -------------------------------- ### Plugin Keybinding Configuration Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/print.html Demonstrates how to use the `reconfigure` command to bind global keys to a plugin using a temporary keybinding. ```APIDOC ## POST /reconfigure ### Description Use the `reconfigure` command to bind global keys to a plugin. This allows for temporary keybindings that are not saved to disk, enabling dynamic plugin interaction. ### Method POST ### Endpoint /reconfigure ### Parameters #### Request Body - **config** (string) - Required - The configuration string containing keybind definitions. - **apply_to_session** (boolean) - Required - Whether to apply the configuration to the current session. ### Request Example ```json { "config": "keybinds {{\n shared {{\n bind \"Ctrl Shift r\" {{ MessagePluginId {{ name \"my_message_name\" }} }} \n }}\n }}", "apply_to_session": false } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Configuration applied successfully." } ``` ``` -------------------------------- ### Start or Reload Plugin in Zellij Source: https://github.com/zellij-org/zellij-org.github.io/blob/main/static/documentation/cli-actions.html Launches a specified plugin if it's not already loaded, or reloads it (bypassing cache) if it is. This action is primarily intended for plugin development and debugging, requiring a valid plugin URL. ```shell zellij action start-or-reload-plugin ``` -------------------------------- ### Zellij Configuration Options (KDL) Source: https://context7.com/zellij-org/zellij-org.github.io/llms.txt An example KDL configuration file for Zellij, demonstrating options for UI, themes, shells, session serialization, and environment variables. ```javascript // ~/.config/zellij/config.kdl - Example configuration on_force_close "quit" // "detach" (default) or "quit" simplified_ui true // Simplified UI without arrow fonts default_shell "fish" // Default shell for new panes pane_frames true // Show frames around panes theme "dracula" // Color theme name default_layout "compact" // Default layout on startup default_mode "locked" // Starting input mode mouse_mode true // Enable mouse support scroll_buffer_size 10000 // Scrollback buffer lines copy_command "wl-copy" // Clipboard command (wayland) copy_on_select true // Auto-copy on selection scrollback_editor "/usr/bin/vim" // Editor for scrollback session_serialization true // Enable session resurrection auto_layout true // Auto-arrange panes // Environment variables for all panes env { RUST_BACKTRACE 1 FOO "bar" } // UI customization ui { pane_frames { rounded_corners true hide_session_name true } } ```