Show running environment in terminal


I don’t think that I currently have a grasp what this project is about.

I would like to have my zsh/oh-my-zsh/p10k setup to automatically show the current environment. How can I achieve this?

Thank you in advance.

Yeah we can help you out with that.
There’s normally a hook which runs when activating an environment which modifies your PROMPT environment variable.
However, some dynamic prompts with shells like zsh may “reset” this variable later which may be happening with p10k.

When customizing a dynamic prompt you’ll likely want to reference the environment variable FLOX_PROMPT_ENVIRONMENTS.
Here’s an example that may be helpful:

~/docs/notes/roam % flox activate -e py;

flox [py default] ~/docs/notes/roam % echo "$FLOX_ACTIVE_ENVIRONMENTS";

flox [py default] ~/docs/notes/roam % echo "$FLOX_PROMPT_ENVIRONMENTS";
py default

flox [py default] ~/docs/notes/roam % echo "$PROMPT";
%B%F{61}flox %F{216}[py default]%f%b %F{yellow}%~%f %(?.%F{cyan}.%F{red}%? )%#%f 

I have this in my

function prompt_flox(){
    [[ -n $FLOX_PROMPT_ENVIRONMENTS && $FLOX_PROMPT_ENVIRONMENTS != "default" ]] || return
    local v=${FLOX_PROMPT_ENVIRONMENTS%default}
    p10k segment -f 63 -i "󱄅" -t "${v}"

and flox added to plugin list. Icon is the Nix icon from JetbrainsMono Nerd Font but can be anything really.

To be clear, the flox can be added whenever you like but most plugins are on the right, depending on your theme ofc:


just add flox in the list and the function from above somewhere below

function prompt_example() {
1 Like