A plugin is a folder in config/plugins/<name>/ that contains a plugin.toml. RedShell loads
plugins at startup. To turn one off, add its id to plugins.disabled.
| Section | Effect |
|---|---|
[[commands]] |
Palette commands, namespaced <plugin>.<id>. You can bind them in [keybindings]. |
[[profiles]] |
Launch profiles. They appear in Open Profile and in the sidebar's Shells section. |
[[themes]] |
Theme files: tweakcn CSS or RedShell TOML. |
[[snippets]] |
Text inserted into the terminal via Insert Snippet. |
[hook] |
A long-running process that receives events and can send actions back. |
A command can do any combination of:
[[commands]]
id = "deploy"
title = "Deploy staging"
send_text = "make deploy-staging\n" # type into the active terminal
open = ["ssh", "-t", "staging"] # open a new tab running this argv
open_profile = "agent:claude" # open a registered profile
notify = "Deploy started" # show a toast
set_theme = "nord" # switch theme
hook = true # forward {"type":"command","command":"deploy"} to the hookRedShell starts [hook].command with [hook].args, using the plugin folder as the working
directory and REDSHELL_PLUGIN_ID set in the environment.
stdin, one JSON object per line:
{"type":"event","event":{"event":"started","version":"0.1.0"}}
{"type":"event","event":{"event":"session_started","session":"<uuid>","profile":"shell:bash","title":"bash"}}
{"type":"event","event":{"event":"session_title_changed","session":"<uuid>","title":"~/src"}}
{"type":"event","event":{"event":"command_submitted","session":"<uuid>","command":"cargo build"}}
{"type":"event","event":{"event":"session_exited","session":"<uuid>","exit_code":0}}
{"type":"event","event":{"event":"theme_changed","theme":"nord"}}
{"type":"event","event":{"event":"quitting"}}
{"type":"command","command":"deploy"}stdout, one action per line, at any time:
{"action":"notify","text":"Build finished"}
{"action":"send_text","text":"git status\n"}
{"action":"open","profile":{"id":"x","name":"htop","kind":"plugin","description":"","available":true,"command":{"program":"htop","args":[],"cwd":null,"env":{}}}}
{"action":"open_profile","id":"ssh:prod"}
{"action":"set_theme","theme":"rose-pine"}
{"action":"run_command","command":"session.search"}When RedShell quits, it kills the hook process. Events are written from a background thread and up to 1024 of them are buffered; a hook that stops reading stdin loses further events instead of freezing RedShell.
Compiled-in features use the same API as external plugins:
use redshell_plugin::{Plugin, PluginAction, PluginContext, PluginInfo};
struct Git;
impl Plugin for Git {
fn info(&self) -> PluginInfo {
PluginInfo { id: "git".into(), name: "Git".into(), ..Default::default() }
}
fn activate(&mut self, ctx: &mut PluginContext<'_>) -> anyhow::Result<()> {
ctx.command("status", "Git status");
ctx.snippet("git: amend", "git commit --amend --no-edit");
Ok(())
}
fn run_command(&mut self, command: &str) -> anyhow::Result<Vec<PluginAction>> {
Ok(match command {
"status" => vec![PluginAction::SendText { text: "git status\n".into() }],
_ => vec![],
})
}
}Register the plugin in AppState::load with plugins.register(Box::new(Git)). See the
built-in BuiltinSnippets plugin for a working example.
examples/plugins/hello shows every feature: commands, a profile,
a snippet, a CSS theme and a Python hook. Copy it into your plugins folder to try it.