# Using ZSH with grml config, and nix-shell prompt indicator

**URL:** https://discourse.nixos.org/t/using-zsh-with-grml-config-and-nix-shell-prompt-indicator/13838
**Category:** Guides
**Created:** [June 28, 2021, 1:45pm UTC](https://discourse.nixos.org/t/using-zsh-with-grml-config-and-nix-shell-prompt-indicator/13838 "2021-06-28T13:45:06Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![nh2](https://discourse.nixos.org/user_avatar/discourse.nixos.org/nh2/32/631_2.png) [@nh2](https://discourse.nixos.org/u/nh2)
#### Post date: [June 28, 2021, 1:45pm UTC](https://discourse.nixos.org/t/using-zsh-with-grml-config-and-nix-shell-prompt-indicator/13838/1 "2021-06-28T13:45:06Z")

</div>

I use the [GRML zshrc](https://grml.org/zsh/) for more than 10 years, and still find it better than the `oh-my-zsh` prompts especially regarding version control integration (e.g. it shows cleanly whether you are in a `git rebase` or `git cherry-pick`).

Here’s how I use it on NixOS, based on my [previous post on reddit](https://old.reddit.com/r/NixOS/comments/7ihiyk/how_to_use_grml_zshrc_on_nixos/) (which I cannot update any more because Reddit crappily forbids that).

It explains some pitfalls I encountered, and also features showing `(nix-shell)` in the prompt when I’m in nix-shell.

```nix
{
    # zsh
    programs.zsh.enable = true;
    programs.zsh.interactiveShellInit = ''
      # Note that loading grml's zshrc here will override NixOS settings such as
      # `programs.zsh.histSize`, so they will have to be set again below.
      source ${pkgs.grml-zsh-config}/etc/zsh/zshrc

      alias d='ls -lah'
      alias g=git

      # Increase history size.
      HISTSIZE=10000000

      # Prompt modifications.
      #
      # In current grml zshrc, changing `$PROMPT` no longer works,
      # and `zstyle` is used instead, see:
      # https://unix.stackexchange.com/questions/656152/why-does-setting-prompt-have-no-effect-in-grmls-zshrc

      # Disable the grml `sad-smiley` on the right for exit codes != 0;
      # it makes copy-pasting out terminal output difficult.
      # Done by setting the `items` of the right-side setup to the empty list
      # (as of writing, the default is `items sad-smiley`).
      # See: https://bts.grml.org/grml/issue2267
      zstyle ':prompt:grml:right:setup' items

      # Add nix-shell indicator that makes clear when we're in nix-shell.
      # Set the prompt items to include it in addition to the defaults:
      # Described in: http://bewatermyfriend.org/p/2013/003/
      function nix_shell_prompt () {
        REPLY=''${IN_NIX_SHELL+"(nix-shell) "}
      }
      grml_theme_add_token nix-shell-indicator -f nix_shell_prompt '%F{magenta}' '%f'
      zstyle ':prompt:grml:left:setup' items rc nix-shell-indicator change-root user at host path vcs percent
    '';
    programs.zsh.promptInit = ""; # otherwise it'll override the grml prompt

    users.users.root.shell = pkgs.zsh;
}

```

PS:

- The code highlighting here on Discourse is broken, it does not understand the `''$VARIABLE` escape to write a verbatim `$` into the config in Nix multi-line strings (`''`).
