Closed manojlds closed 3 years ago
Not sure I understand what you're looking for...
Themes really are prompts - if you want a custom prompt, just copy one of the existing ones and make the changes you want.
@nwinkler - I understand that from personal use point of view. What if I wanted to contribute it here?
Actual use case - I am trying to add Kubernetes kubectl context to my prompt. I would also like to contribute that back to bash-it. But not everyone would want it to be enabled right? How can I let people who want it, to enable it?
Got it, thanks, that makes sense.
We don't have a standard approach for that, but here are a couple of ideas:
base.theme
. This way, it can be used in any theme.powerline-multiline
theme. See the theme's readme (https://github.com/Bash-it/bash-it/tree/master/themes/powerline-multiline) for more info. I think this is a good pattern - add the functionality, document how to add it and then let the user decide which information to include in their theme.Once you've made the changes that implement this new feature, feel free to create a Pull Request and we'll review that together.
One way to see the Kubernetes prompt is to use https://github.com/jlesquembre/kubeprompt/ with Bashit. But I could not get it to work.
Greetings All !
As @nwinkler mentioned, the Powerline themes are an excellent example of a theme that lets you optionally include different pieces of information into your prompt.
In Powerline, each different piece of information is called a segment
.
Each segment has a code name and you use the code names to chose which segments you want, AND in which order they should be displayed.
Example with scm context
export POWERLINE_PROMPT="user_info scm cwd"
Example without scm context and different segment order
export POWERLINE_PROMPT="cwd user_info"
Have a look at recently-added PR #1476 and the discussion I started there.
It introduces logic to for the k8s_context with my recommendation being to centralize that logic so all themes can take advantage of it.
I imagine that the k8s segment would be incorporated into bash-it similar to how the scm segment is incorporated, so you might want to look at that for inspiration.
@manojlds, you and @Diogo-Costa might be able to collaborate on this effort.
-D
@davidpfarrell Thanks for this input. I'm still stuck with this, though. I want to add a simple segment to my powerline. If $MY_ENV_VAR exists, print its value, with the colors I want. I have been trying to find for example where "user_info" segment is defined so I could copy it, but I just cannot find any references to it, or any of the segment names. Where are they defined? Thanks!
In bobby theme it was easy, I just added my variable in the PS1 string with the ${color} I want, but I cannot get it to work with powerline, so it would actually look like powerline and not just text
Hey @tuomassa - thanks for the question.
The user_info
segment function is defined here:
The naming convention for the Powerline segments is __powerline_
segment_prompt
, all of the functions can be found in the powerline.base.bash
file. So for the node
segment, the function is called __powerline_node_prompt
, for example.
Does that help?
@nwinkler Yes, thanks alot! I was actually trying to modify powerline-multiline and didn't notice it actually sources the normal powerline theme so I was not looking in the right place!
You're welcome!
I see that prompts are mixed with themes. How do I add a new prompt that is optional. Like how plugins can be enabled? Am I missing something?