Support SHELL_PROMPT_PREFIX, SHELL_PROMPT_SUFFIX, and SHELL_WELCOME

Add support for the SHELL_PROMPT_PREFIX, SHELL_PROMPT_SUFFIX, and
SHELL_WELCOME environment variables as standardized by systemd v257.

SHELL_PROMPT_PREFIX and SHELL_PROMPT_SUFFIX are automatically prepended
and appended to the left prompt at the shell level, so all prompts
(default, custom, and sample) pick them up without modification.

SHELL_WELCOME is displayed after the greeting when an interactive shell
starts.

These variables provide a standard interface for tools like systemd's
run0 to communicate session context to the shell.

Fixes https://github.com/fish-shell/fish-shell/issues/10924

Closes #12570
This commit is contained in:
Daan De Meyer
2026-03-25 21:45:44 +00:00
committed by Johannes Altmanninger
parent fdd10ba9b2
commit 484032fa9e
7 changed files with 37 additions and 0 deletions

View File

@@ -34,6 +34,13 @@ function __fish_config_interactive -d "Initializations that should be performed
fish_greeting
end
# Display SHELL_WELCOME if set. This is a standard environment variable (introduced by
# systemd v257) intended for shells to display when they first initialize.
if status --is-interactive
and set -q SHELL_WELCOME[1]
string join -- ' ' $SHELL_WELCOME
end
#
# Completions for SysV startup scripts. These aren't bound to any
# specific command, so they can't be autoloaded.