-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Example of customization: left prompt only, $ as the symbol #9
Conversation
ab16353
to
bba91ce
Compare
@agkozak would you possibly be interested in making your prompt fully customizable? For example, as I was looking for a prompt, I was usually interested in customizing:
I know this would be quite some work and that's probably the reason why most prompts hardcode a lot of things but it would be so nice to be able to do that without forking. |
Thank you so much for your kind words and encouragement. I am keen to implement the sort of changes that you recommend. First, though, a little history. The agkozak-zsh-theme was originally merely a rewriting in ZSH code of my pan-POSIX prompt Polyglot, which attempts to provide more or less the same Git prompt in all relevant POSIX shells without using any symbols that could interfere with any terminals or fonts that I might happen to use. I decided to write a ZSH-specific version of the theme because I saw how much simpler and more elegant the script could be (here it is before I introduced any asynchronicity into it!). Like you, however, I frequently use MSys2 (and, to a lesser extent, Cygwin). You know from experience how uncommonly slow forking is in those environments. I can think and type faster than I can now see that the three-tiered asynchronous system is useful enough in its own right to justify making the theme transcend the layout choices I imposed on it. @joeleisner was kind enough to contribute the system of color choices you see that it has now. Your suggestions are all worthy of consideration, and I will start working immediately to introduce more variables to effect the look-and-feel customizations that you propose. I shall probably start by creating a branch to experiment in. I will keep you and any other interested parties aware of new customizations as I implement them. Thank you so very much for contributing to this project. |
That sounds excellent! I also think that it is quite uncommon that a prompt author would be so open to customization :) I'll just throw an idea around: if my prompt looks like this:
maybe there could be a mini-language that would allow me to specify the prompt via something like this (inspired by chalk-cli and ES2015 template literals):
I guess in the end, it's just an attempt to make the built-in syntax more readable so that non-experts like me would be able to customize it. I can imagine you have better ideas though :) Thanks a lot! |
Hey, everyone! Just wanted to stop by, as I saw @agkozak 's mention of me (thank you for the kind words, by the way; always glad to contribute). After reading through the thread, I definitely like the idea of making the prompt's structure more configurable. My initial thought was having a Just an idea! I'm excited to see what comes of this thread. |
I'm inclined to advocate a simpler system that is closer to how ZSH works natively -- perhaps as a sort of shorthand for the real thing. For example, I've written a mere 33 lines of code that can construct @borekb's prompt expressed as
That's a simple array that I can iterate over. An example of the default theme expressed thus can be provided in the documentation as a template. And ultimately, as the user learns more about what ZSH can do, he or she will want to add some native code. For example, @borekb's prompt has no way of indicating if he's a superuser; if he wanted to do so he could change it to
meaning that there's some ZSH code here: If superuser, prompt character is #, otherwise $. If we create a metalanguage capable of expressing a ternary condition in a prompt or any of the other lovely features ZSH provides, it will end up being as complex as ZSH code and less well documented. In any case, the first thing I'll do is to come up with a simple way to override the default prompt. I'll let you know when that's ready. |
I suppose we could eventually add a feature where the elements that make up the prompt are defined in an additional associative array; that way it would be easy for people to add new elements and redefine default ones. That would allow for maximum configurability without muddling up the environment with hundreds of option variables. |
That looks awesome! You seem to hit a great balance between customizability, simplicity and staying true to zsh. 👍 |
Thanks, @borekb! I'll finish off something quickly for us to experiment with. Perhaps I can even use your customizations as an example in the documentation. |
I am making progress on a macro language for describing prompt themes. In the meantime, I thought it would be helpful to provide a simple way to make the sort of changes @borekb described without having to fork the repo. @borekb, if you check out the
you should get your theme. Let me know what you think. If you agree that this works, we can call it version 2.1 of the theme, with theme templating to follow in version 3.0. |
That is just great! I needed to update your example a bit, this gives me exactly the same as on screenshots above:
Cool that I can get rid of my fork now! |
You've got it! For that matter, you can even change the top lines to
and you'll get the same effect, but without that annoying (to me) initial blank line in every terminal. You'll still get blank lines after that. In the I think I'm going to rename the project to "The agkozak ZSH Prompt," instead of agkozak-zsh-theme. It's a themable prompt now -- it was never really a theme, right? If I go so far as to rename the repo, Github should handle the redirects sufficiently, I think. |
Thanks, that's a good tip – something was a little bit annoying compared to my fork and I didn't know what. Now I know :)
Yes, GitHub should redirect everything. I also think renaming this prompt is a very good idea, just didn't dare to suggest it :) I'd probably go even further and gave it some short and sweet name, it also affects how the variables look (typically). As an inspiration, I think that Pure is a beautiful name for a prompt. Naming is hard though... |
Perhaps I'll think of a more marketable name while I finish the macro language. :) For now, I've just changed everything having to do with "theme" to "prompt." That's been bugging me for months, and soon we will have real themes. Thanks for the kind words on Twitter, and thanks again for all the encouragement! |
Thanks for all the discussion here, and I'm thrilled that you're creating a fully customizable prompt as a result. I've updated the OP to point to the new customizability in the |
Thanks. I just moved the latest updates to the |
Great work! Excited to try out these changes. |
@borekb I'm putting together a collection of some of the nicer customizations people have constructed with agkozak-zsh-prompt, and I noticed that with recent additions to the prompt, your
can now be expressed as simply as
Progress! |
Very nice! |
UPDATE: the customization via forking is no longer necessary, see #9 (comment).
First of all, thank you for this prompt. On Mac, I use the Pure prompt but that doesn't work on Windows due to the
zsh/zpty
issue inzsh-async
(mafredri/zsh-async#26). Yours is the only one I found so far that works in MSYS2 and is asynchronous, which is awesome.Now, I prefer the simpler style of
pure
so I've customized your prompt a bit. I don't expect a merge or anything but wanted to share this as a possible inspiration for others.The forked prompt with some slight color customization (
AGKOZAK_COLORS_BRANCH_STATUS=243
) looks like this: