Cannot reset my prompt using a shell hook when an environment is activated

I am trying to reset my custom prompt using a shell hook when activating an environment:

shell.hook = ''
     eval "$(starship init zsh)"
  '';

I tried various quoting of $ but nothing seemed to work and I am not getting a starship prompt.

Could someone please help me to debug this?

Thank you.

Howdy, I have an idea of what might be going on here but I’m working with our engineers to test my theory.

Thanks for your report and I’ll get back with you soon with my findings.

1 Like

Alright this one has a pretty simple solution.
So the issue you were running into was essentially that flox activate sets PROMPT at the end of its run, after shell.hook is executed, so this was wiping out your settings.

The good news is there’s an environment variable FLOX_PROMPT_DISABLE=1; that will suppress setting PROMPT/PS1, which would allow your settings to survive.

Here’s an example:

$ FLOX_PROMPT_DISABLE=1 flox activate -e foo;
$ # or
$ export FLOX_PROMPT_DISABLE=1;
$ flox activate -e foo;

Note that setting FLOX_PROMPT_DISABLE in shell.hook or environmentVariables.FLOX_PROMPT_DISABLE will have no effect. It should be set before running flox.

1 Like

It’s working thanks! And since I am using starship to still display the activated environments, here’s my configuration:

right_format = '$env_var'

[env_var]
variable = 'FLOX_PROMPT_ENVIRONMENTS'
format = '[$env_value]($style)'
default = 'none'
style='green bold'

Then I am not missing anything :slight_smile: !

1 Like

Radical. I’m glad I was able to help.

1 Like