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

Simpler configuration file #2586

Closed
tmccombs opened this issue Feb 25, 2024 · 15 comments
Closed

Simpler configuration file #2586

tmccombs opened this issue Feb 25, 2024 · 15 comments

Comments

@tmccombs
Copy link

The p10k configure wizard is great. It lets you quickly customize the prompt.

However, the resulting .p10k file that is generated is, well, overwhelming.

It generates a shell script that is almost 2000 lines long. Part of this is because this configuration file appears to also serves as the main source of documentation for configuring p105 (see #1112).

If you just want to use the theme exactly as generated by the wizard, this is all well and good. But if you want to actually tweak the result a little bit, then it isn't really ideal, for a few different reasons:

  1. If you run p10k configure again, say because you wan to change one of the decisions you made the last time you ran it, then it overwrites any other changes you made in the configuration, and you have to then do a diff with the backup file and figure out which changes are from running the configure script, and which were tweaks you made.
  2. Such a large file can be difficult to navigate. Especially if you aren't already familiar with powerlevel10k and its configuration (or powerlevel9k)
  3. If there are updates to p10k, then the configuration file can get out of date, and you may need to run the wizard again to get updates, and deal with the issues from 1.
  4. It's hard to know which configuration comes from the wizard, and what comes from your tweaks afterwards.

What I propose, is that there is a way to have a configuration file that would specify the options you can choose in the wizard, and override additional parameters as desired. Then either allow passing that as an argument to p10k configure to generate the current format of the configuration file, or allow using that as the configuration file.

For example you might have something like:

P10K_FONT=nerdfont-v3
P10K_ICONS=small:many
P10K_STYLE=classic
P10K_CHARS=unicode
P10K_COLOR=dark
P10K_TIME=24h
P10K_SEPARATORS=slanted
P10K_HEADS=slanted
P10K_TAILS=flat
P10K_LINES=2
P10K_GAP=disconnected
P10K_FRAME=none
P10K_SPACING=compact

POWERLEVEL9K_INSTANT_PROMPT=verbose
POWERLEVEL9K_STATUS_ERROR=true
@romkatv
Copy link
Owner

romkatv commented Feb 25, 2024

What I propose, is that there is a way to have a configuration file that would specify the options you can choose in the wizard, and override additional parameters as desired.

How can the latter part be implemented, the one where users can apply additional overrides? Specifically, how will the users know which overrides they can apply? How can I ensure that all overrides that users apply will have the same effect even after I modify the wizard to produce different baseline configs?

@rwmitchell
Copy link

Would it be possible to use a minimal configuration set (like that above) to regenerate a .p10k.zsh file without any user prompting?

This would make it quicker to create an updated 'gold' configuration. The new gold could be compared with a previous gold to check if any new and interesting features had been added.

@romkatv
Copy link
Owner

romkatv commented Feb 25, 2024

That would require making a commitment to keep the questions in the wizard backward compatible with the past answers. Currently there is no guarantee of this kind: the next version of the wizard can have dramatically different questions.

@rwmitchell
Copy link

How often does that happen?

A configuration var that gets changed/incremented when a change to the questions occurs could be used to a) force reprompting the user, b) indicate to the user a need to regenerate a new .p10k.zsh

Realize here the interest in this is because powerlevel10k is incredibly awesome and also allows for extensive user customization. As such, users want to stay current with your latest changes and potentially incorporate those changes into their heavily customized setup. Maybe the goal isn't doable, but it is desirable.

@romkatv
Copy link
Owner

romkatv commented Feb 25, 2024

How often does that happen?

That's not the right question. I won't break user shells by my changes in the powerlevel10k code. This commitment is not cheap. Right now I can make any changes to the wizard without breaking anybody who isn't intentionally and explicitly pointing a gun at their own foot. I want to keep this freedom as it allows me to provide the best user experience for new users and for the 99% who don't manually edit their configs.

You don't need to run the generator to stay up to date. Update powerlevel10k at any time and subscribe to new releases on GitHub. If anything in the release notes seems of interest (should be less than once a year even for prompt enthusiasts), edit your config.

@tmccombs
Copy link
Author

How can the latter part be implemented, the one where users can apply additional overrides?

I'm not familiar with how the wizard works but some ideas are:

  • Instead of generating a full configuration, the wizard generates a file that calls some functions that set groups of related functions. Maybe roughly one function per question in the wizard? Then the user can set overrides after those functions are called.
  • When generating the p10k.zsh file for every variable it looks to see if a value is already set, and if so, use that value.
  • Have the generated p10k.zsh source an overrides file if it exists immediately before calling p10k reload.

Specifically, how will the users know which overrides they can apply

Well, that gets back to having better documentation (see #1112) although at least for now, you could just point to the config/p10k-classic.zsh file as a source of documentation.

How can I ensure that all overrides that users apply will have the same effect even after I modify the wizard to produce different baseline configs?

I don't think you need to. If you go the route of having p10k generate config from another source file, then the base config won't change unless the user calls p10k configure again, at which time the user can update their overrides if needed. If you do something like have functions like I describe above, it's a little more difficult because you would need some level of backwards compatibility for those functions, but hopefully that wouldn't be too much of a burden.

@romkatv
Copy link
Owner

romkatv commented Feb 25, 2024

the base config won't change unless the user calls p10k configure again, at which time the user can update their overrides if needed.

If this is good enough for your needs, you can do this:

source ~/.p10k.zsh
source ~/.p10k-overrides.zsh

I appreciate the ideas you've listed but at this point the lack of ideas isn't the problem. If you really care about this issue, fork the project and implement your ideas. It's unlikely that I'll be doing anything in this area myself.

@rwmitchell
Copy link

If you have custom (not customized, but completely new) segments, wouldn't the user need a .p10k-pre.zsh ?

@romkatv
Copy link
Owner

romkatv commented Feb 25, 2024

Need .p10k-pre.zsh to achieve what?

@rwmitchell
Copy link

to add a custom segment that can then be included in a particular left/right prompt element.

by your response, i'm assuming i'm being unreasonably paranoid about using an item before it is declared.

@tmccombs
Copy link
Author

That would require making a commitment to keep the questions in the wizard backward compatible with the past answers.

Not necessarily. It just needs to continue supporting the same inputs as previous versions.

Update powerlevel10k at any time and subscribe to new releases on GitHub. If anything in the release notes seems of interest (should be less than once a year even for prompt enthusiasts), edit your config.

The problem is that currently, this is somewhat difficult to do, due to the size and complexity of the config file.

. If you really care about this issue, fork the project and implement your ideas.

I'll consider it, but I think it would be a lot easier for someone already familiar with the p10k codebase. And I don't currently have a lot of time to learn it.

Four years ago you said:

Users in the middle are underserved though. If you aren't satisfied with the configuration produced by the configuration wizard, it's pretty tough to edit the config. No docs, parameter names are pretty bad, etc. I know about this pain point, just never gotten around to addressing it.

Has your opinion changed since then? Are you no longer interested in addressing this pain point?

The more I think about this, the more I think that the best way to handle it is to have functions to simplify settings, so that for example instead of having to set a handful of variables for the frame, you can just call a function that sets all of them. Or call a function that sets the color scheme. Although you still have tons of configuration for segments you don't use.....

@rwmitchell
Copy link

rwmitchell commented Feb 25, 2024

As an additional point, much of my customization is commenting out all the stuff I don't use. With everything left, in, 'env' becomes a nearly useless command to use to check for new/unintended settings.

I'd much prefer an 'opt-in' method for a setting than having everything just defined - but I'm probably in the minority.

@romkatv
Copy link
Owner

romkatv commented Feb 25, 2024

Not necessarily. It just needs to continue supporting the same inputs as previous versions.

We have a disconnect here. I hope you'll forgive me for not elaborating. I don't have anything new to say on this topic.

Has your opinion changed since then?

No.

Are you no longer interested in addressing this pain point?

As interested as before.

to add a custom segment that can then be included in a particular left/right prompt element.

I'm not sure I understand. You can define a prompt segment after sourcing ~/.p10k.zsh. You can add it to the proper array there, too.

@romkatv
Copy link
Owner

romkatv commented Feb 25, 2024

As an additional point, much of my customization is commenting out all the stuff I don't use.

That's the way. You just need to make an extra step and stop running the wizard. You won't miss out on anything if you do. Save yourself time and energy.

My own config is here: https://github.com/romkatv/dotfiles-public/commits/master/.p10k.zsh. It's 167 lines, including empty ones. There were two changes in 2023: the second change reverted the first. The previous change was in 2021.

@romkatv
Copy link
Owner

romkatv commented Mar 1, 2024

Closing because I don't intend to do anything here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants