-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
Add support for modifying the pre-prompt (add / edit / remove pre-prompt parts) #460
Comments
do you expect users to list segments they would love to see available (so that you can pre-code them, even if they are not enabled by default)?
In case you are not expecting input like this, feel free to delete my comment :-) |
for workaround I added Then just have But something similar would be nice. |
Just throwing in my support - I've been using the https://github.com/intelfx/pure branch (which is now really far behind), but allows customization by adding to (I've added things such as a shrunken path via oh-my-zsh |
I would also like to see this feature added. I enjoy using |
@IssueHunt has funded $80.00 to this issue.
|
One use-case I had in mind for this: I've been wanting a way to automatically switch the active Node.js version when I enter a Node.js project. It would switch to match the Node.js range in the I would use |
@sindresorhus take a look at nvm |
@awmottaz Yes, I'm aware of |
I can see a copule of ways of approaching this customization. Step 0. split the rendering of part prompts in to functions; Then: Option a: something like intelfx branch. # optionally define custom generators
prompt_custom() {
preprompt_parts+=( custom )
}
prompt pure
# add the generator where it's needed
prompt_pure_pieces=(
${prompt_pure_pieces:0:2}
prompt_custom
${prompt_pure_pieces:2}
) Thought the API suggested by the OP is probably nicer
This allows "full" control but would be fragile to ordering change of the built in prompt parts. Option b: add
Option c: combine both of them for total control. Does anyone have thoughts? |
We could look at https://github.com/denysdovhan/spaceship-prompt for inspiration about customizability (They already got a lot of inspiration from Pure). |
This issue is for tracking discussion and development of an extension to the pre-prompt that will allow users to make modifications to it by some means.
The purpose is to minimize the need for our users to maintain a fork just so that they can add some information to the pre-prompt.
Prologue: It would be nice to provide an API that allows user defined segments to run asynchronously as well. And it should be simple enough that it’s hard to make mistakes. Ordering of parts/segments would also be nice and if we ever make a new segment it would be nice if the user doesn’t have to manually enable it due to hard coding the current segments, or whatnot.
Perhaps functions like
prompt_pure_add_segment myfunc
and_set_order myfunc 3
(moves it to pos 3 and old 3-n are offset by one).Another thought I’ve had is more hook-like, e.g. right before re-rendering the prompt. A hook function is called where you can manually modify the preprompt array, but it requires a bit more intimate knowledge of how to work with zsh arrays.
Issue originally raised by @sindresorhus in #458 (comment)
The text was updated successfully, but these errors were encountered: