prompt_foo) into the functions directory.functions directory would likewise be split up.$fpath and autoloaded.autoload -X stubs ourselves and not pollute the user's fpath.zsh
# Tested and it works!
p9k-foobar() {
local oldfpath=( "${(@)fpath}" )
local fpath=( "/path/to/installation/functions" "${(@)oldfpath}" )
autoload -X
}
functions directory would be prefixed with something like p9k- (utility functions) and p9k-segment- (segments).Reasons:
powerlevel9k.zsh-theme is very large. Splitting it up would make it easier to read.emulation, reset all setopts (temporarily) to ensure portability, use local setopts and even use local traps!.zwc file would not be affected by this (see AUTOLOADING FUNCTIONS in the man pages).This is a more concrete description of splitting things out into fpath that I mentioned in #528. Once this is done, then it would be easier to make the widgets reusable for other prompts.
@docwhat - I really, really like this idea. @onaforeignshore has made a number of other suggestions, as well, about ways to make improvements along the same lines, and I think your proposal, here, is a great wrap-up of everything we have discussed in separate places.
The benefits are many, and the implementation is surprisingly straight-forward. I'm all for it. Based on @dritter's 馃憤 to your post, I'm guessing he is, as well.
Questions:
next, but I have to imagine that merging it into your async branch will be a nightmare.@docwhat - Are you up for taking on this effort? If not, are you up for reviewing and testing the results?
I'm guessing he is, as well.
Yes I am! :)
And yes, it would impact the async branch pretty much. I would want to delay this a bit, until we get the async branch merged into next.
Is there anything we need to worry about regarding other ZSH frameworks? I feel like everytime we change something regarding how something is loaded, Antigen or Prezto break.
I think that #562 should fix those problems and show a helpful message when it does break. It has special case handling for Antigen < v2.1.0 and should work without problem in Antigen v2.1.0+.
In some cases, our functions have a number of conditionals based on things like operating system. Would it ever make sense to dynamically map different OS-specific versions of functions to the same segment to simplify the function code? We would have more code overall, but it would be simpler. Frankly, I'm not sure how easy this would be, though.
I think using per-os helper functions makes more sense than per-os functions. The idea is similar, but the OS bits can be varied per-segment without any extra work from the main loader.
Are you up for taking on this effort? If not, are you up for reviewing and testing the results?
As long as everyone can pair on it. :-D
We should collect some standards to normalize on...
-p9k- or -powerlevel9k-. example:zsh
-p9k-segment-dir {
...
}
prompt_powerlevel9k_setup required by the prompt command).setopt local_options is your friend.zshexpn(1) is your friend!@docwhat - Agreed! Let's start some style guidelines in the Developer's Guide on the wiki, here: https://github.com/bhilburn/powerlevel9k/wiki/Developer's-Guide
I would like to use p9k everywhere possible (honestly, I regret making the config flags POWERLEVEL9K_*).
I'm in total agreement with everything else in your list =)
We should make the configuration an associative array, if we're changing everything. :-)
@docwhat 馃憤
Any update on the Developer's Guide in the Wiki?
We haven't actually done anything that we talked about in this issue, yet, hah. These are all things I _very_ much want to see done, I just haven't had the time to sit down and do them, yet.
I'm about to kick off a big list of major P9k improvements that need to happen - this issue will be an important part of them.
A lot of this is under work in #771, by the way! You can check out the branch where @onaforeignshore has put in a ton of work and @dritter is now helping here: https://github.com/bhilburn/powerlevel9k/tree/onaforeignshore-code_separation
Closing this one out, as it's basically been implemented in the next branch as part of the new codebase!