From e7d057926f4bbcdc70b4775b4c6227dcbf21aa8c Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 6 Feb 2025 12:27:56 -0700 Subject: Add alacritty extension script support. This allows an escape code to invoke user-defined extensions found in /home/rahm/.local/bin/alacritty-ext.sh. The terminal passes to this script the escape-code arguments. This allows things like opening links in the browser even through an ssh connection. --- alacritty_terminal/src/term/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs index 84945f52..54068504 100644 --- a/alacritty_terminal/src/term/mod.rs +++ b/alacritty_terminal/src/term/mod.rs @@ -1,6 +1,7 @@ //! Exports the `Term` type which is a high-level API for the Grid. use std::ops::{Index, IndexMut, Range}; +use std::process::Command; use std::sync::Arc; use std::{cmp, mem, ptr, slice, str}; @@ -1746,6 +1747,16 @@ impl Handler for Term { )); } + #[inline] + fn extension_script(&mut self, args: &Vec) { + match Command::new("/home/rahm/.local/bin/alacritty-ext.sh").args(args).output() { + Ok(_) => {}, + Err(v) => { + println!("Failed to run alacritty command. {}", v); + }, + } + } + #[inline] fn clear_screen(&mut self, mode: ansi::ClearMode) { trace!("Clearing screen: {:?}", mode); -- cgit