I want to have a simple indicator showing in my (zsh / oh-my-zsh) shell, that I am one level into a nix shell
or nix develop
environment / sub shell without modifying all my flake.nix
or shell.nix
:
user@hostname ~ nix shell nixpkgs#git
...
#2 user@hostname ~
I want to have a simple indicator showing in my (zsh / oh-my-zsh) shell, that I am one level into a nix shell
or nix develop
environment / sub shell without modifying all my flake.nix
or shell.nix
:
user@hostname ~ nix shell nixpkgs#git
...
#2 user@hostname ~
Share
Improve this question
asked yesterday
Kai WalterKai Walter
4,0012 gold badges37 silver badges69 bronze badges
1 Answer
Reset to default 0In my Nix Home Manager configuration I added some custom script lines which enhance the generated .zshrc
to add the script level:
programs.zsh = {
enable = true;
...
initExtra =
''
if [[ $SHLVL -gt 1 ]]; then
PROMPT="#''${SHLVL}''${PROMPT}"
fi
''
};
or with a simple Unicode symbol:
programs.zsh = {
enable = true;
...
initExtra =
''
if [[ $SHLVL -gt 1 ]]; then
case $SHLVL in
2) PROMPT="⁚''${PROMPT}" ;;
3) PROMPT="⁖''${PROMPT}" ;;
4) PROMPT="⁘''${PROMPT}" ;;
*) PROMPT="⁙''${SHLVL}''${PROMPT}" ;;
esac
fi
''
};