### Zellij Setup and Configuration Source: https://zellij.dev/documentation/commands.html Commands for managing Zellij configuration and environment setup. ```APIDOC ## setup ### Description Provides utilities for configuring and setting up Zellij. ### Parameters #### Flags - **--check** - Check the current configuration. - **--clean** - Start with default configuration. - **--dump-config** - Dump the default configuration file to stdout. - **--dump-layout [LAYOUT]** - Dump a specified default layout file to stdout. - **--generate-completion [SHELL]** - Generate shell completions for the specified shell. ``` -------------------------------- ### Start the local web server Source: https://zellij.dev/documentation/plugin-api-commands.html Starts a local web server to serve Zellij sessions to web clients. Requires the `StartWebServer` permission. ```rust #![allow(unused)] fn main() { fn start_web_server() } ``` -------------------------------- ### Install Zellij via Cargo Binstall Source: https://zellij.dev/documentation/installation.html Use the binstall extension to install pre-compiled binaries, which is faster than compiling from source. ```bash cargo binstall zellij ``` -------------------------------- ### Install Zellij with binstall Source: https://zellij.dev/documentation/print.html Installs Zellij using the `binstall` Cargo extension. This is an alternative installation method if Cargo is present. ```bash cargo binstall zellij ``` -------------------------------- ### start_web_server Source: https://zellij.dev/documentation/plugin-api-commands.html Start a local web server for serving Zellij sessions to web clients. ```APIDOC ## start_web_server ### Description Start a local web server for serving Zellij sessions to web clients. ### Required Permission `StartWebServer` ``` -------------------------------- ### Start the Zellij Web Server Source: https://zellij.dev/documentation/web-client.html Command to initiate the built-in web server from the command line. ```bash $ zellij web ``` -------------------------------- ### Sample Output (With --all) Source: https://zellij.dev/documentation/cli-actions.html Example of the output when using the '--all' flag, providing extensive details for each pane. ```text TAB_ID TAB_POS TAB_NAME PANE_ID TYPE TITLE COMMAND CWD FOCUSED FLOATING EXITED X Y ROWS COLS 0 0 Tab #1 terminal_1 terminal /bin/bash bash /home/user/project true false false 0 1 24 80 0 0 Tab #1 plugin_0 plugin tab-bar zellij:tab-bar - false false false 0 0 1 80 1 1 Tab #2 terminal_2 terminal vim main.rs vim main.rs /home/user/project/src true false false 0 1 24 80 ``` -------------------------------- ### Applying a Zellij Layout on Startup Source: https://zellij.dev/documentation/print.html Applies a layout defined in a local file when starting Zellij. ```bash $ zellij --layout /path/to/layout_file.kdl ``` -------------------------------- ### Start Zellij Without Default Configuration Source: https://zellij.dev/documentation/configuration Launches Zellij without loading any configuration from default directories. This is useful for testing or starting with a clean slate. ```bash zellij options --clean ``` -------------------------------- ### Set startup focus Source: https://zellij.dev/documentation/creating-a-layout.html Specify which pane should be focused when Zellij starts. ```kdl layout { pane focus=true pane { focus true } } ``` -------------------------------- ### Sample Output (With --json) Source: https://zellij.dev/documentation/cli-actions.html Example of the JSON output for the 'list-panes' action, suitable for machine parsing. ```json [ { "id": 1, "is_plugin": false, "is_focused": true, "is_fullscreen": false, "is_floating": false, "is_suppressed": false, "title": "/bin/bash", "exited": false, "exit_status": null, "is_held": false, "pane_x": 0, "pane_content_x": 1, "pane_y": 1, "pane_content_y": 2, "pane_rows": 24, "pane_content_rows": 22, "pane_columns": 80, "pane_content_columns": 78, "cursor_coordinates_in_pane": [0, 5], "terminal_command": null, "plugin_url": null, "is_selectable": true, "tab_id": 0, "tab_position": 0, "tab_name": "Tab #1", "pane_command": "bash", "pane_cwd": "/home/user/project" }, { "id": 0, "is_plugin": true, "is_focused": false, "is_fullscreen": false, "is_floating": false, "is_suppressed": false, "title": "tab-bar", "exited": false, "exit_status": null, "is_held": false, "pane_x": 0, "pane_content_x": 0, "pane_y": 0, "pane_content_y": 0, "pane_rows": 1, "pane_content_rows": 1, "pane_columns": 80, "pane_content_columns": 80, "cursor_coordinates_in_pane": null, "terminal_command": null, "plugin_url": "zellij:tab-bar", "is_selectable": false, "tab_id": 0, "tab_position": 0, "tab_name": "Tab #1" } ] ``` -------------------------------- ### Set current working directory Source: https://zellij.dev/documentation/creating-a-layout.html Define the starting directory for a pane. ```kdl layout { pane cwd="/" pane { command "git" args "diff" cwd "/path/to/some/folder" } } ``` -------------------------------- ### Apply Zellij Layout on Startup Source: https://zellij.dev/documentation/layouts.html Load a layout file when starting Zellij. This sets up the initial pane and tab arrangement. ```bash $ zellij --layout /path/to/layout_file.kdl ``` -------------------------------- ### Setup Zellij Configuration Source: https://zellij.dev/documentation/configuration Creates the Zellij configuration directory and dumps the default configuration to config.kdl. This is often done automatically on first run. ```bash mkdir ~/.config/zellij zellij setup --dump-config > ~/.config/zellij/config.kdl ``` -------------------------------- ### Sample Output (Default) Source: https://zellij.dev/documentation/cli-actions.html Example of the default output format for the 'list-panes' action, showing pane ID, type, and title. ```text PANE_ID TYPE TITLE terminal_1 terminal /bin/bash plugin_0 plugin tab-bar terminal_2 terminal vim main.rs ``` -------------------------------- ### Set Default Mode Source: https://zellij.dev/documentation/options.html Choose the mode Zellij starts in. Defaults to 'normal'. ```zellij default_mode "locked" ``` -------------------------------- ### Plugin Configuration via Layouts Source: https://zellij.dev/documentation/print.html Example of how to configure a plugin with custom key-value pairs within a Zellij layout file. ```zellij pane { plugin location="file:/path/to/my/plugin.wasm" { some_key "some_value" another_key 1 } } ``` -------------------------------- ### Start or reload a plugin by URL Source: https://zellij.dev/documentation/plugin-api-commands.html Initiates a plugin using its URL. If the plugin is already running, this command will reload it. ```rust #![allow(unused)] fn main() { fn start_or_reload_plugin(url: &str) } ``` -------------------------------- ### Load a theme via command line Source: https://zellij.dev/documentation/themes.html Specify a theme when starting a new Zellij session using the options flag. ```bash zellij options --theme [NAME] ``` -------------------------------- ### PaneId Usage Example Source: https://zellij.dev/documentation/plugin-api-types.html Demonstrates how to create and match on PaneId variants to differentiate between terminal and plugin panes. ```rust #![allow(unused)] fn main() { let terminal_pane = PaneId::Terminal(1); let plugin_pane = PaneId::Plugin(0); match pane_id { PaneId::Terminal(id) => { /* terminal pane */ }, PaneId::Plugin(id) => { /* plugin pane */ }, } } ``` -------------------------------- ### Automate CI workflows with Zellij Source: https://zellij.dev/documentation/cli-recipes.html A complete script example demonstrating background session creation, pane management, and output monitoring. ```bash #!/bin/bash # Create a background session with a layout zellij attach --create-background ci-runner options --default-layout compact # Open a pane and capture its ID BUILD_PANE=$(zellij --session ci-runner action new-pane --name "build") # Start a build zellij --session ci-runner action paste --pane-id $BUILD_PANE "cargo build 2>&1" && zellij --session ci-runner action send-keys --pane-id $BUILD_PANE "Enter" # Monitor the build output for relevant lines, exit when the pane closes zellij --session ci-runner subscribe --pane-id $BUILD_PANE --format json \ | jq --unbuffered 'select(.event == "pane_update") | .viewport[] | select(test("error|warning|Finished"))' ``` -------------------------------- ### Watch Filesystem Source: https://zellij.dev/documentation/print.html Start watching the host folder for filesystem changes. File change events will be delivered to the plugin. ```rust #![allow(unused)] fn main() { fn watch_filesystem() } ``` -------------------------------- ### FileToOpen Usage Example Source: https://zellij.dev/documentation/plugin-api-types.html Illustrates creating a FileToOpen instance with a specific path and line number, intended for use with an external editor. ```rust #![allow(unused)] fn main() { let file = FileToOpen { path: PathBuf::from("/home/user/project/src/main.rs"), line_number: Some(42), cwd: None, }; open_file(file, BTreeMap::new()); } ``` -------------------------------- ### Zellij Keybinding Modes Example Source: https://zellij.dev/documentation/print.html Illustrates the structure for defining keybindings within different modes like 'normal' and 'pane'. ```zellij __ keybinds { normal { // keybindings available in normal mode } pane { // keybindings available in pane mode } } ``` -------------------------------- ### Create a background session Source: https://zellij.dev/documentation/programmatic-control.html Starts a headless Zellij session without attaching a terminal. ```bash zellij attach --create-background my-session ``` ```bash zellij attach --create-background my-session options --default-layout /path/to/layout.kdl ``` -------------------------------- ### Start New Session with Inline Layout Source: https://zellij.dev/documentation/print.html Initialize a new Zellij session with a layout specified directly on the command line using `--layout-string`. ```bash zellij --layout-string 'layout { pane split_direction="vertical" { pane; pane; }; }' ``` -------------------------------- ### Swap Layout Constraints Example Source: https://zellij.dev/documentation/print.html Illustrates the use of `exact_panes` and `max_panes` constraints within swap layout configurations for both floating and tiled panes. ```zellij // ... 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 } } // ... ``` -------------------------------- ### Autostart Zellij (Fish Shell) Source: https://zellij.dev/documentation/print.html Conditionally starts a new Zellij session if not already inside one. This is a shell-specific configuration for the Fish shell. ```fish if set -q ZELLIJ else zellij end ``` -------------------------------- ### Start Zellij Without Loading Configuration Source: https://zellij.dev/documentation/print.html Initiate Zellij with a clean state, ignoring any existing configuration files. This is useful for testing or troubleshooting. ```bash zellij options --clean ``` -------------------------------- ### CommandToRun Usage Example Source: https://zellij.dev/documentation/plugin-api-types.html Shows how to construct a CommandToRun object to execute a build command with specific arguments and a working directory. ```rust #![allow(unused)] fn main() { let cmd = CommandToRun { path: PathBuf::from("cargo"), args: vec!["build".to_string(), "--release".to_string], cwd: Some(PathBuf::from("/home/user/project")), }; open_command_pane(cmd, BTreeMap::new()); } ``` -------------------------------- ### External swap layout file naming Source: https://zellij.dev/documentation/swap-layouts.html Example of naming convention for external swap layout files. ```text my-layout.kdl my-layout.swap.kdl ``` -------------------------------- ### FailedToStartWebServer Event Source: https://zellij.dev/documentation/plugin-api-events.html Fired when Zellij failed to start the web server after a `start_web_server` command. The payload is an error message string. ```APIDOC ## FailedToStartWebServer Event ### Description Fired when Zellij failed to start the web server after a `start_web_server` command. ### Payload - `String` - error message ``` -------------------------------- ### Start and Monitor a Build Source: https://zellij.dev/documentation/print.html Initiates a cargo build and monitors its output for completion or errors. Assumes BUILD_PANE is an environment variable set to the target pane ID. ```bash zellij --session ci-runner action paste --pane-id $BUILD_PANE "cargo build 2>&1" && zellij --session ci-runner action send-keys --pane-id $BUILD_PANE "Enter" ``` ```bash zellij --session ci-runner subscribe --pane-id $BUILD_PANE --format json \ | jq --unbuffered 'select(.event == "pane_update") | .viewport[] | select(test("error|warning|Finished"))' ``` -------------------------------- ### Show Startup Tips Source: https://zellij.dev/documentation/options.html Controls whether to display usage tips on Zellij startup. Defaults to true. ```zellij show_startup_tips true ``` -------------------------------- ### Handle ActionComplete Event Source: https://zellij.dev/documentation/plugin-api-events.html This example shows how to react to the completion of an action initiated via `run_action`, using context to identify specific actions. ```rust #![allow(unused)] fn main() { fn update(&mut self, event: Event) -> bool { match event { Event::ActionComplete(action, pane_id, context) => { if context.get("request_id") == Some(&"my-action".to_string()) { if let Some(pane_id) = pane_id { self.created_pane = Some(pane_id); } } true }, _ => false, } } } ``` -------------------------------- ### Handle Key Event in Plugin Source: https://zellij.dev/documentation/plugin-api-events.html Example of handling the `Key` event. This snippet demonstrates closing the plugin on 'q' and handling the Enter key. ```rust #![allow(unused)] fn main() { fn update(&mut self, event: Event) -> bool { match event { Event::Key(key) => { match key.bare_key { BareKey::Char('q') if key.has_no_modifiers() => { close_self(); }, BareKey::Enter => { self.handle_enter(); }, _ => {}, } true }, _ => false, } } } ``` -------------------------------- ### Install Zellij with Cargo Source: https://zellij.dev/documentation/print.html Installs Zellij using Cargo, the Rust package manager. Ensure Cargo is installed before running this command. ```bash cargo install --locked zellij ``` -------------------------------- ### Manage Background Task Pane Source: https://zellij.dev/documentation/print.html Demonstrates a common workflow: starting a long-running task in a floating pane, hiding it, and then showing it again. ```bash # Start a long-running build in a floating pane PANE_ID=$(zellij action new-pane --floating --name "build") zellij action paste --pane-id $PANE_ID "cargo build --release 2>&1" && zellij action send-keys --pane-id $PANE_ID "Enter" # Hide floating panes to focus on other work zellij action hide-floating-panes # Later, show them again to check progress zellij action show-floating-panes ``` -------------------------------- ### watch_filesystem Source: https://zellij.dev/documentation/plugin-api-commands.html Start watching the host folder for filesystem changes. File change events (`FileSystemCreate`, `FileSystemUpdate`, `FileSystemDelete`) will be delivered to the plugin. ```APIDOC ## watch_filesystem ### Description Start watching the host folder for filesystem changes. File change events (`FileSystemCreate`, `FileSystemUpdate`, `FileSystemDelete`) will be delivered to the plugin. ``` -------------------------------- ### Subscribe to BeforeClose Event Source: https://zellij.dev/documentation/plugin-api-events.html This example shows how to subscribe to the BeforeClose event and perform cleanup operations, such as saving state, before the plugin is unloaded. ```rust #![allow(unused)] fn main() { fn load(&mut self, _config: BTreeMap) { subscribe(&[EventType::BeforeClose]); } fn update(&mut self, event: Event) -> bool { match event { Event::BeforeClose => { self.save_state(); false }, _ => false, } } } ``` -------------------------------- ### Install Zellij via Cargo Source: https://zellij.dev/documentation/installation.html Use this command to install the latest version of Zellij using the Rust Cargo package manager. ```bash cargo install --locked zellij ``` -------------------------------- ### Pass Configuration File to Zellij Source: https://zellij.dev/documentation/configuration Starts Zellij with a specific configuration file using the --config flag. Alternatively, the ZELLIJ_CONFIG_FILE environment variable can be used. ```bash zellij --config [FILE] ``` -------------------------------- ### Load plugins on startup via configuration Source: https://zellij.dev/documentation/plugin-loading.html Use the load_plugins block in the configuration file to load plugins in the background during session startup. ```kdl load_plugins { https://example.com/my-plugin.wasm file:/path/to/my/plugin.kdl my-plugin-alias } ``` -------------------------------- ### Generate Shell Completions Source: https://zellij.dev/documentation/controlling-zellij-through-cli.html Generate shell completions for popular shells like fish, bash, and zsh using the `zellij setup --generate-completion` command. ```bash $ zellij setup --generate-completion fish ``` ```bash $ zellij setup --generate-completion bash ``` ```bash $ zellij setup --generate-completion zsh ``` -------------------------------- ### current-tab-info Source: https://zellij.dev/documentation/print.html Gets information about the currently active tab. ```APIDOC ## current-tab-info ### Description Get information about the currently active tab. Returns the tab name and ID by default. ### Method `zellij action current-tab-info` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Options - `-j, --json`: Output as JSON with full TabInfo. ### Example ``` $ zellij action current-tab-info ``` **Sample output:** ``` name: Tab #1 id: 0 position: 0 ``` With `--json`: ``` $ zellij action current-tab-info --json ``` **Sample output:** ```json { "position": 0, "name": "Tab #1", "active": true, "panes_to_hide": 0, "is_fullscreen_active": false, "is_sync_panes_active": false, "are_floating_panes_visible": false, "other_focused_clients": [], "active_swap_layout_name": "default", "is_swap_layout_dirty": false, "viewport_rows": 24, "viewport_columns": 80, "display_area_rows": 26, "display_area_columns": 80, "selectable_tiled_panes_count": 2, "selectable_floating_panes_count": 0, "tab_id": 0, "has_bell_notification": false, "is_flashing_bell": false } ``` ``` -------------------------------- ### Pane Template Expansion Example Source: https://zellij.dev/documentation/creating-a-layout.html Illustrates how a pane template with a 'children' node is expanded into a nested layout structure when used. ```zellij layout { pane_template name="my_template" { pane children pane } my_template split_direction="vertical" { pane pane } } ``` -------------------------------- ### Defining Panes with Commands and Working Directories Source: https://zellij.dev/documentation/print.html Demonstrates various ways to define 'pane' nodes, including specifying commands and current working directories. ```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 "/" } } ``` -------------------------------- ### Start or Reload Plugin Source: https://zellij.dev/documentation/cli-actions.html Loads a plugin if not present, or reloads it bypassing cache. Primarily for plugin development. Accepts a plugin URL and optional configuration. ```bash zellij action start-or-reload-plugin zellij:strider ``` ```bash zellij action start-or-reload-plugin file:/path/to/plugin.wasm -c "key=value" ``` -------------------------------- ### get_pane_cwd Source: https://zellij.dev/documentation/plugin-api-commands.html Get the current working directory of a pane's process. ```APIDOC ## get_pane_cwd ### Description Get the current working directory of a pane's process. ### Required Permission `ReadApplicationState` ### Parameters - `pane_id` (`PaneId`) - The pane to query ### Returns - `Result` - the working directory path ``` -------------------------------- ### get_pane_running_command Source: https://zellij.dev/documentation/plugin-api-commands.html Get the current running command (argv) in a terminal pane. ```APIDOC ## get_pane_running_command ### Description Get the current running command (argv) in a terminal pane. ### Required Permission `ReadApplicationState` ### Parameters - `pane_id` (`PaneId`) - The pane to query ### Returns - `Result, String>` - the command and its arguments ``` -------------------------------- ### get_pane_pid Source: https://zellij.dev/documentation/plugin-api-commands.html Get the PID of the process running inside a terminal pane. ```APIDOC ## get_pane_pid ### Description Get the PID of the process running inside a terminal pane. ### Required Permission `ReadApplicationState` ### Parameters - `pane_id` (`PaneId`) - The pane to query (must be a terminal pane) ### Returns - `Result` - the process ID on success ``` -------------------------------- ### Setting Tab Focus on Startup Source: https://zellij.dev/documentation/print.html Use the `focus=true` argument on a `tab` to designate it as the active tab when Zellij starts. Only one tab can be focused. ```zellij-config layout { tab { pane pane } tab focus=true { pane pane } } ``` -------------------------------- ### Get Current Tab Info Source: https://zellij.dev/documentation/cli-recipes.html Retrieve information about the currently active tab. ```bash zellij action current-tab-info ``` -------------------------------- ### Zellij Command Line Configuration Source: https://zellij.dev/documentation/command-line-options.html Zellij can be configured using command-line options when starting a session. These options take precedence over settings in the configuration file. ```APIDOC ## Zellij Command Line Options ### Description Configure Zellij sessions using command-line flags. These options override settings found in the configuration file. ### Usage `zellij options [OPTIONS]` ### Options #### `--attach-to-session ` - **Type**: string - **Description**: Whether to attach to a session specified in "session-name" if it exists. - **Possible values**: `true`, `false` #### `--copy-clipboard ` - **Type**: string - **Description**: Specifies the destination clipboard for copied content. - **Possible values**: `system`, `primary` #### `--copy-command ` - **Type**: string - **Description**: Use a user-supplied command for clipboard operations instead of OSC52. #### `--copy-on-select ` - **Type**: string - **Description**: Automatically copy selected text. - **Possible values**: `true`, `false` #### `--default-layout ` - **Type**: string - **Description**: Set the default layout for new sessions. #### `--default-mode ` - **Type**: string - **Description**: Set the default mode for new sessions. #### `--default-shell ` - **Type**: string - **Description**: Set the default shell to be used. #### `--disable-mouse-mode` (REMOVED) - **Description**: This option is removed. Use `--mouse-mode false` instead. #### `--layout-dir ` - **Type**: string - **Description**: Set the directory for layouts. Defaults to a subdirectory of the config directory. #### `--mirror-session ` - **Type**: string - **Description**: Enable session mirroring when multiple users are connected. - **Possible values**: `true`, `false` #### `--mouse-mode ` - **Type**: string - **Description**: Control the handling of mouse events. Can be temporarily bypassed with the [SHIFT] key. - **Possible values**: `true`, `false` #### `--no-pane-frames` (REMOVED) - **Description**: This option is removed. Use `--pane-frames false` instead. #### `--on-force-close ` - **Type**: string - **Description**: Set the behavior when a session is force-closed. - **Possible values**: `quit`, `detach` #### `--pane-frames ` - **Type**: string - **Description**: Control the display of pane frames. - **Possible values**: `true`, `false` #### `--scroll-buffer-size ` - **Type**: string - **Description**: Set the size of the scroll buffer. #### `--scrollback-editor ` - **Type**: string - **Description**: Specify the full path to open the scrollback editor. Defaults to `$EDITOR` or `$VISUAL`. #### `--session-name ` - **Type**: string - **Description**: The name of the session to create when starting Zellij. #### `--simplified-ui ` - **Type**: string - **Description**: Enable a simplified UI layout compatible with more fonts. - **Possible values**: `true`, `false` #### `--theme ` - **Type**: string - **Description**: Set the default theme for Zellij. #### `--theme-dir ` - **Type**: string - **Description**: Set the directory for themes. Defaults to a subdirectory of the config directory. ``` -------------------------------- ### Configure Plugin via Command Line Source: https://zellij.dev/documentation/plugin-api-configuration.html Launch or focus a plugin and provide its configuration directly through the command line arguments. The configuration is a comma-separated list of key-value pairs. ```bash zellij action launch-or-focus-plugin --configuration "some_key=some_value,another_key=1" ``` -------------------------------- ### Update Rust Toolchain Source: https://zellij.dev/documentation/installation.html Run this command if you encounter installation errors while using a rustup-managed environment. ```bash rustup update ``` -------------------------------- ### Get Current Tab Information Source: https://zellij.dev/documentation/print.html Retrieve information about the currently active tab in the Zellij session. ```bash zellij current-tab-info ``` -------------------------------- ### Loading Plugins in Zellij Configuration Source: https://zellij.dev/documentation/print.html Plugins can be loaded on startup through the `load_plugins` configuration block. These plugins are loaded in the background and request permissions if needed. ```zellij load_plugins { https://example.com/my-plugin.wasm file:/path/to/my/plugin.kdl my-plugin-alias } ``` -------------------------------- ### Get Layout Directory Source: https://zellij.dev/documentation/plugin-api-commands.html Returns the absolute path to the layout directory. Requires the `ReadApplicationState` permission. ```rust #![allow(unused)] fn main() { fn get_layout_dir() -> String } ``` -------------------------------- ### Define basic panes Source: https://zellij.dev/documentation/creating-a-layout.html Demonstrates various ways to define panes, including bare panes, command execution, and child-brace arguments. ```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 "/" } } ``` -------------------------------- ### Update Rustup Source: https://zellij.dev/documentation/print.html Updates the Rust toolchain using rustup. This is a troubleshooting step if Cargo installation fails. ```bash rustup update ``` -------------------------------- ### Configure Tab Focus on Startup Source: https://zellij.dev/documentation/creating-a-layout.html Set a tab to have focus on startup using the 'focus=true' argument. Only one tab can be focused at a time. Defaults to false. ```zellij layout { tab { pane pane } tab focus=true { pane pane } } ``` -------------------------------- ### Get Pane Info Source: https://zellij.dev/documentation/plugin-api-commands.html Queries detailed information about a specific pane by its `PaneId`. Requires the `ReadApplicationState` permission. ```rust #![allow(unused)] fn main() { fn get_pane_info(pane_id: PaneId) -> Option } ``` ```rust #![allow(unused)] fn main() { if let Some(info) = get_pane_info(PaneId::Terminal(1)) { eprintln!("Pane title: {}, focused: {}", info.title, info.is_focused); } } ``` -------------------------------- ### Handling PastedText Event Source: https://zellij.dev/documentation/print.html Example of how to handle the `PastedText` event to append the pasted text to an input buffer. ```rust #![allow(unused)] fn main() { fn update(&mut self, event: Event) -> bool { match event { Event::PastedText(text) => { self.input_buffer.push_str(&text); true }, _ => false, } } } ``` -------------------------------- ### Launch Plugin Instance Source: https://zellij.dev/documentation/keybindings-possible-actions.html Launches a new instance of a plugin. Use this when you always want a fresh instance, regardless of whether one is already running. Supports configuration options and skipping the plugin cache. ```zellij __ bind "a" { LaunchPlugin "file:/path/to/my/plugin.wasm" { floating true skip_plugin_cache true my_config_key "my_config_value" } } ``` -------------------------------- ### Manage plugins Source: https://zellij.dev/documentation/cli-recipes.html Launch, pipe data to, or reload plugin instances. ```bash zellij action launch-plugin file:/path/to/plugin.wasm --floating ``` ```bash echo "some data" | zellij pipe --name my-pipe --plugin "my-plugin-alias" ``` ```bash zellij action start-or-reload-plugin file:/path/to/plugin.wasm ``` -------------------------------- ### Writing to Host Filesystem from Plugin Source: https://zellij.dev/documentation/print.html Demonstrates how a plugin can write content to a file in the host's filesystem using Zellij's mapped '/host' path. ```rust #![allow(unused)] fn main() { std::fs::write("/host/my_file.txt", "hi from a plugin!").unwrap() } ``` -------------------------------- ### intercept_key_presses Source: https://zellij.dev/documentation/plugin-api-commands.html Starts intercepting key presses, delivering them via the `InterceptedKeyPress` event instead of normal Zellij processing. ```APIDOC ## intercept_key_presses ### Description Start intercepting key presses. Intercepted keys are delivered via the `InterceptedKeyPress` event rather than being processed by Zellij. ### Required Permission InterceptInput ``` -------------------------------- ### Start or Reload Plugin Source: https://zellij.dev/documentation/cli-actions.html Launches a plugin if it is not loaded or reloads it (skipping cache) if it is. Primarily useful for plugin development. ```APIDOC ## Start or Reload Plugin ### Description Launches a plugin if it is not loaded or reload it (skipping cache) if it is. Mostly useful for plugin development. ### Method `zellij action start-or-reload-plugin ` ### Arguments - **PLUGIN_URL** (string) - Required - The plugin URL (eg. `file:/path/to/my/plugin.wasm`) ### Parameters #### Options - **-c, --configuration ** (string) - Optional - Plugin configuration (key=value pairs) ### Example ``` zellij action start-or-reload-plugin zellij:strider zellij action start-or-reload-plugin file:/path/to/plugin.wasm -c "key=value" ``` ``` -------------------------------- ### LaunchPlugin Source: https://zellij.dev/documentation/print.html Launches a new instance of a plugin. ```APIDOC ## LaunchPlugin ### Description Launch a new plugin instance. Unlike `LaunchOrFocusPlugin`, this always launches a new instance even if one is already running. ### Arguments - **plugin_url** (string) - Required - The URL of the plugin (e.g., `file:/path/to/my/plugin.wasm`). - **floating** (boolean) - Optional - Whether to launch the plugin as a floating pane (default: `false`). - **in_place** (boolean) - Optional - Whether to open the plugin in place of the focused pane (default: `false`). - **close_replaced_pane** (boolean) - Optional - If `in_place` is true, close the replaced pane instead of suspending it (default: `false`). - **skip_plugin_cache** (boolean) - Optional - Skip the plugin cache and force reloading (default: `false`). - **Additional key-value pairs** - These are passed as plugin user configuration. ### Example ``` bind "a" { LaunchPlugin "file:/path/to/my/plugin.wasm" { floating true skip_plugin_cache true my_config_key "my_config_value" } } ``` ``` -------------------------------- ### Set Environment Variables Source: https://zellij.dev/documentation/options.html Define a key-value map of environment variables that will be set for each terminal pane Zellij starts. ```zellij env { RUST_BACKTRACE 1 FOO "bar" } ``` -------------------------------- ### Get current tab information Source: https://zellij.dev/documentation/print.html Retrieves information about the currently active tab. Can be output as plain text or JSON. ```APIDOC ## Get current tab information ### Description Get information about the currently active tab. ### Method `zellij action current-tab-info` ### Example ``` zellij action current-tab-info ``` ### Response Example (Plain Text) ``` name: Tab #1 id: 0 position: 0 ``` ### Method `zellij action current-tab-info --json` ### Example ``` zellij action current-tab-info --json ``` ### Response Example (JSON) ```json { "position": 0, "name": "Tab #1", "active": true, "panes_to_hide": 0, "is_fullscreen_active": false, "is_sync_panes_active": false, "are_floating_panes_visible": false, "other_focused_clients": [], "active_swap_layout_name": "default", "is_swap_layout_dirty": false, "viewport_rows": 24, "viewport_columns": 80, "display_area_rows": 26, "display_area_columns": 80, "selectable_tiled_panes_count": 2, "selectable_floating_panes_count": 0, "tab_id": 0, "has_bell_notification": false, "is_flashing_bell": false } ``` ``` -------------------------------- ### dump_session_layout Source: https://zellij.dev/documentation/plugin-api-commands.html Gets the current session layout as a KDL string, optionally including metadata, with the requesting plugin removed. ```APIDOC ## dump_session_layout ### Description Get the current session layout as a KDL string, along with optional metadata. The requesting plugin is removed from the dumped layout. ### Returns Result<(String, Option), String> ### Required Permission ReadApplicationState ``` -------------------------------- ### current_session_last_saved_time Source: https://zellij.dev/documentation/plugin-api-commands.html Get the number of milliseconds elapsed since the last session save. This command requires the `ReadApplicationState` permission. ```APIDOC ## current_session_last_saved_time ### Description Get the number of milliseconds elapsed since the last session save. ### Returns `Option` - milliseconds since last save, or `None` if never saved ``` -------------------------------- ### Layout with Exa and Git Log Commands Source: https://zellij.dev/documentation/layout-examples.html Configures panes to run 'exa' for file listing and 'git log' for commit history. ```zellij layout { pane split_direction="vertical" { pane pane split_direction="horizontal" { pane command="exa" { args "--color" "always" "-l" } pane command="git" { args "log" } } } } ``` -------------------------------- ### Get Pane CWD Source: https://zellij.dev/documentation/plugin-api-commands.html Retrieves the current working directory of a pane's process. Requires the `ReadApplicationState` permission. ```rust #![allow(unused)] fn main() { fn get_pane_cwd(pane_id: PaneId) -> Result } ``` -------------------------------- ### Get Pane PID Source: https://zellij.dev/documentation/plugin-api-commands.html Retrieves the PID of the process running inside a terminal pane. Requires the `ReadApplicationState` permission. ```rust #![allow(unused)] fn main() { fn get_pane_pid(pane_id: PaneId) -> Result } ``` -------------------------------- ### Get Tab Info Source: https://zellij.dev/documentation/plugin-api-commands.html Queries detailed information about a specific tab by its stable ID. Requires the `ReadApplicationState` permission. ```rust #![allow(unused)] fn main() { fn get_tab_info(tab_id: usize) -> Option } ``` -------------------------------- ### Get Focused Pane Info Source: https://zellij.dev/documentation/plugin-api-commands.html Retrieves the focused pane ID and its tab index. Requires the `ReadApplicationState` permission. ```rust #![allow(unused)] fn main() { fn get_focused_pane_info() -> Result<(usize, PaneId), String> } ``` ```rust #![allow(unused)] fn main() { match get_focused_pane_info() { Ok((tab_index, pane_id)) => { eprintln!("Focused pane {:?} in tab {}", pane_id, tab_index); }, Err(e) => eprintln!("Error: {}", e), } } ``` -------------------------------- ### Create Borderless Pinned Pane for Resource Monitor Source: https://zellij.dev/documentation/cli-recipes.html Creates a persistent, borderless overlay pane in the bottom-right corner to display system resource usage. Requires the `zellij` CLI and the `watch` command. ```bash zellij action new-pane --floating --borderless true --pinned true \ --width 30 --height 5 --x "100%" --y "100%" \ -- watch -n2 -t "free -h | head -3" ``` -------------------------------- ### Get Zellij Version Source: https://zellij.dev/documentation/plugin-api-commands.html Retrieves the version string of the running Zellij instance. Useful for checking plugin compatibility. ```rust #![allow(unused)] fn main() { fn get_zellij_version() -> String } ``` ```rust #![allow(unused)] fn main() { let version = get_zellij_version(); eprintln!("Running on Zellij {}", version); } ``` -------------------------------- ### Launch a Zellij Plugin from a URL Source: https://zellij.dev/documentation/zellij-plugin-and-pipe.html Use the `zellij plugin` command to load a plugin from a local or remote WASM file into a new pane. The URL can start with http(s), file:, or zellij:. ```bash zellij plugin -- https://path/to/my/plugin.wasm ``` ```bash zellij plugin [OPTIONS] [--] ``` ```bash Plugin URL, can either start with http(s), file: or zellij: ``` ```bash -c, --configuration Plugin configuration ``` ```bash -f, --floating Open the new pane in floating mode ``` ```bash -h, --help Print help information ``` ```bash --height The height if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%) ``` ```bash -i, --in-place Open the new pane in place of the current pane, temporarily suspending it ``` ```bash -s, --skip-plugin-cache Skip the plugin cache and force reloading of the plugin (good for development) ``` ```bash --width The width if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%) ``` ```bash -x, --x The x coordinates if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%) ``` ```bash -y, --y The y coordinates if the pane is floating as a bare integer (eg. 1) or percent (eg. 10%) ``` -------------------------------- ### Event::FailedToStartWebServer Source: https://zellij.dev/documentation/print.html Fired when Zellij fails to start the web server after a `start_web_server` command. The payload contains an error message. ```rust #![allow(unused)] fn main() { Event::FailedToStartWebServer(String) } ``` -------------------------------- ### Convert YAML to KDL Configuration Files Source: https://zellij.dev/documentation/migrating-yaml-config.html Use these commands to manually convert old YAML configuration, layout, and theme files to the new KDL format. Ensure the output path is correctly specified. ```bash $ zellij convert-config /path/to/my/config.yaml > /path/to/my/config.kdl ``` ```bash $ zellij convert-layout /path/to/my/layout.yaml > /path/to/my/layout.kdl ``` ```bash $ zellij convert-theme /path/to/my/theme.yaml > /path/to/my/theme.kdl ``` -------------------------------- ### Reload a Plugin Source: https://zellij.dev/documentation/print.html Use `zellij action start-or-reload-plugin` to either start a plugin if it's not running or reload it if it is. This is useful during development. ```bash zellij action start-or-reload-plugin file:/path/to/plugin.wasm ``` -------------------------------- ### Autostart Zellij Shell (Fish) Source: https://zellij.dev/documentation/integration.html This script autostarts a new Zellij shell if not already inside one. It's specifically for the Fish shell. ```fish if set -q ZELLIJ else zellij end ``` -------------------------------- ### Use inline KDL layout strings Source: https://zellij.dev/documentation/cli-recipes.html Pass raw KDL layout strings directly via the command line for dynamic configuration. ```bash zellij action new-tab --layout-string 'layout { pane split_direction="vertical" { pane; pane; }; }' ``` ```bash zellij action override-layout --layout-string 'layout { pane split_direction="vertical" { pane; pane; pane; }; }' ``` ```bash zellij --layout-string 'layout { pane split_direction="vertical" { pane; pane; }; }' ``` -------------------------------- ### Configure Zellij Web Server Settings Source: https://zellij.dev/documentation/print.html Configure various aspects of the Zellij web server, including whether it starts on startup, the IP and port to listen on, and SSL certificate paths. Also includes an option to enforce HTTPS on localhost. ```zellij-config web_server true // always start the web server on Zellij startup (default: false) web_server_ip "0.0.0.0" // the IP to listen on, 0.0.0.0 is all (default: 127.0.0.1) web_server_port 443 // the port to listen on (default: 8082) web_server_cert "/path/to/my/certs/localhost+3.pem" // SSL certificate web_server_key "/path/to/my/certs/localhost+3-key.pem" // SSL private key enforce_https_on_localhost true // whether to enforce an https certificate being present also when listening on localhost (default: false) ``` -------------------------------- ### Get Focused Tab Info Source: https://zellij.dev/documentation/print.html Extracts the currently active tab from a list of tab information. This is a local helper function. ```rust #![allow(unused)] fn main() { fn get_focused_tab(tab_infos: &Vec) -> Option } ``` ```rust #![allow(unused)] fn main() { match event { Event::TabUpdate(tabs) => { if let Some(focused) = get_focused_tab(&tabs) { eprintln!("Active tab: {}", focused.name); } true }, _ => false, } } ``` -------------------------------- ### Get Pane Running Command Source: https://zellij.dev/documentation/plugin-api-commands.html Retrieves the current running command (argv) in a terminal pane. Requires the `ReadApplicationState` permission. ```rust #![allow(unused)] fn main() { fn get_pane_running_command(pane_id: PaneId) -> Result, String> } ``` -------------------------------- ### Start New Tab with Inline Layout String Source: https://zellij.dev/documentation/print.html Create a new tab with a layout defined directly in the command line using `--layout-string`. This avoids the need for temporary layout files. ```bash zellij action new-tab --layout-string 'layout { pane split_direction="vertical" { pane; pane; }; }' ``` -------------------------------- ### Get Session Environment Variables Source: https://zellij.dev/documentation/plugin-api-commands.html Retrieves the environment variables present when the Zellij session was created. Requires the `ReadSessionEnvironmentVariables` permission. ```rust #![allow(unused)] fn main() { fn get_session_environment_variables() -> BTreeMap } ``` -------------------------------- ### List all panes with full details Source: https://zellij.dev/documentation/cli-recipes.html Use this command to list all panes with their detailed information in a table format. This is useful for a quick overview of the current session's panes. ```bash zellij action list-panes --all ``` -------------------------------- ### Get JSON output for all tabs Source: https://zellij.dev/documentation/cli-recipes.html Obtain a JSON representation of all tabs. This is useful for programmatic access to tab data and for scripting. ```bash zellij action list-tabs --json ``` -------------------------------- ### Basic Zellij Layout Structure Source: https://zellij.dev/documentation/print.html Defines a simple layout with two panes, one of which is configured to run 'htop'. ```kdl layout { pane pane split_direction="vertical" { pane pane command="htop" } } ``` -------------------------------- ### Handling PaneClosed Event Source: https://zellij.dev/documentation/print.html Example of handling the Event::PaneClosed. It removes the pane ID from a tracked list when a pane is closed. ```rust #![allow(unused)] fn main() { fn update(&mut self, event: Event) -> bool { match event { Event::PaneClosed(pane_id) => { self.tracked_panes.remove(&pane_id); true }, _ => false, } } } ``` -------------------------------- ### Configure Zellij Auto-Start for Fish Shell Source: https://zellij.dev/documentation/integration.html Adds the necessary command to your `$HOME/.config/fish/config.fish` file to enable Zellij auto-start for the Fish shell. Note potential version compatibility issues. ```fish if status is-interactive ... eval (zellij setup --generate-auto-start fish | string collect) end ``` -------------------------------- ### Set Default Layout Source: https://zellij.dev/documentation/options.html Specify the name of the layout file to load on startup. The layout must be in the layouts folder. Defaults to 'default'. ```zellij default_layout "compact" ``` -------------------------------- ### Layout for Project Exploration with Exa and Git Log Source: https://zellij.dev/documentation/print.html A layout designed for quickly exploring a new project, featuring panes for 'exa --color always -l' and 'git log'. ```zellij __ layout { pane split_direction="vertical" { pane pane split_direction="horizontal" { pane command="exa" { args "--color" "always" "-l" } pane command="git" { args "log" } } } } ``` -------------------------------- ### Define Basic Pane Templates Source: https://zellij.dev/documentation/creating-a-layout.html Create reusable pane configurations using 'pane_template'. Templates can define commands, arguments, and other attributes. ```zellij layout { pane_template name="htop" { command "htop" } pane_template name="htop-tree" { command "htop" args "--tree" borderless true } // the below will create a template with four panes // the top and bottom panes running htop and the two // middle panes running "htop --tree" without a pane frame htop htop-tree htop-tree htop } ``` -------------------------------- ### Monitor Pane in Background Session Source: https://zellij.dev/documentation/zellij-subscribe.html Example of subscribing to a pane within a background Zellij session, outputting in JSON format. ```bash $ zellij --session build-server subscribe --pane-id terminal_1 --format json ```