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
Conversation
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: NixOS#30121
This seems sane, especially since it eats lines, which can be easily encountered by running eg. |
@@ -69,7 +69,7 @@ in | |||
|
|||
promptInit = mkOption { | |||
default = '' | |||
autoload -U promptinit && promptinit && prompt walters | |||
autoload -U promptinit && promptinit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that disabling zsh
on global system level and leave it enabled only at home manager user level, eliminate this weird (IMHO very uncommon) option.
There exists a magical tool `git blame` that shows who to mention.
Anyway, as the author of that line, this LGTM. I guess zsh is usable without any custom prompt set now? When I wrote the module I borrowed that line from somewhere (Debian or Arch, I don't remember), so I wonder, do they not set it now too?
|
@Mic92 Your snippet works well only for a very small number of prompts.
Something like this should be done by inspecting terminfo. `walters` was a nice single-line prompt that did all the right things on `linux`, `rxvt*`, `tmux`, and the serial tty (e.g. picocom) by default (before they broke it).
|
the option should probably be `types.str` instead of `types.lines`
That's orthogonal, but, yes, that would be a better type for that option.
As to the prompt, after some testing, I'd strongly prefer zsh to fix the walters prompt. It was a default nobody complained for >5 years, it works with any tty, and the default prompt is still unusable. But I'm ok with switching to another minimalistic "user@host"-style non-broken prompt from the default zsh distribution if it does the job of working well over serial ttys. If it would also show return codes then things would be perfect.
|
Is the proper fix for walter just? setopt prompt_sp |
Has somebody informed zsh upstream about it? |
@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)?
I did not. |
Ping? :) |
It's on my TODO list for 18.09. |
Any updates on this pull request, please? |
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. |
See NixOS#38535, properly fixing the prompt seems complicated, and this seems to work in all the ttys I checked. Suggested by @Mic92.
Should be fixed/worked-around with #66992.
|
@oxij @matthewbauer I'm still seeing issues even with #66992 applied locally; specifically because the |
Does |
Technically -- as does clearing the configuration option -- but the point
posed by this issue, and the one I'm reiterating, is it's very non-standard
to have RPS1 set by a default prompt, as well as for a distro to set a default Zsh theme
…On Tue, Aug 20, 2019 at 5:49 PM Matthew Bauer ***@***.***> wrote:
@oxij <https://github.com/oxij> @matthewbauer
<https://github.com/matthewbauer> I'm still seeing issues even with #66992
<#66992> applied locally;
specifically because the walter theme is setting RPS1
[image: image]
<https://user-images.githubusercontent.com/630909/63385642-608ab500-c36f-11e9-9f56-5b7d7da77c52.png>
Does unset RPS1 help with this?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#38535?email_source=notifications&email_token=AAE2A7LMQHG7ATLKYO6CI3DQFRRGJA5CNFSM4EZLK3IKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4XYQEA#issuecomment-523208720>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAE2A7I237D4UTPPFOWMNILQFRRGJANCNFSM4EZLK3IA>
.
|
Yeah, let's leave this PR open in case we want to just use the default zsh theme. |
IMHO, the current statement of the problem should be a WONTFIX.
Firstly, IMHO, the default zsh prompt is unusable: no username, no path, no return code, nothing, only a hostname.
Secondly, IMHO, NixOS modules exist to make hard to use things into easy to use things, with no configuration, when possible. Meanwhile, ZSH explicitly expects you to configure it. When you run it without any user configuration files present in $HOME it does not even give a shell, it just complains!
Thirdly, disabling parts of the configuration the NixOS module in question generates is trivial:
- you can `mkForce` any specific thing into nothingness,
- you can also do `echo setopt no_global_rcs >> ~/.zshenv` and then your shell will only load `/etc/zshenv` thus giving your specific user pretty much pristine unconfigured zsh (since `/etc/zshenv` does not configure anything you don't want configured even in a very customized setting) (though, now that I think about it, this fact should probably be noted directly at the top of the generated `/etc/zshrc`, since both the OP author and other people here seem to be unaware of such an option).
Hence, IMHO, this specific issue should be closed.
I'm not against changing `walters` to something different by default, though. But `walters` is a single-line prompt that is very similar to the default bash prompt. It also has all the things like `pwd` in `RPS1`, return code in `PS1` and so on by default. So, IMHO, `walters` is pretty much the ideal default adhering to "good enough and without surprises with no configuration" principle. I'm open to suggestions for less buggy alternatives adhering to the same principle, though.
But such suggestions, if there are any, should be done as separate PRs, IMHO.
So, to reiterate.
- The bugginess was worked-around with #66992.
- The OP and later complaints of "setting of the prompt has surprising effects on user configurations", IMHO, should be a WONTFIX for the aforementioned reasons.
|
@oxij #66992 doesn't resolve this, as the 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 |
as the `walters` theme exhibits unexpected behavior compared to the typical ZSH defaults because it modifies values other than `PS1`
By that logic we should not set `HISTSIZE` and `SAVEHIST` either, nor should we do any `setopt`s, since for configs that don't explicitly override all of those (nor disable `global_rcs`) could also give "an unexpected behavior".
because it modifies values other than `PS1`
Arguably, if for a prompt "X" a sequence of zsh commands `prompt Y ; prompt X` gives different results for different "Y"s then prompt "X" should be considered buggy.
In any case, that and, thus, your particular problem can also be trivially solved by doing `prompt off && prompt X` for your particular `X` in your `~/.zshrc` as `prompt off` resets _all_ prompt variables.
|
@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. |
I think they're better used as example values rather than presets.
And I respectfully disagree. Sure, there is a trade-off there. But, IMHO, most users not needing to configure anything to get a reasonable zsh config by default wins over most users needing to manually override a bunch of `configuration.nix` options with their example values so that a couple users with heavily modified `~/.zshrc`s would be spared from adding a single line into their `~/.zshenv`.
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.
require debugging
Well, like I said, I find the whole premise of this rather weird. Like, it explicitly sets the prompt to something non-default in the /etc/zshrc. That file is also rather short. I find it strange that somebody needs to do "debugging" to find that line there.
Moreover, half of the stuff I wrote in this thread can be found by running `man zsh` and pressing the "End" button to read the last sections about startup files (having such a section at the very end of the manual is a very standard thing, applicable to most UNIX programs, now knowing about this is rather strange, IMHO), other half can be found by running `info zsh` and searching for "promptinit" (or just running `info zsh "prompt themes"`) (searching `info X` for program "X" for its builtin commands/keywords is another of those the most basic UNIX skills, IMHO) (yes, `info` is absolutely awesome and you absolutely should learn to use it well, e.g. a couple more awesome examples: `info bash '$!'`, `info gdb disassemble`; yes, it's much more efficient than searching the web, and it does not spy on you doing it).
But I made #67376. It won't hurt, I guess.
|
@oxij Yes, one of the first places I looked was 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. |
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 |
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:
|
I'd still like to see this change implemented, since it's very strange and confusing to have this as a default when ZSH users are likely to set their own PS1 using some other means, and this creates major side effects (which is even noted in the current promptInit default). |
I case anyone else comes across this, having problems with the right side of the promp ( This workround worked for me: programs.zsh = {
enable = true;
sessionVariables = {
RPS1 = ""; # Disable the right side prompt that "walters" theme introduces
};
}; |
I marked this as stale due to inactivity. → More info |
Any updates on this @giraffito ? |
@pinpox A quick look at their account makes me think they're no longer active on GitHub I'd be more than happy to submit a new PR with a less opinionated default if the option's available though |
This resolves a long-standing issue caused by the 'walters' theme setting `RPS1`. See NixOS#38535 for discussion details.
Thanks @rummik ! I'll subscribe to your new PR. |
Closing this since the wanted functionality was implemented in #128183 |
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
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)