Can I change zsh prompt using direnv

Hi,

I’ve installed direnv but I don’t know if I can change my zsh prompt with shellHook

Currently, I’ve this that doesn’t seem to work:

{pkgs ? import <nixpkgs> {}}:
with pkgs;
let
gems = bundlerEnv {
name = "blog";
gemdir = ./.;
};
in mkShell {
buildInputs = [ gems gems.wrappedRuby ];
shellHook = ''
PS1="%m" # or export PS1="%m" 
bundler config set --local force_ruby_platform true
'';
}

I don’t think you need shellHook to change the prompt. I think setting PS1 like this should work, but never tried it:

mkShell {
  PS1 = "<whatever>";
}

make prompts with GitHub - starship/starship: ☄🌌️ The minimal, blazing-fast, and infinitely customizable prompt for any shell!

this seems to work for any random variables

mkShell {
test="test";
}
direnv: export ... +shell +shellHook ... +test ...

but not for PS1

mkShell {
PS1 = "%m";
}
direnv: export ... +shell +shellHook ...  ...

I’ll take a look, but does it work with direnv ?

What I would do at this point is search the direnv codebase for PS1.

1 Like

You may be right, I’ll try. Thanks :slight_smile:

Yes, they have a direnv module: Configuration | Starship

1 Like