最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How can I add a simple indicator in my Nix configuration so that I see, that I am in a nix shell or nix develop environment? - S

programmeradmin1浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

In 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

          ''
      };

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论