Thursday, February 20, 2025

How to Install and Configure Zellij Terminal as Tmux Alternative 2025


Zellij emerges as a cutting-edge, open-source terminal multiplexer, poised to revolutionize command-line workflows. Distinguishing itself from traditional tools like tmux and screen, Zellij introduces an innovative layout system, user-friendly keybindings, and a plugin architecture for extensive customization. The project's official repository, actively nurtured on GitHub, reflects a vibrant community dedicated to enhancing the terminal experience.

Key Features of Zellij

  • Pane Management: Zellij allows users to divide their terminal into multiple panes and tabs, configurable both horizontally and vertically, to suit diverse workflow needs.
  • Session Persistence: A notable advantage of Zellij is its session persistence, safeguarding work by automatically restoring sessions even after accidental terminal closures.
  • Customizable Layouts: It provides a range of pre-designed layouts for quick workspace configuration, alongside the flexibility to create and save custom layouts.
  • Plugin Support: Zellij's functionality can be significantly extended through plugins, enabling users to add bespoke features tailored to their specific requirements.
  • Mouse Support: Unlike some keyboard-centric multiplexers, Zellij integrates mouse interactions, offering a more intuitive user experience.
  • Status Bar: A built-in status bar at the screen's bottom provides real-time information, including system time, battery status, and session names, for at-a-glance monitoring.

Installing Zellij on Linux

Zellij's installation across various Linux distributions is streamlined through system package managers. Below are the commands for common distributions:

Bash
# On Debian, Ubuntu and Mint
sudo apt install zellij

# On RHEL/CentOS/Fedora and Rocky/AlmaLinux
sudo dnf install zellij

# On Gentoo Linux
sudo emerge -a sys-apps/zellij

# On Alpine Linux
sudo apk add zellij

# On Arch Linux
sudo pacman -S zellij

# On OpenSUSE
sudo zypper install zellij

# On FreeBSD
sudo pkg install zellij

For distributions without package availability, pre-built binaries from the latest release can be downloaded and added to your system's $PATH.

Bash
wget https://github.com/zellij-org/zellij/releases/download/v0.41.2/zellij-x86_64-unknown-linux-musl.tar.gz
tar -xvf zellij-x86_64-unknown-linux-musl.tar.gz
chmod +x zellij
sudo mv zellij /usr/local/bin/

Alternatively, users with Rust installed can compile and install Zellij using Cargo:

Bash
cargo install zellij

For a quick trial without installation, Zellij offers launch commands for different shells:

Bash
# For bash/zsh
bash <(curl -L https://zellij.dev/launch)

# For fish
bash (curl -L https://zellij.dev/launch | psub)

Getting Started with Zellij

Initiate Zellij by typing zellij in your terminal. Upon first launch, a setup wizard guides users to choose between keybinding modes. For newcomers, the 'Default Mode' is recommended for its straightforward keybindings.

Basic Zellij Commands

  • Split Panes:
    • Horizontal split: Ctrl + o then -
    • Vertical split: Ctrl + o then |
  • Switch Panes: Ctrl + o + Arrow keys (, , , )
  • Resize Panes: Ctrl + o + Shift + Arrow keys
  • Close Pane: Ctrl + o then x
  • Create New Tab: Ctrl + o then n
  • Switch Tabs: Ctrl + o then Tab

Working with Layouts

Zellij's layout feature allows users to load predefined workspace configurations using the command mode:

Bash
layout my_layout

Custom layouts can be defined by editing .kdl files, Zellij's human-readable configuration format.

Managing Sessions

Session management in Zellij mirrors other multiplexers, enabling users to handle multiple terminal sessions.

List active sessions:

Bash
zellij list-sessions

Attach to a specific session:

Bash
zellij attach session_name

Customizing Zellij

Extensive customization is available through Zellij's configuration file, typically located at ~/.config/zellij/config.kdl. This file allows modifications to keybindings, default layouts, and plugin configurations.

Example: Changing the prefix keybinding to Ctrl + b:

Code snippet
keybind {
    prefix "Ctrl-b"
}

Plugins and Extensions

Zellij's plugin system enhances its capabilities, with plugins written in any language interacting via Zellij's API. Popular plugins include:

  • Status Bar: For displaying system metrics.
  • File Picker: For in-terminal file Browse and opening.
  • Tab Management: For improved tab navigation.

Plugins are installed by placing script files in ~/.config/zellij/plugins and referencing them in the configuration file.

Conclusion

Zellij stands out as a robust and intuitive terminal multiplexer, offering a modern approach to terminal session management. Its adaptable layouts, learnable keybindings, and extensible plugin system make it a compelling choice for Linux users seeking to enhance their command-line efficiency. Whether for development or general command-line tasks, Zellij provides valuable tools to boost productivity.

0 comments:

Post a Comment