返回资讯中心
外部精选
软件工程
#开发者实时流

Zellij:用 Rust 编写的终端工作区管理器,支持 WebAssembly 插件

来源标题:Zellij manages terminal workspaces with style

Zellij 是一款用 Rust 编写的终端复用器,支持 WebAssembly 插件系统,可控制其行为。该项目 2021 年发布 0.1.0-alpha,首个被更新日志承认的版本是 2021 年 4 月的 0.5.0-beta,初期缺少会话持久化和共享功能,此后已补齐。插件可用任何能编译为 WebAssembly 的语言编写,但目前仅正式支持 Rust。

Hacker News 最新chmaynard2026/11/17 · 今天30 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

The initial release, 0.1.0-alpha, was published in January 2021, though it seems to have been a quiet affair; the first release acknowledged by the changelog is 0.5.0-beta which was announced in April 2021. The project's announcement stated that its aim was to make Zellij "a general purpose application development platform in the future". The 0.5.0 release was a bit more modest than that, however; it handled terminal multiplexing, but did not yet have some of the basics that users had come to expect from Screen or tmux, such session persistence and sharing. These days, many terminal emulators let users create new tabs or split windows—but Screen and tmux allow users to "detach" from a session and resume it later, which makes life much easier. Zellij has since acquired those features and quite a few more.

It is written in Rust and it has a WebAssembly plugin system that can be used to control Zellij and manage its behavior. Tmux has a sort of third-party plugin system, but it does not seem to be something supported by the project itself.

Zellij plugins can be written in other languages as long as they can be compiled to WebAssembly, but Rust is the only supported language for plugins at the moment. Some of its user-interface features are, in fact, implemented using plugins: the default plugins source code provides good examples of what developers can accomplish with the plugin API.

The name comes from an Arabic word for a mosaic-tilework art form. The application's interface lacks the majesty and complex geometry of those classic tileworks, but Zellij does seem like an apt name for a project that lets users turn a terminal emulator into a tiled workspace with multiple panes and tabs containing their own applications.

The project's governance document notes that there are 13 current members who are empowered to make decisions for the project. They are expected to bring "larger and more controversial" topics to the full quorum of members. Aram Drevekenin is the "benevolent dictator for life": he is responsible for "steering the project and making large decisions regarding finances and collaboration". He has veto power over decisions made by the members, but only as a last resort.

A number of Linux distributions have Zellij packages in their repositories, but there are notable exceptions such as Debian and Fedora. Other distributions have packages but tend to be one or more releases behind. The project provides binaries for x86-64 and Arm 64-bit systems; it has a setup wizard to copy the binary to a "permanent folder", such as $home/.local/bin, and set up a desktop entry so that it appears in a desktop environment's application menus. Users can also choose to install it using Cargo, but the project recommends using operating-system packages. The project also warns against installing it from its main branch because it contains pre-release code that may be broken or contain unusable features.

Once installed, Zellij can be entirely keyboard-driven, but users can also make use of the mouse to manage most of its operations. For example, when Zellij is started, it shows a menu at the bottom of the screen that lists the primary modifier (which is used to access different modes) and a list of modes to manage windows (panes) or tabs, search through text in a window, resize windows, and more. Users can type Ctrl+p to enter pane mode, then n to create a new pane—or they can just use the mouse to click on the pane menu item, and then click the new button. Zellij also has a right-click mouse menu with a set of frequently used operations; the menu is editable via Zellij's settings, so users can add or remove operations as they wish.

Many users will want to either set up the unlock-first preset or configure alternate keybindings immediately after installation. By default, Zellij uses Ctrl as its primary modifier key, and Alt as its secondary modifier. For instance, Ctrl+t invokes the tab mode, and then users can type n for a new tab, r to rename the tab, Tab to cycle between tabs, and so forth.

The problem, of course, is that plenty of terminal applications also use Ctrl as a modifier key but Zellij intercepts it before it's passed on to the application. For example, I use aerc as my mail client, and several operations use Ctrl as part of the default keybindings. That conflicts with Zellij's defaults, though, because it uses Ctrl plus another character to switch between its modes. To get around that, the unlock-first preset requires users to type Ctrl+g to "unlock" the interface to use its other modes. So, to invoke the tab mode, a user would need to type Ctrl+g and then t.

Zellij makes it possible to reconfigure the defaults to avoid collisions without having to unlock modes first. I have configured Alt as the primary modifier—which does not seem to conflict with any of the applications I use regularly in the terminal—and Alt+Shift as the secondary modifier, which allows me to use aerc, Vim, and other terminal applications in Zellij without any hassles. For the purpose of this article, however, I will use the default keybindings in examples to avoid confusion.

As a longtime user of tmux, I initially resisted switching to Zellij for because I was hesitant to have to learn yet another set of key bindings. Clearly, more than a few other people felt the same way; the project added a tmux mode in 2022. It's not a full replica of tmux keybindings, but it does support a number of basic tmux shortcuts and might be useful for folks who want to make the switch without having to relearn the basics right away.

Like Screen and tmux, Zellij works inside any terminal emulator to manage a user's workspace—but, with the 0.46 release, the project added the Zellij Terminal to turn it into its own standalone application. Running zellij terminal starts a full terminal emulator that integrates with a Linux desktop environment just like any other desktop applications. It provides desktop notifications, such as a pop-up when task finishes in Zellij, and a tray icon that displays a count of notifications. The icon also has a right-click menu for quick access to common commands.

Naturally, it has the option of light or dark mode, and includes a wide selection of themes. If none of the included themes are just right, users can define their own—the documentation for theme definitions is quite comprehensive and should be more than enough to help tweak existing themes or create new ones. With the 0.46 release, the project added a settings screen that includes a built-in theme editor; users can simply tweak a theme by making a copy of the theme and adjusting its colors to suit.

The built-in terminal also moves Zellij closer to being what the project's developers envisioned when it was launched: an application development-platform. The user guide has instructions on using Zellij as a library so that developers can use it as a platform for their own applications.

As one would expect, Zellij supports splitting a terminal window into multiple panes to run different commands in each, creating tabs with their own sets of panes, and so forth. It goes a bit farther, though, and offers users the ability to create panes that sit above the rest of the windows and tabs in a floating layer. The default keybinding to create a floating pane is Alt+f; the same shortcut will dismiss the floating layer or re-summon it if it's needed again. The floating layer can contain multiple free-floating panes. Users can also manipulate the windows using the mouse rather than shortcuts, if they prefer—Zellij allows resizing and moving windows using the mouse as if it were a regular window manager.

It not only lets users manage their terminal workspace; it makes it easy to save a layout for later use. Layouts are stored as text files using the KDL document language and can be applied when a Zellij session is launched or applied to an existing session. A layout can not only define the number, position, and size of panes for a session—it can also specify commands to run within the panes. As an example, if a user wanted to start with a two-pane layout, with Vim running in one pane and top in the other, the configuration would look something like this:

layout { pane size=1 borderless=true { plugin location="zellij:bars" { role "tab-bar"} } pane split_direction="vertical" { pane command="top" pane command="vim" { args "/home/jzb/scratch.kdl" } } pane size=1 borderless=true { plugin location="status-bar" } }

The first layout stanza defines the tab bar at the top of the workspace and loads the built-in bars plugin. The next defines the middle two panes with top and vim commands running. Note that it's not necessary to define the size of these panes; they will simply fill whatever space that is not taken by the top and bottom panes, which do have the sizes specified. The last stanza loads the status-bar plugin which displays the current mode, the actions available, and the shortcuts the actions are assigned to. The final result will look like the screenshot shown below, though the theme may be different.

When a new session is launched, it is given a two-word name like "tremendous-goose", "zippy-platypus", or "judicious-yak". Sessions can be renamed if one finds the names too silly or just not memorable enough. The zellij sessions command will list all of the existing sessions, zellij attach session-name will attach to a session, and zellij kill-session session-name will kill the ill-fated session. Zellij does support auto-complete, so it's not necessary to type the entire session names.

Users can share sessions over the web using the built-in web server. When the server is started, Zellij displays a login token to be used to authenticate with a session; these are only displayed once and cannot be pulled up again. If a new one is needed, though, zellij web --create-token will generate a new token. Existing tokens can also be revoked, which is the only option for tokens one forgot to save the first time around.

Users can connect to a session with their web browser or with another Zellij session. For example, zellij attach https://my-server:8082/session-name would prompt the user for the authentication token and then bring up the remote session locally. The default port is 8082, though that (of course) can be changed as well. Web sharing can allow users to connect to a session with full access or read-only access. To share a session in read-only mode, users have to generate a read-only token. The documentation gives instructions on how to use self-signed TLS certificates to share sessions over HTTPS instead of HTTP.

The only real complaint I have with Zellij at this stage in its development is a minor one: the project does not have man pages. Its user documentation is excellent, and zellij command --help will display basic usage and options for its commands, but it would be nice to have more expansive documentation that does not require a web browser to get to. On the other hand, I can understand why the project has not invested any time in man pages; it is still undergoing fairly rapid development (three releases in 2026 so far), and it's a multi-platform application. I'd wager that Linux users are a large chunk of the project's audience, but man pages are not in much demand by Windows users.

Since the project is still pre-1.0, there are quite a few features on the roadmap that have yet to be implemented. The planned features are divided into three primary categories: configuration experience, plugin experience, and user experience. The project has a graphic divided into those three categories, with yellow boxes indicating the upcoming features (with links to their associated GitHub issues) and purple boxes for the features that have been implemented.

The project's CONTRIBUTING.md provides instructions on packaging Zellij for distributions, explains how to build Zellij,

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →