Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/zsh: do not set ZSH prompt to the 'walters' style #38535

Open
wants to merge 1 commit into
base: master
from

Conversation

@giraffito
Copy link
Contributor

commented Apr 6, 2018

This is not the default upstream and causes differences in behavior for users compared to other distros.

The commit introducing this default was the one introducing support for zsh, without any justification at the time.

In addition to having surprising effects on user configurations, the prompt is currently buggy and can hide command output: #30121

Motivation for this change

Other distros do not change the default zsh prompt theme, and it changes the behavior of any user configuration that does not explicitly override all settings set in the 'walters' theme. In addition, the current prompt theme is buggy and hides the last line of output from commands that do not terminate their output with a newline.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

This is not the default upstream and causes differences in behavior for users compared to other distros.

The commit introducing this default was the one introducing support for zsh, without any justification at the time.

In addition to having surprising effects on user configurations, the prompt is currently buggy and can hide command output: #30121
@hedning

This comment has been minimized.

Copy link
Contributor

commented Apr 7, 2018

This seems sane, especially since it eats lines, which can be easily encountered by running eg. nix eval nixpkgs.hello.name --raw.

@@ -69,7 +69,7 @@ in

promptInit = mkOption {
default = ''
autoload -U promptinit && promptinit && prompt walters
autoload -U promptinit && promptinit

This comment has been minimized.

Copy link
@Mic92

Mic92 Apr 7, 2018

Contributor

I know other distros do not that anything, but they also do not have configuration management that let user's override.
The default prompt of zsh is almost useless. Could we at least have something that is consistent with our bash prompt?

          # Provide a nice prompt if the terminal supports it.
          if [ "$TERM" != "dumb" -o -n "$INSIDE_EMACS" ]; then
            PROMPT_COLOR="1;31m"
            let $UID && PROMPT_COLOR="1;32m"
            PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] "
            if test "$TERM" = "xterm"; then
              PS1="\[\033]2;\h:\u:\w\007\]$PS1"
            fi
          fi

it does not have to be fancy pants, but it should be a bit saner to what zsh provide by default.
The reason is, that in automatically configured systems, you don't want to spend time on setting up dotfiles.
Also when users configure their shells the first time they also should not suffer from eye bleeding.

This comment has been minimized.

Copy link
@giraffito

giraffito Apr 22, 2018

Author Contributor

I'm not enough of a zsh expert to know how to write an idiomatic configuration, but I would like to avoid having a prompt theme injected by default since this changes the effect of dotfiles atop a regular install compared to other distros.

To me, it seems like automated deploys using zsh will also have custom configuration for it, since zsh is not a default shell in the first place (opinionated sysadmins tend to come with their own dotfiles :P).

Unless someone knows of a way to make the default zsh configuration friendly which will not interfere with other nixos-provided zsh configuration nor user dotfiles, I think we should merge this as-is. Users are used to adding their own config, but shouldn't have to contend with unexpected pre-existing configuration that isn't familiar from other distros or zsh experience.

This comment has been minimized.

Copy link
@LnL7

LnL7 Apr 23, 2018

Member

Anything that runs afterwards, including traditional dotfiles like ~/.zshrc will override the system defaults. Alternatively it can be disabled globally with programs.zsh.promptInit = mkForce "";, the option should probably be types.str instead of types.lines then regular assignment would just work.

@oxij

This comment has been minimized.

Copy link
Contributor

commented Apr 23, 2018

@oxij

This comment has been minimized.

Copy link
Contributor

commented Apr 23, 2018

@oxij

This comment has been minimized.

Copy link
Contributor

commented Apr 23, 2018

@Mic92

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2018

Is the proper fix for walter just?

setopt prompt_sp
@Mic92

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2018

Has somebody informed zsh upstream about it?

@oxij

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2018

@Mic92 Interestingly, from my point of view github seems to ignore the messages you write (I don't receive email notifications specifically about your messages).

The fix I will test, but how does it relate to the changes in zsh-users/zsh@43e55a9 (mentioned in #30121)?

Has somebody informed zsh upstream about it?

I did not.

@dtzWill

This comment has been minimized.

Copy link
Contributor

commented Sep 10, 2018

Ping? :)

@oxij

This comment has been minimized.

Copy link
Contributor

commented Sep 10, 2018

It's on my TODO list for 18.09.

@mmahut

This comment has been minimized.

Copy link
Member

commented Aug 7, 2019

Any updates on this pull request, please?

@rummik

This comment has been minimized.

Copy link

commented Aug 13, 2019

I've been switching to home-manager for personal dotfiles management, and this took quite a bit of digging to find where my theme was being mangled. It's very non-obvious that NixOS is setting the prompt to something other than the ZSH default.

oxij added a commit to oxij/nixpkgs that referenced this pull request Aug 19, 2019
See NixOS#38535, properly fixing the prompt seems complicated, and this seems
to work in all the ttys I checked.

Suggested by @Mic92.
@oxij

This comment has been minimized.

Copy link
Contributor

commented Aug 19, 2019

@rummik

This comment has been minimized.

Copy link

commented Aug 20, 2019

@oxij @matthewbauer I'm still seeing issues even with #66992 applied locally; specifically because the walter theme is setting RPS1
image

@matthewbauer

This comment has been minimized.

Copy link
Member

commented Aug 20, 2019

@oxij @matthewbauer I'm still seeing issues even with #66992 applied locally; specifically because the walter theme is setting RPS1
image

Does unset RPS1 help with this?

@rummik

This comment has been minimized.

Copy link

commented Aug 20, 2019

@matthewbauer

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

Yeah, let's leave this PR open in case we want to just use the default zsh theme.

@matthewbauer matthewbauer reopened this Aug 21, 2019
@oxij

This comment has been minimized.

Copy link
Contributor

commented Aug 23, 2019

@rummik

This comment has been minimized.

Copy link

commented Aug 23, 2019

@oxij #66992 doesn't resolve this, as the walters theme exhibits unexpected behavior compared to the typical ZSH defaults because it modifies values other than PS1. Regardless of how usable the ZSH default theme is, I would argue that any theme being used as a default should not require a user override RPS1, or any other values, in order to restore expected behavior when setting a theme

Edit: Additionally, I'd also argue that if NixOS is specifying a theme for ZSH, it should either set it for other shells as well, or not set one at all, in order to maintain consistency in this behavior

@oxij

This comment has been minimized.

Copy link
Contributor

commented Aug 23, 2019

@rummik

This comment has been minimized.

Copy link

commented Aug 24, 2019

@oxij I'm mainly talking about the non-standard prompt changes because that's the scope of the issue. However, if they're creating side effects that require debugging in order to determine where they're being set, much like I was forced to do here, then yes, I think they're better used as example values rather than presets.

@oxij

This comment has been minimized.

Copy link
Contributor

commented Aug 24, 2019

@rummik

This comment has been minimized.

Copy link

commented Aug 24, 2019

@oxij Yes, one of the first places I looked was /etc/zshrc. I then had to figure out which NixOS option was causing this unexpected behavior to override it

Edit: I just don't think we should be forcing people to override a non-standard theme in order to restore expected behavior. To my knowledge, no NixOS-supplied default theme of other shells set RPS1 -- and if they do, I would argue they should not be doing this either.

Edit: Additionally, I find it strange that anyone should have to argue to restore expected defaults, as opposed to arguing to diverge from expected defaults.

@rummik

This comment has been minimized.

Copy link

commented Sep 1, 2019

Additionally, it seems like the standard is for NixOS to not be opinionated -- or at least minimally opinionated -- in its default configurations, and this option seems highly opinionated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.