From 6d8027dd9407655789d94e8fcbbff87d4cd8196a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Klein?= Date: Fri, 9 Jan 2026 00:31:04 +0100 Subject: [PATCH] Spawning new terminal with --config from parent instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reference: https://codeberg.org/dnkl/foot/issues/1622 Signed-off-by: Stéphane Klein --- CHANGELOG.md | 3 +++ config.c | 3 +++ config.h | 1 + doc/foot.1.scd | 3 +++ terminal.c | 12 +++++++++++- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0462666c..45db9854 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,9 +78,12 @@ * `[colors-light]` section to `foot.ini`. Replaces `[colors2]`. * `XTGETTCAP`: added `query-os-name`, returning the OS foot is compiled for (e.g. _'Linux'_) ([#2209][2209]). +* `--config=PATH` option is now automatically passed to new + terminals spawned via `spawn-terminal` action ([#2259][2259]). [2212]: https://codeberg.org/dnkl/foot/issues/2212 [2209]: https://codeberg.org/dnkl/foot/issues/2209 +[2259]: https://codeberg.org/dnkl/foot/pulls/2259 ### Changed diff --git a/config.c b/config.c index 14e836c1..1293c995 100644 --- a/config.c +++ b/config.c @@ -3442,6 +3442,7 @@ config_load(struct config *conf, const char *conf_path, enum fcft_capabilities fcft_caps = fcft_capabilities(); *conf = (struct config) { + .conf_path = (conf_path ? xstrdup(conf_path) : NULL), .term = xstrdup(FOOT_DEFAULT_TERM), .shell = get_shell(), .title = xstrdup("foot"), @@ -3895,6 +3896,7 @@ config_clone(const struct config *old) struct config *conf = xmalloc(sizeof(*conf)); *conf = *old; + conf->conf_path = (old->conf_path ? xstrdup(old->conf_path) : NULL); conf->term = xstrdup(old->term); conf->shell = xstrdup(old->shell); conf->title = xstrdup(old->title); @@ -3995,6 +3997,7 @@ UNITTEST void config_free(struct config *conf) { + free(conf->conf_path); free(conf->term); free(conf->shell); free(conf->title); diff --git a/config.h b/config.h index 9ca47753..00c04487 100644 --- a/config.h +++ b/config.h @@ -217,6 +217,7 @@ enum center_when { }; struct config { + char *conf_path; char *term; char *shell; char *title; diff --git a/doc/foot.1.scd b/doc/foot.1.scd index 7058e96f..a190db9b 100644 --- a/doc/foot.1.scd +++ b/doc/foot.1.scd @@ -27,6 +27,9 @@ the foot command line *-c*,*--config*=_PATH_ Path to configuration file, see *foot.ini*(5) for details. + The configuration file is automatically passed to new terminals + spawned via *spawn-terminal* (see *foot.ini*(5)). + *-C*,*--check-config* Verify configuration and then exit with 0 if ok, otherwise exit with 230 (see *EXIT STATUS*). diff --git a/terminal.c b/terminal.c index b670d606..8ce9bd4b 100644 --- a/terminal.c +++ b/terminal.c @@ -3802,8 +3802,18 @@ term_bell(struct terminal *term) bool term_spawn_new(const struct terminal *term) { + char *argv[4]; + int argc = 0; + + argv[argc++] = term->foot_exe; + if (term->conf->conf_path != NULL) { + argv[argc++] = "--config"; + argv[argc++] = term->conf->conf_path; + } + argv[argc] = NULL; + return spawn( - term->reaper, term->cwd, (char *const []){term->foot_exe, NULL}, + term->reaper, term->cwd, argv, -1, -1, -1, NULL, NULL, NULL) >= 0; }