aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2026-03-07 16:33:05 +0100
committerGitHub <noreply@github.com>2026-03-07 16:33:05 +0100
commit58cb2267fd7994ad9abb2df9792ec452a2deab45 (patch)
treed0ab9dbbc147bd5db5b7dee5c1687069cc946d99 /src
parentUpdate CHANGELOG.md (diff)
downloadsl0ppij-58cb2267fd7994ad9abb2df9792ec452a2deab45.tar.gz
sl0ppij-58cb2267fd7994ad9abb2df9792ec452a2deab45.tar.xz
sl0ppij-58cb2267fd7994ad9abb2df9792ec452a2deab45.zip
Allow subscribing to pane viewport updates (renders) from the CLI (#4814)
* initial subscribe implementation * tests for subscribe * update cli help * rustfmt * add pr
Diffstat (limited to 'src')
-rw-r--r--src/commands.rs57
-rw-r--r--src/main.rs4
2 files changed, 61 insertions, 0 deletions
diff --git a/src/commands.rs b/src/commands.rs
index d00d1d04..77bdecec 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -442,6 +442,63 @@ pub(crate) fn send_action_to_session(
},
};
}
+pub(crate) fn subscribe_to_session(
+ subscribe_cli: zellij_utils::cli::SubscribeCli,
+ requested_session_name: Option<String>,
+ _config: Option<Config>,
+) {
+ let session_name = match get_active_session() {
+ ActiveSession::None => {
+ eprintln!("There is no active session!");
+ std::process::exit(1);
+ },
+ ActiveSession::One(session_name) => {
+ if let Some(ref requested) = requested_session_name {
+ if *requested != session_name {
+ eprintln!(
+ "Session '{}' not found. The following sessions are active:",
+ requested
+ );
+ eprintln!("{}", session_name);
+ std::process::exit(1);
+ }
+ }
+ session_name
+ },
+ ActiveSession::Many => {
+ let existing_sessions: Vec<String> = get_sessions()
+ .unwrap_or_default()
+ .iter()
+ .map(|s| s.0.clone())
+ .collect();
+ if let Some(session_name) = requested_session_name {
+ if existing_sessions.contains(&session_name) {
+ session_name
+ } else {
+ eprintln!(
+ "Session '{}' not found. The following sessions are active:",
+ session_name
+ );
+ list_sessions(false, false, true);
+ std::process::exit(1);
+ }
+ } else if let Ok(session_name) = envs::get_session_name() {
+ session_name
+ } else {
+ eprintln!("Please specify the session name to subscribe to. The following sessions are active:");
+ list_sessions(false, false, true);
+ std::process::exit(1);
+ }
+ },
+ };
+ let os_input = get_os_input(zellij_client::os_input_output::get_cli_client_os_input);
+ zellij_client::cli_client::start_subscribe_client(
+ Box::new(os_input),
+ &session_name,
+ subscribe_cli,
+ );
+}
+
pub(crate) fn convert_old_config_file(old_config_file: PathBuf) {
match File::open(&old_config_file) {
Ok(mut handle) => {
diff --git a/src/main.rs b/src/main.rs
index 1a0db7e1..ddca0f27 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,6 +25,10 @@ fn main() {
commands::send_action_to_session(*cli_action, opts.session, config);
std::process::exit(0);
}
+ if let Some(Command::Subscribe(subscribe_cli)) = opts.command {
+ commands::subscribe_to_session(subscribe_cli, opts.session, config);
+ std::process::exit(0);
+ }
if let Some(Command::Sessions(Sessions::Run {
command,
direction,