Hello,
It's nice how powerlevel9k get's more and more custom segments.. but we should maybe think about outsourcing them into plugins or and working on a way to handle these plugins. This way we could keep our powerline clean and fast and adding more plugins would be more easy.
What do you guys think about this step?
Hi @shibumi !
Phew. That's some big topics you are talking about. ;) I'll try to answer them:
Well, the speed of the prompt is a product of the complexity of the base-functions (like printing colors, joining segments, printing icons, etc.) and the configured segments. Yes, all segments get slower if we add more base-functionality to the theme. And it gets slower if the user configures slow segments. We try to address that by calling the segments asynchronously.. Outsourcing the segments won't help at this point. If the user did not configure a specific segment, it won't slow down the prompt (it won't get called).
Is it hard to develop new segments (I might be blind on that spot)? Well, you need to know how to call $1_prompt_segment, but once you got that it is quite easy, no? It would be easier to handle each segment like custom segments, so that you just have to echo your contents. But that would clutter the information needed to draw the segment (like content, icon, colors).
@bhilburn and I talked about moving the segments into its own file (or even into separate files). But that is just cosmetics so that we don't need to scroll so much.. I am planning this to do after #344 gets merged into next. Before that it would get too complicated to keep the branches in sync.
A "real" plugin architecture would need a plugin manager. There are a few out there for ZSH, but we want to keep the segments as easy as possible to use, and as less dependencies as possible.
Do you have in mind to create a separate repo with custom segments? For now we try to merge as many as possible to upstream, so it would be easy to turn segments just on and off. IMHO the installation is currently complicated enough and that won't make it easier..
Hey @shibumi! Interesting idea!
So, generally, I'm definitely a fan of breaking the segments out of the primary powerlevel9k.zsh-theme file that they currently sit in. When @dritter and I met up in Brussels a couple of months ago, we discussed this exact point and definitely agree with you. As he mentioned, our plan is to give each segment its own file in the future. I think this will make it easier to add & maintain segments for everyone, including us!
Usually, when I think of 'plugins', I think of more than just what typically goes into P9k segment code. What did you have in mind for what would be included in a plugin? Is there anything there that would simplify the installation of segments?
Hello @dritter and @bhilburn,
I thought about this a lot and I think the best solution is just to put the segments into an own directory and we just load all files in the directory into our main script. This way a user could create a custom segment, move it to the segment-directory and it will be instantly loaded without editing his .zshrc file. A nice side effect would be that the user keeps his .zshrc clean, because all custom segments will be in an own directory.
Thats more or less what I thought about 'plugins'.
@shibumi - Oh, great idea! So, basically, P9k will glob a directory and pick up any segments in that directory. And yes, I really like the idea of being able to keep zshrc and the P9k source file clean.
Okay, this work has been picked up by @dritter in his async branch and some by @onaforeignshore, which is based on the async branch. Closing this issue to track progress in #476.