When inside a zmx session, the environment variable ZMX_SESSION is set to the session name. Since zmx does not provide visual indicators of being inside a session, it is recommended to update your shell prompt to display the session name.
Fish
Add to ~/.config/fish/config.fish:
functions -c fish_prompt _original_fish_prompt 2>/dev/null
function fish_prompt --description 'Write out the prompt'
if set -q ZMX_SESSION
echo -n "[$ZMX_SESSION] "
end
_original_fish_prompt
end
Bash and Zsh
Add to .bashrc or .zshrc:
if [[ -n $ZMX_SESSION ]]; then
export PS1="[$ZMX_SESSION] ${PS1}"
fi
Powerlevel10k (Zsh)
Add to .zshrc:
function prompt_my_zmx_session() {
if [[ -n $ZMX_SESSION ]]; then
p10k segment -b '%k' -f '%f' -t "[$ZMX_SESSION]"
fi
}
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=my_zmx_session
Oh My Posh
Add to your configuration:
[[blocks.segments]]
template = '{{ if .Env.ZMX_SESSION }} {{ .Env.ZMX_SESSION }}{{ end }}'
foreground = 'p:orange'
background = 'p:black'
type = 'text'
style = 'plain'
Starship
Add to starship.toml:
format = """
${env_var.ZMX_SESSION}\n..."
"""
[env_var.ZMX_SESSION]
symbol = " "
format = "[$symbol$env_value]($style) "
description = "zmx session name"
style = "bold magenta"