Identity: own names, directories, variables and app id

LLeMbas TTY installs and runs beside WezTerm without touching it:

- binaries llembas-tty, llembas-tty-gui, llembas-tty-mux-server (packages keep
  upstream's names);
- configuration in $XDG_CONFIG_HOME/llembas-tty/llembas-tty.lua or
  ~/.llembas-tty.lua; own data, cache and runtime directories;
- LLEMBAS_TTY_CONFIG_FILE / _CONFIG_DIR / _UNIX_SOCKET / _PANE / _EXECUTABLE
  replace the WEZTERM_ ones, which are neither read nor passed on, so neither
  program talks to the other's panes;
- window class, app id, notification id and bundle id eu.llembas.tty;
- panes get LLEMBAS_TTY=<version>; TERM_PROGRAM stays WezTerm;
- --version shows our version and the WezTerm version it is based on;
- the update check, which asks about WezTerm's releases, is off by default.

The LLeMbas layer (llembas/lua) is compiled in and offered as
require 'llembas'; with no configuration file the built-in one applies it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Fable 5.2 committed 2026-12-01 19:15:13 +00:00
1 parent 9863428c64
commit f3d4fe413c
38 files changed
+1967 -78

No files matched your search

+5 -4
View File
@@ -5,13 +5,14 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>wezterm-gui</string>
<!-- LLeMbas TTY: its own names and identifier, here and below -->
<string>llembas-tty-gui</string>
<key>CFBundleIdentifier</key>
<string>com.github.wez.wezterm</string>
<string>eu.llembas.tty</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>WezTerm</string>
<string>LLeMbas TTY</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
@@ -33,7 +34,7 @@
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>CFBundleDisplayName</key>
<string>WezTerm</string>
<string>LLeMbas TTY</string>
<key>NSRequiresAquaSystemAppearance</key>
<string>NO</string>
<key>NSAppleEventsUsageDescription</key>
+81 -16
View File
@@ -1025,9 +1025,10 @@ impl Config {
// multiple. In addition, it spawns a lot of subprocesses,
// so we do this bit "by-hand"
let mut paths = vec![PathPossibility::optional(HOME_DIR.join(".wezterm.lua"))];
// LLeMbas TTY: its own file names, never WezTerm's
let mut paths = vec![PathPossibility::optional(HOME_DIR.join(".llembas-tty.lua"))];
for dir in CONFIG_DIRS.iter() {
paths.push(PathPossibility::optional(dir.join("wezterm.lua")))
paths.push(PathPossibility::optional(dir.join("llembas-tty.lua")))
}
if cfg!(windows) {
@@ -1041,12 +1042,17 @@ impl Config {
// dir as the executable that will take precedence.
if let Ok(exe_name) = std::env::current_exe() {
if let Some(exe_dir) = exe_name.parent() {
paths.insert(0, PathPossibility::optional(exe_dir.join("wezterm.lua")));
// LLeMbas TTY: its own file name
paths.insert(
0,
PathPossibility::optional(exe_dir.join("llembas-tty.lua")),
);
}
}
}
if let Some(path) = std::env::var_os("WEZTERM_CONFIG_FILE") {
log::trace!("Note: WEZTERM_CONFIG_FILE is set in the environment");
// LLeMbas TTY: its own variable, WEZTERM_CONFIG_FILE is not honoured
if let Some(path) = std::env::var_os("LLEMBAS_TTY_CONFIG_FILE") {
log::trace!("Note: LLEMBAS_TTY_CONFIG_FILE is set in the environment");
paths.insert(0, PathPossibility::required(path.into()));
}
@@ -1077,8 +1083,23 @@ impl Config {
// We didn't find (or were asked to skip) a wezterm.lua file, so
// update the environment to make it simpler to understand this
// state.
std::env::remove_var("WEZTERM_CONFIG_FILE");
std::env::remove_var("WEZTERM_CONFIG_DIR");
// LLeMbas TTY: its own variables
std::env::remove_var("LLEMBAS_TTY_CONFIG_FILE");
std::env::remove_var("LLEMBAS_TTY_CONFIG_DIR");
// LLeMbas TTY: with no configuration file (and not asked to skip one),
// the built-in configuration applies the LLeMbas layer.
if !CONFIG_SKIP.load(Ordering::Relaxed) {
return match Self::try_builtin(overrides) {
Err(err) => LoadedConfig {
config: Err(err),
file_name: None,
lua: None,
warnings: vec![],
},
Ok(cfg) => cfg,
};
}
match Self::try_default() {
Err(err) => LoadedConfig {
@@ -1105,6 +1126,44 @@ impl Config {
})
}
/// LLeMbas TTY: evaluate the configuration that is built into the binary
/// (`llembas/lua/default-config.lua`). The same steps as `try_load`, with
/// the script taken from memory rather than from a file.
fn try_builtin(overrides: &wezterm_dynamic::Value) -> anyhow::Result<LoadedConfig> {
let lua = make_lua_context(Path::new(""))?;
let (config, warnings) =
wezterm_dynamic::Error::capture_warnings(|| -> anyhow::Result<Config> {
let cfg: Config;
let config: mlua::Value = smol::block_on(
lua.load(crate::llembas::DEFAULT_CONFIG)
.set_name("=llembas-tty/default-config.lua")
.eval_async(),
)?;
let config = Config::apply_overrides_to(&lua, config)?;
let config = Config::apply_overrides_obj_to(&lua, config, overrides)?;
cfg = Config::from_lua(config, &lua).context(
"Error converting lua value returned by the built-in configuration \
to Config struct",
)?;
cfg.check_consistency()?;
// Compute but discard the key bindings here so that we raise any
// problems earlier than we use them.
let _ = cfg.key_bindings();
Ok(cfg)
});
let cfg = config?;
Ok(LoadedConfig {
config: Ok(cfg.compute_extra_defaults(None)),
file_name: None,
lua: Some(lua),
warnings,
})
}
fn try_load(
path_item: &PathPossibility,
overrides: &wezterm_dynamic::Value,
@@ -1149,9 +1208,10 @@ impl Config {
// problems earlier than we use them.
let _ = cfg.key_bindings();
std::env::set_var("WEZTERM_CONFIG_FILE", p);
// LLeMbas TTY: its own variables
std::env::set_var("LLEMBAS_TTY_CONFIG_FILE", p);
if let Some(dir) = p.parent() {
std::env::set_var("WEZTERM_CONFIG_DIR", dir);
std::env::set_var("LLEMBAS_TTY_CONFIG_DIR", dir);
}
Ok(cfg)
});
@@ -1620,11 +1680,15 @@ impl Config {
// de-facto standard for identifying the terminal.
cmd.env("TERM_PROGRAM", "WezTerm");
cmd.env("TERM_PROGRAM_VERSION", crate::wezterm_version());
// LLeMbas TTY: how a program knows that it runs in this terminal
cmd.env("LLEMBAS_TTY", crate::llembas_tty_version());
}
}
fn default_check_for_updates() -> bool {
cfg!(not(feature = "distro-defaults"))
// LLeMbas TTY: off. Upstream's check asks GitHub about WezTerm's releases,
// which are not this program's, and nothing leaves the machine unasked.
false
}
fn default_pane_select_fg_color() -> RgbaColor {
@@ -1756,28 +1820,29 @@ fn default_font_size() -> f64 {
12.0
}
// LLeMbas TTY: its own cache, data and runtime directories, never WezTerm's
pub(crate) fn compute_cache_dir() -> anyhow::Result<PathBuf> {
if let Some(runtime) = dirs_next::cache_dir() {
return Ok(runtime.join("wezterm"));
return Ok(runtime.join("llembas-tty"));
}
Ok(crate::HOME_DIR.join(".local/share/wezterm"))
Ok(crate::HOME_DIR.join(".local/share/llembas-tty"))
}
pub(crate) fn compute_data_dir() -> anyhow::Result<PathBuf> {
if let Some(runtime) = dirs_next::data_dir() {
return Ok(runtime.join("wezterm"));
return Ok(runtime.join("llembas-tty"));
}
Ok(crate::HOME_DIR.join(".local/share/wezterm"))
Ok(crate::HOME_DIR.join(".local/share/llembas-tty"))
}
pub(crate) fn compute_runtime_dir() -> anyhow::Result<PathBuf> {
if let Some(runtime) = dirs_next::runtime_dir() {
return Ok(runtime.join("wezterm"));
return Ok(runtime.join("llembas-tty"));
}
Ok(crate::HOME_DIR.join(".local/share/wezterm"))
Ok(crate::HOME_DIR.join(".local/share/llembas-tty"))
}
pub fn pki_dir() -> anyhow::Result<PathBuf> {
+7 -3
View File
@@ -31,6 +31,8 @@ mod font;
mod frontend;
pub mod keyassignment;
mod keys;
// LLeMbas TTY: the built-in Lua layer
pub mod llembas;
pub mod lua;
pub mod meta;
mod scheme_data;
@@ -383,9 +385,10 @@ pub fn create_user_owned_dirs(p: &Path) -> anyhow::Result<()> {
}
fn xdg_config_home() -> PathBuf {
match std::env::var_os("XDG_CONFIG_HOME").map(|s| PathBuf::from(s).join("wezterm")) {
// LLeMbas TTY: its own directory, never WezTerm's
match std::env::var_os("XDG_CONFIG_HOME").map(|s| PathBuf::from(s).join("llembas-tty")) {
Some(p) => p,
None => HOME_DIR.join(".config").join("wezterm"),
None => HOME_DIR.join(".config").join("llembas-tty"),
}
}
@@ -395,7 +398,8 @@ fn config_dirs() -> Vec<PathBuf> {
#[cfg(unix)]
if let Some(d) = std::env::var_os("XDG_CONFIG_DIRS") {
dirs.extend(std::env::split_paths(&d).map(|s| PathBuf::from(s).join("wezterm")));
// LLeMbas TTY: its own directory, never WezTerm's
dirs.extend(std::env::split_paths(&d).map(|s| PathBuf::from(s).join("llembas-tty")));
}
dirs
+44
View File
@@ -0,0 +1,44 @@
//! LLeMbas TTY: the LLeMbas layer, built into the binary.
//!
//! The layer is Lua (`llembas/lua/` at the top of the repository). It is
//! compiled in as text and offered to every Lua context through
//! `package.preload`, so that a configuration file can say
//! `require('llembas').apply(config)`. With no configuration file at all,
//! `DEFAULT_CONFIG` is evaluated instead (see `Config::try_builtin`).
//!
//! Nothing here runs the layer: a module is only evaluated when it is
//! required.
use anyhow::Context;
use mlua::{Lua, Table};
/// The configuration used when the person has no configuration file.
pub const DEFAULT_CONFIG: &str = include_str!("../../llembas/lua/default-config.lua");
/// Module name as given to `require`, and its source.
const MODULES: &[(&str, &str)] = &[
(
"llembas",
include_str!("../../llembas/lua/llembas/init.lua"),
),
(
"llembas.core",
include_str!("../../llembas/lua/llembas/core.lua"),
),
];
pub fn register(lua: &Lua) -> anyhow::Result<()> {
let package: Table = lua.globals().get("package").context("get _G.package")?;
let preload: Table = package.get("preload").context("get package.preload")?;
for (name, source) in MODULES {
let loader = lua
.load(*source)
.set_name(format!("=llembas-tty/{}.lua", name))
.into_function()
.with_context(|| format!("compiling the built-in module {}", name))?;
preload
.set(*name, loader)
.with_context(|| format!("registering the built-in module {}", name))?;
}
Ok(())
}
+5 -1
View File
@@ -227,7 +227,8 @@ pub fn make_lua_context(config_file: &Path) -> anyhow::Result<Lua> {
array.insert(1, format!("{}/?/init.lua", path.display()));
}
prefix_path(&mut path_array, &crate::HOME_DIR.join(".wezterm"));
// LLeMbas TTY: its own directory, never WezTerm's
prefix_path(&mut path_array, &crate::HOME_DIR.join(".llembas-tty"));
for dir in crate::CONFIG_DIRS.iter() {
prefix_path(&mut path_array, dir);
}
@@ -385,6 +386,9 @@ end
func(&lua).context("calling SETUP_FUNCS")?;
}
// LLeMbas TTY: make the built-in layer available as `require 'llembas'`
crate::llembas::register(&lua).context("registering the llembas module")?;
Ok(lua)
}
+3 -2
View File
@@ -118,10 +118,11 @@ impl UnixDomain {
Some(cmd) => Ok(cmd.iter().map(Into::into).collect()),
None => Ok(vec![
std::env::current_exe()?
// LLeMbas TTY: its own binary names
.with_file_name(if cfg!(windows) {
"wezterm-mux-server.exe"
"llembas-tty-mux-server.exe"
} else {
"wezterm-mux-server"
"llembas-tty-mux-server"
})
.into_os_string(),
OsString::from("--daemonize"),
+21
View File
@@ -14,6 +14,27 @@ pub fn wezterm_version() -> &'static str {
.unwrap_or(&"someone forgot to call assign_version_info")
}
/// LLeMbas TTY: this program's own version, from the `VERSION` file at
/// the top of the repository at build time. `wezterm_version` stays
/// WezTerm's: programs and scripts compare it to detect features.
pub fn llembas_tty_version() -> &'static str {
include_str!("../../VERSION").trim()
}
/// LLeMbas TTY: what `--version` shows: our version and the WezTerm
/// version that it is based on.
pub fn llembas_tty_long_version() -> &'static str {
static LONG: OnceLock<String> = OnceLock::new();
match VERSION.get() {
// Not assigned yet (the gui parses its arguments before it is):
// our own version alone.
None => llembas_tty_version(),
Some(wezterm) => LONG
.get_or_init(|| format!("{} (based on WezTerm {})", llembas_tty_version(), wezterm))
.as_str(),
}
}
pub fn wezterm_target_triple() -> &'static str {
TRIPLE
.get()
+30 -6
View File
@@ -3,11 +3,33 @@ pub use ringlog::setup_logger;
use std::path::{Path, PathBuf};
pub fn set_wezterm_executable() {
// LLeMbas TTY: its own variable names. A WezTerm that started us must
// not be mistaken for us by what runs in our panes, so what it exported
// is dropped rather than passed on.
for name in [
"WEZTERM_EXECUTABLE",
"WEZTERM_EXECUTABLE_DIR",
"WEZTERM_CONFIG_FILE",
"WEZTERM_CONFIG_DIR",
"WEZTERM_PANE",
"WEZTERM_UNIX_SOCKET",
] {
std::env::remove_var(name);
}
if let Ok(exe) = std::env::current_exe() {
if let Some(dir) = exe.parent() {
std::env::set_var("WEZTERM_EXECUTABLE_DIR", dir);
std::env::set_var("LLEMBAS_TTY_EXECUTABLE_DIR", dir);
}
std::env::set_var("WEZTERM_EXECUTABLE", exe);
// LLeMbas TTY: always the launcher (the one with the `cli`
// subcommand), whichever of our binaries this process is.
std::env::set_var(
"LLEMBAS_TTY_EXECUTABLE",
exe.with_file_name(if cfg!(windows) {
"llembas-tty.exe"
} else {
"llembas-tty"
}),
);
}
}
@@ -52,9 +74,10 @@ pub fn fixup_appimage() {
// Since our AppImage includes multiple utilities, we want to
// be able to use them, so add that location to the PATH!
// WEZTERM_EXECUTABLE_DIR is set by `set_wezterm_executable`
// LLEMBAS_TTY_EXECUTABLE_DIR is set by `set_wezterm_executable`
// which is called before `fixup_appimage`
if let Some(dir) = std::env::var_os("WEZTERM_EXECUTABLE_DIR") {
// LLeMbas TTY: its own variable name
if let Some(dir) = std::env::var_os("LLEMBAS_TTY_EXECUTABLE_DIR") {
if let Some(path) = std::env::var_os("PATH") {
let mut paths = std::env::split_paths(&path).collect::<Vec<_>>();
paths.insert(0, PathBuf::from(dir));
@@ -86,8 +109,9 @@ pub fn fixup_appimage() {
/// However, if we are using the system wezterm to spawn a portable
/// AppImage then we want these to not take effect.
fn clean_wezterm_config_env() {
std::env::remove_var("WEZTERM_CONFIG_FILE");
std::env::remove_var("WEZTERM_CONFIG_DIR");
// LLeMbas TTY: its own variable names
std::env::remove_var("LLEMBAS_TTY_CONFIG_FILE");
std::env::remove_var("LLEMBAS_TTY_CONFIG_DIR");
}
if config::HOME_DIR.starts_with(append_extra_file_name_suffix(&appimage, ".home")) {
+8
View File
@@ -0,0 +1,8 @@
-- LLeMbas TTY: the configuration used when the person has none of their own
-- ($XDG_CONFIG_HOME/llembas-tty/llembas-tty.lua or ~/.llembas-tty.lua).
-- It is the terminal's defaults with the LLeMbas layer applied. A person's
-- own file starts from the same four lines.
local wezterm = require 'wezterm'
local config = wezterm.config_builder()
require('llembas').apply(config)
return config
File diff suppressed because it is too large. Load diff
+659
View File
@@ -0,0 +1,659 @@
-- LLeMbas TTY: the LLeMbas layer.
--
-- local wezterm = require 'wezterm'
-- local config = wezterm.config_builder()
-- require('llembas').apply(config) -- or apply(config, { … })
-- return config
--
-- A plain terminal by default: applying the layer binds keys, adds entries to
-- the command palette and registers event handlers, and that is all. No
-- process is started, no text of any pane is read and nothing leaves the
-- machine until the person presses one of those keys or picks one of those
-- entries. The session bar reads only the variables that a program in the
-- pane set for the terminal (OSC 1337 SetUserVar), never the pane's text.
--
-- Everything that decides something is in llembas.core (pure, tested);
-- this file is the part that talks to the terminal.
local wezterm = require 'wezterm'
local core = require 'llembas.core'
local M = {}
M.core = core
local act = wezterm.action
local opts = core.defaults()
local registered = false
-- Events of the layer. A key or a palette entry emits one of these.
local EV = {
ask = 'llembas-ask',
ask_screen = 'llembas-ask-screen',
ask_line = 'llembas-ask-line',
ask_screen_line = 'llembas-ask-screen-line',
new_session = 'llembas-new-session',
resume = 'llembas-resume',
resume_pick = 'llembas-resume-pick',
toggle_display = 'llembas-toggle-display',
private = 'llembas-private',
login = 'llembas-login',
dismiss = 'llembas-dismiss',
}
M.events = EV
----------------------------------------------------------------------------
-- State that outlives a configuration reload. wezterm.GLOBAL holds only
-- strings, numbers, booleans and tables with string keys.
local function global(section)
local name = 'llembas_' .. section
if wezterm.GLOBAL[name] == nil then
wezterm.GLOBAL[name] = {}
end
return wezterm.GLOBAL[name]
end
local function pane_key(pane_id)
return 'p' .. tostring(pane_id)
end
function M.is_private(pane_id)
return global('private')[pane_key(pane_id)] == true
end
local function set_private(pane_id, on)
global('private')[pane_key(pane_id)] = on and true or false
end
----------------------------------------------------------------------------
-- Talking to the person
local function is_windows()
return wezterm.target_triple:find('windows', 1, true) ~= nil
end
-- A message in the terminal itself: an overlay with one line to dismiss it.
local function tell(window, pane, message)
wezterm.log_warn('LLeMbas: ' .. message:gsub('\r\n', ' '))
window:perform_action(
act.InputSelector {
title = 'LLeMbas',
description = message .. '\r\n',
choices = { { label = 'OK', id = 'ok' } },
action = act.EmitEvent(EV.dismiss),
},
pane
)
end
----------------------------------------------------------------------------
-- The LLeMbas CLI
local function file_exists(path)
local f = io.open(path, 'r')
if f then
f:close()
return true
end
return false
end
-- The path of the CLI, or nil. Looks at files only; starts nothing.
function M.find_cli()
local list = core.cli_candidates(opts.cli, wezterm.executable_dir, os.getenv 'PATH', is_windows())
for _, candidate in ipairs(list) do
if file_exists(candidate) then
return candidate
end
end
return nil
end
-- The CLI, or nil after telling the person why not.
local function need_cli(window, pane)
local cli = M.find_cli()
if cli then
return cli
end
local told = global('told')
if told.cli_missing then
tell(window, pane, core.messages.cli_missing_short)
else
told.cli_missing = true
tell(window, pane, core.messages.cli_missing)
end
return nil
end
-- Does this CLI know about terminals? Asked once per CLI path, at the first
-- thing that needs it (never at startup). The decision itself is
-- core.cli_supports_terminal.
local function cli_knows_terminals(window, pane, cli)
local cache = global('cli_version')
local key = 'v:' .. cli
local version = cache[key]
if version == nil then
local ok, stdout = wezterm.run_child_process { cli, '--version' }
version = ok and core.one_line(stdout or '', 64) or ''
cache[key] = version
end
local supports = core.cli_supports_terminal(version)
if supports == false then
tell(window, pane, string.format(core.messages.cli_too_old, version, core.MIN_CLI_VERSION))
return false
end
return true
end
----------------------------------------------------------------------------
-- Panes
local function pane_session(pane)
return core.session_from_vars(pane:get_user_vars())
end
local function pane_cwd(pane)
local ok, value = pcall(function()
return pane:get_current_working_dir()
end)
if ok then
return core.cwd_from(value)
end
return nil
end
-- The LLeMbas pane of the tab that `pane` is in (another pane rather than
-- `pane` itself when there are several), or nil.
local function session_pane_of_tab(pane)
local tab = pane:tab()
if not tab then
return nil
end
local by_id = {}
local list = {}
for _, p in ipairs(tab:panes()) do
local id = p:pane_id()
by_id[id] = p
list[#list + 1] = { pane_id = id, user_vars = p:get_user_vars() }
end
local id = core.find_session_pane(list, pane:pane_id())
return id and by_id[id] or nil
end
local function is_local(pane)
local ok, name = pcall(function()
return pane:get_domain_name()
end)
return not ok or name == 'local'
end
-- Start the CLI in a new pane beside `pane`.
local function split_with(pane, args)
return pane:split {
direction = opts.split.direction,
size = opts.split.size,
args = args,
cwd = pane_cwd(pane),
}
end
local function spawn_cli(window, pane, args)
if opts.new_session_in == 'tab' then
window:perform_action(act.SpawnCommandInNewTab { args = args, cwd = pane_cwd(pane) }, pane)
return nil
end
return split_with(pane, args)
end
-- Text for a session that is still starting: it is sent when the pane first
-- says that it is idle (user-var-changed, below), and dropped after a minute.
local PENDING_SECONDS = 60
local function send_when_ready(pane, kind, text)
local key = pane_key(pane:pane_id())
global('pending_kind')[key] = kind
global('pending_at')[key] = os.time()
global('pending_text')[key] = text
end
local function send_question(pane, question)
pane:send_paste(question)
pane:send_text '\r'
end
local function deliver_pending(pane)
local key = pane_key(pane:pane_id())
local texts = global('pending_text')
local text = texts[key]
if type(text) ~= 'string' or text == '' then
return
end
texts[key] = ''
local at = global('pending_at')[key]
if type(at) ~= 'number' or os.time() - at > PENDING_SECONDS then
return
end
if global('pending_kind')[key] == 'question' then
send_question(pane, text)
else
pane:send_text(text .. '\r')
end
end
----------------------------------------------------------------------------
-- Terminal context
-- The directory the context files live in: the terminal's own runtime
-- directory (where its socket is), which only the person can read.
local function runtime_dir()
local sock = os.getenv 'LLEMBAS_TTY_UNIX_SOCKET'
if sock and sock ~= '' then
local dir = sock:match('^(.*)[/\\][^/\\]+$')
if dir and dir ~= '' then
return dir
end
end
local xdg = os.getenv 'XDG_RUNTIME_DIR'
if xdg and xdg ~= '' then
return xdg .. '/llembas-tty'
end
return wezterm.home_dir .. '/.local/share/llembas-tty'
end
local function random_hex()
local f = io.open('/dev/urandom', 'rb')
if f then
local bytes = f:read(16)
f:close()
if bytes and #bytes == 16 then
return core.hex(bytes)
end
end
local parts = {}
for i = 1, 4 do
parts[i] = string.format('%08x', math.random(0, 0x7fffffff))
end
return table.concat(parts)
end
local function sweep(dir, now)
local ok, entries = pcall(wezterm.read_dir, dir)
if not ok or type(entries) ~= 'table' then
return
end
for _, path in ipairs(entries) do
if core.is_stale_context_file(path, now) then
os.remove(path)
end
end
end
-- What the pane shows, as the table of the context file; or nil and why not.
-- explicit_screen: the person asked about the screen itself, so the visible
-- screen is taken even from a full-screen program.
function M.gather_context(pane, explicit_screen)
if not opts.context.enabled then
return nil, 'off'
end
if M.is_private(pane:pane_id()) then
return nil, 'private'
end
local meta = pane:get_metadata() or {}
if meta.password_input then
return nil, 'password'
end
local limits = opts.context
local alt = pane:is_alt_screen_active()
local blocks = core.array {}
local screen
-- Asked about the screen: the screen alone. Otherwise the command blocks,
-- and the screen only when the shell marks none. A full-screen program
-- (the alternate screen) gives nothing unless asked.
local want_screen
if alt then
want_screen = explicit_screen or limits.alt_screen
elseif explicit_screen then
want_screen = true
else
blocks = core.blocks_from_zones(pane:get_semantic_zones(), function(zone)
return pane:get_text_from_semantic_zone(zone)
end, limits)
want_screen = #blocks == 0
end
if want_screen then
screen = core.tail(core.clean(pane:get_lines_as_text(), true), limits.screen_lines, limits.output_bytes)
end
local shell
local ok, program = pcall(function()
return pane:get_foreground_process_name()
end)
if ok then
shell = core.shell_name(program)
end
return core.context {
pane = pane:pane_id(),
cwd = pane_cwd(pane),
shell = shell,
blocks = blocks,
screen = screen,
}
end
-- Write a context to a new file that only the person can read.
-- Returns its path, or nil and why not.
local function write_context(ctx)
local dir = runtime_dir()
local now = os.time()
sweep(dir, now)
local json = core.encode_context(ctx)
local sep = is_windows() and '\\' or '/'
local path = dir .. sep .. core.context_file_name(now, random_hex())
-- Made empty first and closed to everybody else before anything is written.
local f, err = io.open(path, 'w')
if not f then
return nil, tostring(err)
end
f:close()
if not is_windows() then
local ok = wezterm.run_child_process { 'chmod', '600', path }
if not ok then
os.remove(path)
return nil, 'chmod failed'
end
end
f, err = io.open(path, 'w')
if not f then
os.remove(path)
return nil, tostring(err)
end
f:write(json)
f:close()
return path
end
----------------------------------------------------------------------------
-- Ask the model
local function ask(window, pane, line, explicit_screen)
local question = core.question_text(line or '')
if question == '' then
return
end
local cli = need_cli(window, pane)
if not cli then
return
end
if not is_local(pane) then
tell(window, pane, core.messages.remote)
return
end
if not cli_knows_terminals(window, pane, cli) then
return
end
-- Asked from inside the LLeMbas pane: it is simply typed there.
if pane_session(pane) then
send_question(pane, question)
return
end
local path
local ctx, why = M.gather_context(pane, explicit_screen)
if ctx then
local err
path, err = write_context(ctx)
if not path then
tell(window, pane, string.format(core.messages.write_failed, core.one_line(err or '', 120)))
end
elseif why == 'private' then
tell(window, pane, core.messages.private)
elseif why == 'password' then
tell(window, pane, core.messages.password)
end
local target = session_pane_of_tab(pane)
if target then
if path then
target:send_text(core.context_command(path) .. '\r')
end
send_question(target, question)
return
end
local args = { cli }
if path then
args[#args + 1] = '--terminal-context'
args[#args + 1] = path
end
local new_pane = split_with(pane, args)
if new_pane then
send_when_ready(new_pane, 'question', question)
end
end
local function prompt_for(event, description)
return function(window, pane)
window:perform_action(
act.PromptInputLine {
description = description,
prompt = 'ask> ',
action = act.EmitEvent(event),
},
pane
)
end
end
----------------------------------------------------------------------------
-- Sessions
local function new_session(window, pane)
local cli = need_cli(window, pane)
if cli then
spawn_cli(window, pane, { cli })
end
end
local function login(window, pane)
local cli = need_cli(window, pane)
if cli then
split_with(pane, { cli, 'login' })
end
end
local function resume(window, pane)
local cli = need_cli(window, pane)
if not cli then
return
end
local choices
local ok, stdout = wezterm.run_child_process { cli, 'sessions', '--json' }
if ok and type(stdout) == 'string' then
local decode = wezterm.serde and wezterm.serde.json_decode or wezterm.json_parse
local parsed, decoded = pcall(decode, stdout)
if parsed then
choices = core.session_choices(decoded)
end
end
if choices then
window:perform_action(
act.InputSelector {
title = 'LLeMbas: resume a session',
choices = choices,
fuzzy = true,
action = act.EmitEvent(EV.resume_pick),
},
pane
)
return
end
-- A CLI with no list for programs: its own session list, in a new pane.
local new_pane = split_with(pane, { cli })
if new_pane then
send_when_ready(new_pane, 'command', '/sessions')
end
end
local function resume_pick(window, pane, id)
if not core.is_session_id(id) then
return
end
local cli = need_cli(window, pane)
if cli then
spawn_cli(window, pane, { cli, '-s', id })
end
end
local function toggle_display(window, pane)
local target = pane_session(pane) and pane or session_pane_of_tab(pane)
if not target then
tell(window, pane, core.messages.no_session_pane)
return
end
window:perform_action(act.SendKey { key = 'd', mods = 'ALT' }, target)
end
local function toggle_private(window, pane)
local id = pane:pane_id()
local on = not M.is_private(id)
set_private(id, on)
if not opts.session_bar then
tell(window, pane, on and core.messages.private_on or core.messages.private_off)
end
end
----------------------------------------------------------------------------
-- The session bar and the tab mark
local function update_status(window, pane)
local shown = global('bar')
local key = 'w' .. tostring(window:window_id())
local items = core.bar_items(pane_session(pane), opts.bar.fields, M.is_private(pane:pane_id()))
if items then
window:set_right_status(wezterm.format(items))
shown[key] = true
elseif shown[key] then
-- only what the layer itself put there is ever cleared
window:set_right_status ''
shown[key] = false
end
end
local function format_tab_title(tab, _, _, config, _, max_width)
local show_index, zero_based = true, false
pcall(function()
show_index = config.show_tab_index_in_tab_bar
zero_based = config.tab_and_split_indices_are_zero_based
end)
return core.tab_title(tab, { max_width = max_width, show_index = show_index, zero_based = zero_based })
end
local PALETTE = {
{ 'LLeMbas: ask the model', 'ask', 'md_comment_question_outline' },
{ 'LLeMbas: ask about this screen', 'ask_screen', 'md_monitor_eye' },
{ 'LLeMbas: new session here', 'new_session', 'md_plus_box_outline' },
{ 'LLeMbas: resume a session', 'resume', 'md_history' },
{ 'LLeMbas: toggle side display', 'toggle_display', 'md_dock_right' },
{ 'LLeMbas: private pane on/off', 'private', 'md_eye_off_outline' },
{ 'LLeMbas: log in', 'login', 'md_login' },
}
local function palette()
local entries = {}
for i, e in ipairs(PALETTE) do
entries[i] = { brief = e[1], action = act.EmitEvent(EV[e[2]]), icon = e[3] }
end
return entries
end
----------------------------------------------------------------------------
local function register_events()
if registered then
return
end
registered = true
wezterm.on(EV.ask, prompt_for(EV.ask_line, 'Ask LLeMbas. It is given the last commands of this pane and their output.'))
wezterm.on(EV.ask_screen, prompt_for(EV.ask_screen_line, 'Ask LLeMbas about what is on this screen.'))
wezterm.on(EV.ask_line, function(window, pane, line)
ask(window, pane, line, false)
end)
wezterm.on(EV.ask_screen_line, function(window, pane, line)
ask(window, pane, line, true)
end)
wezterm.on(EV.new_session, new_session)
wezterm.on(EV.resume, resume)
wezterm.on(EV.resume_pick, resume_pick)
wezterm.on(EV.toggle_display, toggle_display)
wezterm.on(EV.private, toggle_private)
wezterm.on(EV.login, login)
wezterm.on(EV.dismiss, function() end)
wezterm.on('user-var-changed', function(_, pane, name, value)
if name == 'lembas_state' and value == 'idle' then
deliver_pending(pane)
end
end)
if opts.session_bar then
wezterm.on('update-status', update_status)
end
if opts.tab_marker then
wezterm.on('format-tab-title', format_tab_title)
end
if opts.palette then
wezterm.on('augment-command-palette', palette)
end
end
local KEY_EVENTS = {
ask = EV.ask,
new_session = EV.new_session,
resume = EV.resume,
toggle_display = EV.toggle_display,
private = EV.private,
}
-- apply(config, options): add the layer to a configuration. Returns config.
function M.apply(config, options)
local warnings
opts, warnings = core.options(options)
for _, w in ipairs(warnings) do
wezterm.log_warn('llembas: ' .. w)
end
M.options = opts
if not opts.enabled then
return config
end
local keys = config.keys or {}
for _, name in ipairs { 'ask', 'new_session', 'resume', 'toggle_display', 'private' } do
local k = opts.keys[name]
if k then
keys[#keys + 1] = { key = k.key, mods = k.mods, action = act.EmitEvent(KEY_EVENTS[name]) }
end
end
config.keys = keys
if opts.autocomplete then
-- The shipped shell integration completes the prompt only when it sees this.
local env = config.set_environment_variables or {}
env.LLEMBAS_TTY_AUTOCOMPLETE = '1'
local cli = M.find_cli()
if cli then
env.LLEMBAS_TTY_CLI = cli
end
config.set_environment_variables = env
end
register_events()
return config
end
return M
+5 -3
View File
@@ -476,10 +476,12 @@ impl LocalDomain {
if let Some(dir) = command_dir {
cmd.cwd(dir);
}
if let Ok(sock) = std::env::var("WEZTERM_UNIX_SOCKET") {
cmd.env("WEZTERM_UNIX_SOCKET", sock);
// LLeMbas TTY: its own variable names, so that neither this program
// nor a WezTerm running beside it talks to the other's panes.
if let Ok(sock) = std::env::var("LLEMBAS_TTY_UNIX_SOCKET") {
cmd.env("LLEMBAS_TTY_UNIX_SOCKET", sock);
}
cmd.env("WEZTERM_PANE", pane_id.to_string());
cmd.env("LLEMBAS_TTY_PANE", pane_id.to_string());
if let Some(agent) = Mux::get().agent.as_ref() {
cmd.env("SSH_AUTH_SOCK", agent.path());
}
+6 -4
View File
@@ -1223,7 +1223,9 @@ impl Client {
prefer_mux: bool,
class_name: &str,
) -> anyhow::Result<config::UnixDomain> {
match std::env::var_os("WEZTERM_UNIX_SOCKET") {
// LLeMbas TTY: its own variable names here and below; WezTerm's own
// are never read, so a WezTerm pane that starts us is not taken for ours.
match std::env::var_os("LLEMBAS_TTY_UNIX_SOCKET") {
Some(path) if !path.is_empty() => Ok(config::UnixDomain {
socket_path: Some(path.into()),
..Default::default()
@@ -1245,7 +1247,7 @@ impl Client {
.first()
.ok_or_else(|| {
anyhow!(
"no default unix domain is configured and WEZTERM_UNIX_SOCKET \
"no default unix domain is configured and LLEMBAS_TTY_UNIX_SOCKET \
is not set in the environment"
)
})?
@@ -1315,7 +1317,7 @@ impl Client {
let pane_id: PaneId = match pane_id {
Some(p) => p,
None => {
if let Ok(pane) = std::env::var("WEZTERM_PANE") {
if let Ok(pane) = std::env::var("LLEMBAS_TTY_PANE") {
pane.parse()?
} else {
let mut clients = self.list_clients().await?.clients;
@@ -1323,7 +1325,7 @@ impl Client {
clients.sort_by(|a, b| b.last_input.cmp(&a.last_input));
if clients.is_empty() {
anyhow::bail!(
"--pane-id was not specified and $WEZTERM_PANE
"--pane-id was not specified and $LLEMBAS_TTY_PANE
is not set in the environment, and I couldn't
determine which pane was currently focused"
);
+6 -5
View File
@@ -4,7 +4,8 @@ use config::{GuiPosition, SshParameters};
use std::ffi::OsString;
use std::path::PathBuf;
pub const DEFAULT_WINDOW_CLASS: &str = "org.wezfurlong.wezterm";
// LLeMbas TTY: its own window class / app id
pub const DEFAULT_WINDOW_CLASS: &str = "eu.llembas.tty";
/// Helper for parsing config overrides
pub fn name_equals_value(arg: &str) -> Result<(String, String), String> {
@@ -62,7 +63,7 @@ pub struct StartCommand {
pub _cmd: bool,
/// Override the default windowing system class.
/// The default is "org.wezfurlong.wezterm".
/// The default is "eu.llembas.tty".
/// Under X11 and Windows this changes the window class.
/// Under Wayland this changes the app_id.
/// This changes the class for all windows spawned by this
@@ -143,7 +144,7 @@ pub struct SshCommand {
pub verbose: bool,
/// Override the default windowing system class.
/// The default is "org.wezfurlong.wezterm".
/// The default is "eu.llembas.tty".
/// Under X11 and Windows this changes the window class.
/// Under Wayland this changes the app_id.
/// This changes the class for all windows spawned by this
@@ -175,7 +176,7 @@ pub struct SerialCommand {
pub baud: Option<usize>,
/// Override the default windowing system class.
/// The default is "org.wezfurlong.wezterm".
/// The default is "eu.llembas.tty".
/// Under X11 and Windows this changes the window class.
/// Under Wayland this changes the app_id.
/// This changes the class for all windows spawned by this
@@ -213,7 +214,7 @@ pub struct ConnectCommand {
pub new_tab: bool,
/// Override the default windowing system class.
/// The default is "org.wezfurlong.wezterm".
/// The default is "eu.llembas.tty".
/// Under X11 and Windows this changes the window class.
/// Under Wayland this changes the app_id.
/// This changes the class for all windows spawned by this
+6
View File
@@ -9,6 +9,12 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
# LLeMbas TTY: its own binary name, so that it installs beside WezTerm.
# The package keeps upstream's name.
[[bin]]
name = "llembas-tty-gui"
path = "src/main.rs"
[features]
default = ["vendored-fonts", "wayland"]
wayland = ["window/wayland"]
+10 -5
View File
@@ -66,9 +66,11 @@ pub use selection::SelectionMode;
pub use termwindow::{set_window_class, set_window_position, TermWindow, ICON_DATA};
#[derive(Debug, Parser)]
// LLeMbas TTY: its own name and version
#[command(
about = "Wez's Terminal Emulator\nhttp://github.com/wezterm/wezterm",
version = config::wezterm_version()
name = "llembas-tty-gui",
about = "LLeMbas TTY: a terminal with LLeMbas built in, based on Wez's Terminal Emulator\nhttp://github.com/wezterm/wezterm",
version = config::llembas_tty_long_version()
)]
struct Opt {
/// Skip loading wezterm.lua
@@ -412,7 +414,8 @@ async fn async_run_terminal_gui(
) -> anyhow::Result<()> {
let unix_socket_path =
config::RUNTIME_DIR.join(format!("gui-sock-{}", unsafe { libc::getpid() }));
std::env::set_var("WEZTERM_UNIX_SOCKET", unix_socket_path.clone());
// LLeMbas TTY: its own variable name
std::env::set_var("LLEMBAS_TTY_UNIX_SOCKET", unix_socket_path.clone());
wezterm_blob_leases::register_storage(Arc::new(
wezterm_blob_leases::simple_tempdir::SimpleTempDir::new_in(&*config::CACHE_DIR)?,
))?;
@@ -561,7 +564,8 @@ impl Publish {
"Running GUI is a different executable from us, will start a new one");
}
if vers.config_file_path
!= std::env::var_os("WEZTERM_CONFIG_FILE").map(Into::into)
// LLeMbas TTY: its own variable name
!= std::env::var_os("LLEMBAS_TTY_CONFIG_FILE").map(Into::into)
{
*self = Publish::NoConnectNoPublish;
anyhow::bail!(
@@ -1172,7 +1176,8 @@ fn run() -> anyhow::Result<()> {
{
unsafe {
::windows::Win32::UI::Shell::SetCurrentProcessExplicitAppUserModelID(
::windows::core::PCWSTR(wide_string("org.wezfurlong.wezterm").as_ptr()),
// LLeMbas TTY: its own application id
::windows::core::PCWSTR(wide_string("eu.llembas.tty").as_ptr()),
)
.unwrap();
}
@@ -868,7 +868,8 @@ impl SessionHandler {
codec_vers: CODEC_VERSION,
version_string: config::wezterm_version().to_owned(),
executable_path,
config_file_path: std::env::var_os("WEZTERM_CONFIG_FILE")
// LLeMbas TTY: its own variable name
config_file_path: std::env::var_os("LLEMBAS_TTY_CONFIG_FILE")
.map(Into::into),
})))
}
+6
View File
@@ -8,6 +8,12 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
# LLeMbas TTY: its own binary name, so that it installs beside WezTerm.
# The package keeps upstream's name.
[[bin]]
name = "llembas-tty-mux-server"
path = "src/main.rs"
[dependencies]
anyhow.workspace = true
async_ossl.workspace = true
+9 -5
View File
@@ -15,9 +15,11 @@ use wezterm_mux_server_impl::update_mux_domains_for_server;
mod daemonize;
#[derive(Debug, Parser)]
// LLeMbas TTY: its own name and version
#[command(
about = "Wez's Terminal Emulator\nhttp://github.com/wezterm/wezterm",
version = config::wezterm_version(),
name = "llembas-tty-mux-server",
about = "LLeMbas TTY: a terminal with LLeMbas built in, based on Wez's Terminal Emulator\nhttp://github.com/wezterm/wezterm",
version = config::llembas_tty_long_version(),
trailing_var_arg = true,
)]
struct Opt {
@@ -195,8 +197,9 @@ fn run() -> anyhow::Result<()> {
"OLDPWD",
"PWD",
"SHLVL",
"WEZTERM_PANE",
"WEZTERM_UNIX_SOCKET",
// LLeMbas TTY: its own variable names
"LLEMBAS_TTY_PANE",
"LLEMBAS_TTY_UNIX_SOCKET",
"_",
] {
std::env::remove_var(name);
@@ -311,7 +314,8 @@ mod ossl;
pub fn spawn_listener() -> anyhow::Result<()> {
let config = configuration();
for unix_dom in &config.unix_domains {
std::env::set_var("WEZTERM_UNIX_SOCKET", unix_dom.socket_path());
// LLeMbas TTY: its own variable name
std::env::set_var("LLEMBAS_TTY_UNIX_SOCKET", unix_dom.socket_path());
let mut listener = wezterm_mux_server_impl::local::LocalListener::with_domain(unix_dom)?;
thread::spawn(move || {
listener.run();
+3 -2
View File
@@ -105,9 +105,10 @@ async fn show_notif_impl(notif: ToastNotification) -> Result<(), Box<dyn std::er
hints.insert("urgency", Value::U8(1 /* Normal */));
let notification = proxy
.notify(
"wezterm",
// LLeMbas TTY: its own application name and icon
"llembas-tty",
0,
"org.wezfurlong.wezterm",
"eu.llembas.tty",
&notif.title,
&notif.message,
if notif.url.is_some() {
+2 -1
View File
@@ -78,7 +78,8 @@ fn show_notif_impl(toast: TN) -> Result<(), Box<dyn std::error::Error>> {
*/
let notifier = ToastNotificationManager::CreateToastNotifierWithId(HSTRING::from(
"org.wezfurlong.wezterm",
// LLeMbas TTY: its own application id
"eu.llembas.tty",
))?;
notifier.Show(&notif)?;
+6
View File
@@ -7,6 +7,12 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
# LLeMbas TTY: its own binary name, so that it installs beside WezTerm.
# The package keeps upstream's name.
[[bin]]
name = "llembas-tty"
path = "src/main.rs"
[dependencies]
anyhow.workspace = true
chrono.workspace = true
+1 -1
View File
@@ -6,7 +6,7 @@ use wezterm_client::client::Client;
pub struct ActivatePane {
/// Specify the target pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
}
+1 -1
View File
@@ -8,7 +8,7 @@ use wezterm_client::client::Client;
pub struct ActivatePaneDirection {
/// Specify the current pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
+1 -1
View File
@@ -36,7 +36,7 @@ pub struct ActivateTab {
/// Specify the current pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
///
/// The pane is used to figure out which window
/// contains appropriate tabs
+1 -1
View File
@@ -9,7 +9,7 @@ use wezterm_client::client::Client;
pub struct CliAdjustPaneSize {
/// Specify the target pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
/// Specify the direction to resize in
+1 -1
View File
@@ -8,7 +8,7 @@ use wezterm_client::client::Client;
pub struct GetPaneDirection {
/// Specify the current pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
+1 -1
View File
@@ -8,7 +8,7 @@ use wezterm_term::{ScrollbackOrVisibleRowIndex, StableRowIndex};
pub struct GetText {
/// Specify the target pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
+1 -1
View File
@@ -6,7 +6,7 @@ use wezterm_client::client::Client;
pub struct KillPane {
/// Specify the target pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
}
+1 -1
View File
@@ -7,7 +7,7 @@ use wezterm_client::client::Client;
pub struct MovePaneToNewTab {
/// Specify the pane that should be moved.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
+1 -1
View File
@@ -11,7 +11,7 @@ pub struct RenameWorkspace {
/// Specify the current pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
///
/// The pane is used to figure out which workspace
/// should be renamed.
+1 -1
View File
@@ -8,7 +8,7 @@ use wezterm_client::client::Client;
pub struct SendText {
/// Specify the target pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
+1 -1
View File
@@ -11,7 +11,7 @@ pub struct SetTabTitle {
tab_id: Option<TabId>,
/// Specify the current pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
///
/// The pane is used to figure out which tab should be renamed.
#[arg(long)]
+1 -1
View File
@@ -11,7 +11,7 @@ pub struct SetWindowTitle {
window_id: Option<WindowId>,
/// Specify the current pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
///
/// The pane is used to figure out which window
/// should be renamed.
+1 -1
View File
@@ -12,7 +12,7 @@ use wezterm_client::client::Client;
pub struct SpawnCommand {
/// Specify the current pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
/// The pane is used to determine the current domain
/// and window.
#[arg(long)]
+1 -1
View File
@@ -10,7 +10,7 @@ use wezterm_client::client::Client;
pub struct SplitPane {
/// Specify the pane that should be split.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
+1 -1
View File
@@ -9,7 +9,7 @@ use wezterm_client::client::Client;
pub struct ZoomPane {
/// Specify the target pane.
/// The default is to use the current pane based on the
/// environment variable WEZTERM_PANE.
/// environment variable LLEMBAS_TTY_PANE.
#[arg(long)]
pane_id: Option<PaneId>,
+9 -5
View File
@@ -2,7 +2,8 @@ use anyhow::{anyhow, Context};
use clap::builder::ValueParser;
use clap::{Parser, ValueEnum, ValueHint};
use clap_complete::{generate as generate_completion, shells, Generator as CompletionGenerator};
use config::{wezterm_version, ConfigHandle};
// LLeMbas TTY: its own version for --version
use config::{llembas_tty_long_version, ConfigHandle};
use mux::Mux;
use std::ffi::OsString;
use std::io::Read;
@@ -22,9 +23,11 @@ mod cli;
// let message = "; ❤ 😍🤢\n\x1b[91;mw00t\n\x1b[37;104;m bleet\x1b[0;m.";
#[derive(Debug, Parser)]
// LLeMbas TTY: its own name and version
#[command(
about = "Wez's Terminal Emulator\nhttp://github.com/wezterm/wezterm",
version = wezterm_version()
name = "llembas-tty",
about = "LLeMbas TTY: a terminal with LLeMbas built in, based on Wez's Terminal Emulator\nhttp://github.com/wezterm/wezterm",
version = llembas_tty_long_version()
)]
pub struct Opt {
/// Skip loading wezterm.lua
@@ -771,10 +774,11 @@ fn delegate_to_gui(saver: UmaskSaver) -> anyhow::Result<()> {
// Restore the original umask
drop(saver);
// LLeMbas TTY: its own binary names
let exe_name = if cfg!(windows) {
"wezterm-gui.exe"
"llembas-tty-gui.exe"
} else {
"wezterm-gui"
"llembas-tty-gui"
};
let exe = std::env::current_exe()?