-
-
Notifications
You must be signed in to change notification settings - Fork 981
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
Option to add prefix/postfix to preprompt line #241
Comments
One possibility would be to purpose the But I'm not sure about this, I'm worried that a user might have predefined something in |
Instead of using Side node, referencing psvar as |
Your suggestion would require two new configuration variables which is something we don't want. We don't want pure to be cluttered with a bunch of configuration options to fit everyones taste, the defaults should be good enough for most, and those who want more have the option to maintain a fork. Also, the idea behind using psvar is to protect against expansion. If the user wants expanded content, he could take care of that himself, e.g. in his own precmd hook. That said, I try to find ways to allow power users to tweak and extend pure without having to fork. This could potentially be one such instance given enough thought. Also note that we are considering supporting virtualenvs in pure (see #221). You might feel that adding these new configuration options are a reasonable request, however, we do not. But we're committed to always keep improving pure and all we ask is that you can keep an open mind and work with us, according to our principles, to make pure the greatest it can be 😁. |
This is a cross-post from #427 (comment) as I feel the information is relevant here as well: [...] That said, I'm not opposed to something that would allow this, in one way or another. I want Pure to be hackable, but not complicated. I have my own thoughts about what such an implementation could look like, but I have never gotten around to implement / experiment. But there are at least a few options I can think of (both include introducing a new markdown document,
|
For example option 2 was implemented in fork https://github.com/intelfx/pure#custom-handlers. I'm successfully using it to extend prompt with my indicators at https://github.com/z0rc/dotfiles/blob/master/zsh/rc.d/08_pure.zsh. |
@z0rc Thanks for pointing it out, that does seem like a similar approach I had in mind (for nr. 2). I still think the post-processing / hook method is more powerful, though. And it could perhaps be re-used in other parts of Pure. I mostly mentioned nr. 2 for brainstorming. There are some downsides that make it unappealing:
|
For option nr. 1, a user will realistically only be able to prepend or append to the entire prompt. Otherwise the string manipulation would probably get to be too difficult and brittle. Option nr 2 allows users to insert data in the middle easily. |
I did not intend for it to be a string, it would still be an array (one for each segment, as in the code now), and understanding array manipulation would be beneficial here as well.
Not any more easily than via the hook where you would have access to the full preprompt array and can perform manipulations on it. With option 1 you at least manipulate the preprompt directly instead of manipulating the order of functions that in turn manipulate the preprompt. In my opinion that's more straightforward. |
I misunderstood how you were planning on exporting the data. Would something like this work? I'm a bit of a shell scripting beginner so there might be better ways to achieve this. After this line: # check that function is defined
declare -f prompt_pure_preprompt_postprocess > /dev/null;
if [ $? -eq 0 ]; then
prompt_pure_preprompt_postprocess "${preprompt_parts[@]}";
fi prompt_pure_preprompt_postprocess() {
local my_prompt = ("$@");
# manipulate here
preprompt_parts = my_prompt;
} |
I would like to have the output of |
I want to add a couple of my own indicators to preprompt line: enabled virtualenv and mc/ranger subshell. I can easily define some functions or variables to return this info, all I need is a way for adding it to preprompt. Maintaining a fork is a last resort here, as I believe I wouldn't be a single person to benefit from such possibility.
The text was updated successfully, but these errors were encountered: