March 28, 2026·4 min read·engineeringfishpromptssystemd

fish 4.6 reads session context from prompt environment variables

fish 4.6 supports the prompt prefix, suffix, and welcome variables used by systemd. The change lets a session launcher supply context without replacing the user's prompt function.

The request for fish to support SHELL_PROMPT_PREFIX began in December 2024. Systemd had introduced environment variables through which session launchers could supply prompt context, but its shell integration did not cover fish. Issue 10924 asked fish to consume those values itself. Fish 4.6.0, released on March 28, implements that support.

The release notes define the behavior directly. SHELL_PROMPT_PREFIX appears before the left prompt, and SHELL_PROMPT_SUFFIX appears after it. SHELL_WELCOME appears on startup after the greeting. A launcher can therefore contribute context through the environment without supplying the user's complete prompt definition.

I came to fish after Bash and Zsh, and its useful defaults are a large part of why I prefer it as a personal shell. Prompt customization should not require recreating integration that another program can describe through a small interface. This change lets fish retain its own prompt model while accepting information from the program that started the session.

The launcher knows why the session exists

Systemd's run0 is the example named in the release notes. Its versioned manual documents a shell prompt prefix option and the environment variable it controls. The manual also describes a default prefix when the relevant character support is available. Fish's new behavior gives that value a defined place in the prompt.

The division of responsibility is useful. A launcher knows the context in which it created the session. The shell knows when to display a prompt and how the user has configured it. Passing a prefix lets the launcher communicate its information without needing to generate fish code or understand every user's prompt function.

The original fish request also discussed possible use in containers, virtual machines, and remote sessions. Those were proposed applications of the interface, not proof that every such launcher already supplies the variables. The concrete support in this release is consumption by fish. A session only displays supplied context when the corresponding values reach its environment.

A prefix is still presentation. It does not independently prove the identity, privileges, or isolation of the running process. The useful property is that the launcher has a conventional way to label the session. Operational decisions still depend on the actual process context. That boundary keeps a visible prompt marker from being mistaken for an authorization mechanism.

Startup text and prompt text have different lifetimes

SHELL_WELCOME is displayed at startup after fish's greeting. The prefix and suffix surround the left prompt. That separates a message shown on entry from context shown with the prompt itself. A launcher can choose between introducing the session and keeping a shorter marker present while commands are entered.

The distinction matters in a long interactive session. A startup message can scroll away as commands produce output. A prompt marker has repeated opportunities to remind the user of context. Neither requires the launcher to replace the user's choice of current-directory display, version-control information, or command status formatting.

The 4.6 language documentation explains that fish obtains its prompt from the fish_prompt function. Its output forms the prompt. The new environment integration adds a way for context outside that function to participate. The release describes the prefix and suffix as automatic, so prompt authors do not need to copy the launcher's convention into every custom prompt.

This is a useful kind of compatibility for fish. Its scripting language deliberately differs from POSIX shells, but session context does not require POSIX syntax. Environment variable names and their presentation rules can form a common interface while each shell retains its own implementation.

Emoji width affects whether that context fits

Fish 4.6 also changes the default emoji width from one column to two. The release notes explain the intended benefit for users connecting to older systems from modern desktops. Users whose older desktop display becomes misaligned can set the width back to one. This is a rendering assumption with a documented override, not a change to the meaning of a prompt marker.

The two changes are related in practice because a launcher-provided prefix may contain an emoji. A shell needs a column width when placing the editable command and moving its cursor. If its width assumption disagrees with the terminal display, text can appear misaligned even when the prefix value itself is correct.

That explains why terminal behavior belongs in a shell release alongside language behavior. A prompt is text with cursor-position consequences. Accepting context from the environment makes that text available, while width handling determines how reliably it can share a line with the command.

I value this attention to ordinary interaction. Fish's attraction is the amount of useful feedback available before a command runs. A contextual prompt contributes to that feedback when it remains readable and does not demand a separate collection of shell-specific integration scripts.

The release also gives set_color finer control over terminal attributes. Italics, reverse mode, strikethrough, and underline can be turned off individually. New foreground and reset options make other formatting choices explicit. These changes help prompt implementations manage the formatting they introduce, alongside the session text that fish now accepts through the environment. The resulting prompt still has to share terminal state with the command output around it.

A familiar spelling for combined output

The same release accepts |& as an alternate spelling of &|. Both pipe standard output and standard error to the next process. The versioned language documentation describes them as aliases, so existing fish commands using &| retain their meaning.

For example, the documentation's pattern for a function that emits both streams can use the new spelling:

function print_streams
    echo out
    echo err >&2
end

print_streams |& less

The receiving pager gets both streams. This is a small compatibility change for users bringing familiar Bash syntax to the prompt. It does not imply general Bash compatibility, but it removes one unnecessary difference in an operation whose intended stream connections are already supported by fish. Prompt environment variables follow a similar approach, adopting an existing interface where the shell can implement its meaning directly.