From 32bf61c51e4c5211c9bf2a00d22548639a16d81e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Jun 2026 13:07:20 -0700 Subject: [PATCH] nixos/foot: only modify the prompt when running inside foot Without this, these integration scripts will mess with the prompt even when not running a shell inside of foot. This can break: 1. Terminals that don't understand these sequences (e.g., gnome-terminal and likely other vte based terminals). 2. Anything that tries to parse the prompt (Emacs packages like bash-completion). This patch relies on the TERM variable (against upstream's recommendation [1]) because: 1. Only Fish [2] has built-in support for querying things like XTVERSION. Querying terminal features manually is non-trivial and requires writing to STDOUT, which I'd like to avoid. 2. Even in Fish, this XTVERSION may only be queried after the first prompt has been displayed ([2]), which is too late. This patch does not explicitly check if the terminal is interactive as the modified files are only sourced by interactive shells anyway. [1]: https://codeberg.org/dnkl/foot#programmatically-checking-if-running-in-foot [2]: https://fishshell.com/docs/current/cmds/status.html#status-terminal fixes #374613 --- nixos/modules/programs/foot/bashrc | 5 +++++ nixos/modules/programs/foot/config.fish | 4 ++++ nixos/modules/programs/foot/zshrc | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/nixos/modules/programs/foot/bashrc b/nixos/modules/programs/foot/bashrc index e35bc29f117b..d3fb0ffcb4bf 100644 --- a/nixos/modules/programs/foot/bashrc +++ b/nixos/modules/programs/foot/bashrc @@ -1,3 +1,8 @@ +case "$TERM" in + foot*) : ;; + *) return 0 ;; +esac + osc7_cwd() { local strlen=${#PWD} local encoded="" diff --git a/nixos/modules/programs/foot/config.fish b/nixos/modules/programs/foot/config.fish index c7d45211327f..92f614421268 100644 --- a/nixos/modules/programs/foot/config.fish +++ b/nixos/modules/programs/foot/config.fish @@ -1,3 +1,7 @@ +if ! string match -q "foot*" "$TERM" + return 0 +end + function update_cwd_osc --on-variable PWD --description 'Notify terminals when $PWD changes' if status --is-command-substitution || set -q INSIDE_EMACS return diff --git a/nixos/modules/programs/foot/zshrc b/nixos/modules/programs/foot/zshrc index 186f21c987e5..935dd49aaed5 100644 --- a/nixos/modules/programs/foot/zshrc +++ b/nixos/modules/programs/foot/zshrc @@ -1,3 +1,8 @@ +case "$TERM" in + foot*) : ;; + *) return 0 ;; +esac + function osc7-pwd() { emulate -L zsh # also sets localoptions for us setopt extendedglob