Skip to content

Shakudo-io/zellij-smem-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zellij Memory Monitor Plugin

A Zellij plugin that displays aggregated memory usage in a nicely formatted table using smem. Shows PSS (Proportional Set Size) and RSS (Resident Set Size) metrics grouped by process category.

Features

  • Aggregated view - Groups processes by category (OpenCode, Node.js, Python, VS Code, MCP Servers, Zellij, etc.)
  • Color-coded - Green (<100MB), Yellow (<500MB), Red (>500MB PSS)
  • Auto-refresh - Updates every 5 seconds (configurable)
  • Modal interface - Opens as a floating pane, close with q or Esc
  • Keyboard controls - r to manually refresh

Screenshot

┌─────────────────────────────────────────────────────────────┐
│              Memory Usage Monitor (smem)                     │
│                                                              │
│  Category                            PSS          RSS  Procs │
│  ─────────────────────────────────────────────────────────── │
│  OpenCode                          1.4 GB       1.5 GB     4 │
│  VS Code Server                  795.5 MB     811.3 MB     3 │
│  Node.js                         312.4 MB     450.2 MB    12 │
│  Python                          201.2 MB     245.6 MB     6 │
│  MCP Servers                     156.8 MB     203.4 MB     5 │
│  Zellij                           59.6 MB      67.4 MB     1 │
│  Shell                            12.3 MB      18.9 MB     8 │
│  ─────────────────────────────────────────────────────────── │
│  TOTAL                             8.6 GB      12.0 GB   138 │
│                                                              │
│  [q/Esc] Close  [r] Refresh              Auto-refresh: 5s   │
└─────────────────────────────────────────────────────────────┘

Installation

Requirements

  • Zellij 0.40.0 or later
  • smem installed on the system
  • Rust toolchain (for building from source)

Install smem

# Debian/Ubuntu
sudo apt install smem

# Arch Linux
sudo pacman -S smem

# macOS (via Homebrew)
brew install smem

Quick Install (Pre-built)

mkdir -p ~/.config/zellij/plugins
curl -L https://github.com/shakudo-io/zellij-smem-plugin/releases/latest/download/zellij_smem_plugin.wasm \
  -o ~/.config/zellij/plugins/zellij_smem_plugin.wasm

Build from Source

git clone https://github.com/shakudo-io/zellij-smem-plugin.git
cd zellij-smem-plugin
./build.sh

The build script will:

  1. Install the wasm32-wasip1 Rust target if needed
  2. Build the plugin in release mode
  3. Copy the .wasm file to ~/.config/zellij/plugins/

Configuration

Add this to your Zellij config (~/.config/zellij/config.kdl):

Option 1: Session Mode (Recommended)

Add to the session keybinds section:

keybinds {
    session {
        bind "m" {
            LaunchOrFocusPlugin "file:~/.config/zellij/plugins/zellij_smem_plugin.wasm" {
                floating true
                move_to_focused_tab true
            }
            SwitchToMode "normal"
        }
    }
}

Usage: Press Ctrl+o then m to open the memory monitor.

Option 2: Direct Keybinding

keybinds {
    shared_except "locked" {
        bind "Ctrl Shift m" {
            LaunchOrFocusPlugin "file:~/.config/zellij/plugins/zellij_smem_plugin.wasm" {
                floating true
                move_to_focused_tab true
            }
        }
    }
}

Plugin Alias (Optional)

Add to the plugins section for easier reference:

plugins {
    memory-monitor location="file:~/.config/zellij/plugins/zellij_smem_plugin.wasm"
}

Keyboard Shortcuts

Key Action
q or Esc Close the plugin modal
r Manual refresh

For AI Agents

Installation Commands

# 1. Clone and build
git clone https://github.com/shakudo-io/zellij-smem-plugin.git /tmp/zellij-smem-plugin
cd /tmp/zellij-smem-plugin
rustup target add wasm32-wasip1
cargo build --release

# 2. Install plugin
mkdir -p ~/.config/zellij/plugins
cp target/wasm32-wasip1/release/zellij-smem-plugin.wasm ~/.config/zellij/plugins/zellij_smem_plugin.wasm

# 3. Add keybinding to zellij config
# In the session section of ~/.config/zellij/config.kdl, add:
# bind "m" { LaunchOrFocusPlugin "file:~/.config/zellij/plugins/zellij_smem_plugin.wasm" { floating true; move_to_focused_tab true } SwitchToMode "normal" }

Reload Plugin (in active Zellij session)

zellij action start-or-reload-plugin "file:$HOME/.config/zellij/plugins/zellij_smem_plugin.wasm"

Verify Installation

# Check plugin exists
ls -la ~/.config/zellij/plugins/zellij_smem_plugin.wasm

# Check smem is available
which smem

Memory Metrics Explained

  • PSS (Proportional Set Size): Memory unique to process + proportional share of shared memory. Best metric for actual memory consumption.
  • RSS (Resident Set Size): Total memory in RAM including shared libraries. Can overcount when libraries are shared between processes.

Process Categories

The plugin automatically groups processes into these categories:

Category Matches
OpenCode opencode
VS Code Server code-server
Node.js node, npm, npx
MCP Servers Node processes with mcp
Playwright Node processes with playwright
Python python, uv
Zellij zellij
Rust Toolchain cargo, rustc, rust-analyzer
Shell bash, sh, zsh, fish
System Services systemd, dbus, polkit
Git git

Processes not matching any category are shown by their original name. If there are more than 15 categories, smaller ones are aggregated into "Other".


Development

Project Structure

zellij-smem-plugin/
├── .cargo/config.toml    # WASM build target
├── Cargo.toml            # Rust dependencies
├── build.sh              # Build & install script
├── src/main.rs           # Plugin implementation
├── LICENSE               # MIT
└── README.md

Building for Development

# Build debug version
cargo build

# Build release version
cargo build --release

# Hot-reload in Zellij
zellij action start-or-reload-plugin "file:$(pwd)/target/wasm32-wasip1/debug/zellij-smem-plugin.wasm"

Dependencies

  • zellij-tile 0.43.1 - Zellij plugin SDK

License

MIT License - see LICENSE file.

Contributing

Issues and pull requests welcome at https://github.com/shakudo-io/zellij-smem-plugin

About

Zellij plugin that displays aggregated memory usage in a nice table format using smem

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors