# Show running environment in terminal

**URL:** <https://discourse.flox.dev/t/show-running-environment-in-terminal/747>\
**Category:** Help\
**Created:** [May 23, 2023, 11:50am UTC](https://discourse.flox.dev/t/show-running-environment-in-terminal/747 "2023-05-23T11:50:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wulfheart](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/wulfheart/32/581_2.png) [@Wulfheart](https://discourse.flox.dev/u/Wulfheart)\
**Post date:** [May 23, 2023, 11:50am UTC](https://discourse.flox.dev/t/show-running-environment-in-terminal/747/1 "2023-05-23T11:50:45Z")

</div>

Hello,

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.

---

<div class="post-metadata">

**Author:** ![aameen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/aameen/32/564_2.png) [@aameen](https://discourse.flox.dev/u/aameen)\
**Post date:** [May 24, 2023, 2:48pm UTC](https://discourse.flox.dev/t/show-running-environment-in-terminal/747/2 "2023-05-24T14:48:51Z")

</div>

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:

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

flox [py default] ~/docs/notes/roam % echo "$FLOX_ACTIVE_ENVIRONMENTS";
/home/camus/.local/share/flox/environments/local/x86_64-linux.py:/home/camus/.local/share/flox/environments/local/x86_64-linux.default

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 

```

---

<div class="post-metadata">

**Author:** ![anon59756714](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anon59756714](https://discourse.flox.dev/u/anon59756714)\
**Post date:** [May 25, 2023, 12:35pm UTC](https://discourse.flox.dev/t/show-running-environment-in-terminal/747/3 "2023-05-25T12:35:22Z")

</div>

I have this in my `.p10k.sh`:

```auto
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.

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

```auto
 typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(

```

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

```auto
function prompt_example() {
}

```

---

<div class="post-metadata">

**Author:** ![davidmarble](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/davidmarble/32/766_2.png) [@davidmarble](https://discourse.flox.dev/u/davidmarble)\
**Post date:** [June 2, 2025, 10:35pm UTC](https://discourse.flox.dev/t/show-running-environment-in-terminal/747/4 "2025-06-02T22:35:48Z")

</div>

Thanks for this @anon59756714 ! In case it’s useful to future searchers, I’m using zsh4humans (which uses p10k) and used your tip along with a workaround to avoid errors I was getting when calling `flox activate` due to flox redefining $ZDOTDIR:

At the bottom of my ~/.zshenv I added:

```auto
_MY_ZDOTDIR="$ZDOTDIR"

```

At the top of my ~/.zshrc I added:

```auto
_FLOX_ZDOTDIR="$ZDOTDIR"
export ZDOTDIR=$_MY_ZDOTDIR

```

And at the bottom of my .zhsrc I added:

```auto
export ZDOTDIR=$_FLOX_ZDOTDIR

```
