Skip to content
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

How to change the start mark from '%' to another? #15

Closed
sandangel opened this issue Jan 7, 2019 · 26 comments
Closed

How to change the start mark from '%' to another? #15

sandangel opened this issue Jan 7, 2019 · 26 comments
Assignees

Comments

@sandangel
Copy link

I want to change the start mark from '%' to another mark (lambda mark), how could I do that

@agkozak
Copy link
Owner

agkozak commented Jan 7, 2019

I have noticed that a lot of people want to change the prompt character. Give me a couple of days and I'll come up with a way to set it to whatever you like using a simple variable.

@agkozak agkozak self-assigned this Jan 7, 2019
@agkozak
Copy link
Owner

agkozak commented Jan 7, 2019

The solution right now would be to have a custom left prompt in your .zshrc:

AGKOZAK_CUSTOM_PROMPT='%(?..%B%F{red}(%?%)%f%b )'
AGKOZAK_CUSTOM_PROMPT+='%(!.%S%B.%B%F{green})%n%1v%(!.%b%s.%f%b) '
AGKOZAK_CUSTOM_PROMPT+=$'%B%F{blue}%2v%f%b\n'
AGKOZAK_CUSTOM_PROMPT+='%(4V.:.ⲗ) '

Give that a try. But I do mean to come up with a simpler way of changing the setting.

@sandangel
Copy link
Author

thank you, please support config for changing the start mark at the beginning of the first line and second line, as well as git status sign, and auto-compare the git remote/local to show if we already push or need to pull like pure-prompt

@agkozak
Copy link
Owner

agkozak commented Jan 7, 2019

the start mark at the beginning of the first line and second line

I'm not quite sure what you mean by that. Could you explain? Thanks!

@sandangel
Copy link
Author

Hi @agkozak , I mean For now the '%' mark is on the second line, and there is no mark at the beginning of first line. So it would be great if you could make it easy to change the mark at the beginning of both line like the picture below:

screen shot 2019-01-08 at 0 22 05

@agkozak
Copy link
Owner

agkozak commented Jan 15, 2019

All right, @sandangel. You might like to try what I’ve now got on the develop branch. You can now specify the array $AGKOZAK_PROMPT_CHAR, which should consist of three strings: 1) the prompt for a regular user; 2) the prompt for a superuser; and 3) the prompt when in vi command mode (which is not relevant if you use Emacs keybindings). The default is the equivalent of

AGKOZAK_PROMPT_CHAR=( %# %# : )

If you’d always like to see a lambda, you can just do the following. First, get rid of the $AGKOZAK_CUSTOM_PROMPT I showed you before. Then start up a fresh shell and enter

AGKOZAK_PROMPT_CHAR=( λ λ λ )

Play around with it a bit. You can even use colors, if you like, e.g.

AGKOZAK_PROMPT_CHAR=( λ '%F{green}λ%f' '%F{yellow}λ%f' )

Let me know if that addresses your needs. I’ll continue to work on your other requests.

@agkozak
Copy link
Owner

agkozak commented Jan 15, 2019

@sandangel I just added a feature to the develop branch. If you copy and paste

AGKOZAK_CUSTOM_SYMBOLS=( '&*' '&' '*' '+' 'x' '!' '>' '?' )

You can edit the items in that array to be the Git symbols you want: diverged, behind, ahead, new, deleted, modified, renamed, untracked. See if you like this feature.

@sandangel
Copy link
Author

@agkozak wow thank you. This is how my current prompt looks like after customize (I'm using AGKOZAK_CUSTOM_PROMPT and master branch)
image

AGKOZAK_CUSTOM_PROMPT=$'\n%F{yellow}λ %(!.%S%B.%B%F{green})%n%1v%(!.%b%s.%f%b) '
AGKOZAK_CUSTOM_PROMPT+='%B%F{blue}%2v%f%b'
AGKOZAK_CUSTOM_PROMPT+='%(3V.%F{yellow}%3v%f.)'
AGKOZAK_CUSTOM_PROMPT+=$' %(?..%B%F{red}(%?%)%f%b )'
AGKOZAK_CUSTOM_PROMPT+=$'%F{magenta}%*\n'
AGKOZAK_CUSTOM_PROMPT+='%(4V.:.%F{cyan}→%f) '

AGKOZAK_CUSTOM_RPROMPT=''

This prompt is still not possible in the develop branch right?

Is it possible to only input only the colour that you want for the character instead of having to put between %F{}?
And I think it would be nice if the prompt auto fetching from the upstream branch like pure prompt

@agkozak
Copy link
Owner

agkozak commented Jan 16, 2019

Nice prompt!

You can accomplish a lot, but not all, of what you’ve got in your prompt using these features:

  • The extra line between prompts can be achieved with AGKOZAK_BLANK_LINES=1
  • AGKOZAK_LEFT_PROMPT_ONLY=1 will put your git status exactly where you’ve got it
  • The AGKOZAK_COLORS_* variables will let you specify colors for exit status, user and host, path, and git information

You’re very right to ask about a simpler way of specifying the color of the “prompt character” (such as % # : $ or →). I’m still working on it. I’d like to make it simple, but I imagine some people will want to have that character change color if they’re switching between insert and vi command mode. Give me a little while to play around with various ideas.

For now, I’m not going to include a setting for prepending a character such as your lambda to the prompt. If it were the only customization that you needed, you could always just put

AGKOZAK_CUSTOM_PROMPT="%F{yellow}λ%f $PROMPT"

at the end of your prompt setup. Likewise with the time of day — anyone who wants that might want it anywhere in the prompt — I can’t predict where they’ll want it, so I’ll just continue making AGKOZAK_CUSTOM_PROMPT available for people who need extra customization.

I agree with you about getting information about the remote branch. It’s something I intend to add, and I like how pure does it, but implementing it will be a little complex. I support more systems than pure, and I have to use more than one asynchronous method to do that. Rest assured that I’ll continue to work towards having this feature.

@sandangel
Copy link
Author

Thanks. I really appreciate that. I will try out the develop branch and let you know if I have more feedback.

@lfromanini
Copy link

Any plans to merge it to main branch?

@agkozak
Copy link
Owner

agkozak commented Jan 29, 2019

@lfromanini Yes, I plan to do that in the next few days. Thanks for showing interest. Are you happy with the two new features ($AGKOZAK_PROMPT_CHAR and $AGKOZAK_CUSTOM_SYMBOLS)?

@agkozak
Copy link
Owner

agkozak commented Jan 30, 2019

@sandangel I just added a feature, $AGKOZAK_COLORS_PROMPT_CHAR. If you set it to a color, it will make your prompt character that color. So, for example, if you want the prompt character to work exactly as it does in pure, you can use

AGKOZAK_PROMPT_CHAR=( '❯' '❯' '❮' )
AGKOZAK_COLORS_PROMPT_CHAR='magenta'

See what you think. The changes are on the develop branch.

@lfromanini
Copy link

@lfromanini Yes, I plan to do that in the next few days. Thanks for showing interest. Are you happy with the two new features ($AGKOZAK_PROMPT_CHAR and $AGKOZAK_CUSTOM_SYMBOLS)?

@agkozak , I really like it a lot, specially the AGKOZAK_PROMPT_CHAR! I'd added a thumbs up on your message from 14 days ago because, IMHO, it's a killer feature. Thanks for the initiative and for sharing it with community, by the way.

@sandangel
Copy link
Author

I notice the prompt startup is very slow. Could we call the prompt on zsh async hook precmd?

@agkozak
Copy link
Owner

agkozak commented Jan 30, 2019

@sandangel What operating system are you using?

@sandangel
Copy link
Author

I'm using macos mojave. The prompt becomes slower when I enable the time prompt.

@agkozak
Copy link
Owner

agkozak commented Jan 30, 2019

@sandangel Try typing

 echo $AGKOZAK_ASYNC_METHOD

and see what it says.

@agkozak
Copy link
Owner

agkozak commented Jan 30, 2019

@sandangel I don’t have access to a Mac myself, so I’ve never been able to benchmark the prompt for MacOS. The prompt should be using the subst-async method for asynchronous activities. zsh-async is only used by default on Solaris and Windows with WSL.

If you want to try the other systems, try initiating zsh these ways

AGKOZAK_FORCE_ASYNC_METHOD=‘zsh-async’ zsh

AGKOZAK_FORCE_ASYNC_METHOD=‘usr1’ zsh

See if either of those seems considerably faster.

But if the problem only arises when you add the time (%*), that’s a bit odd.

@sandangel
Copy link
Author

sandangel commented Jan 30, 2019

@agkozak hmm, I figured out it's because I'm using antigen. Switched to zplugins and lazy load the prompt and it's working well now.

AGKOZAK_PROMPT_CHAR=( '❯' '❯' '❮' )
AGKOZAK_COLORS_PROMPT_CHAR='magenta'

Great!!, I will try it. Please notify me when you release that on master

@avalonwilliams
Copy link

avalonwilliams commented Feb 1, 2019

How would one change the vi mode char? Because my config currently is like this:

_agkozak_vi_mode_indicator() {
  case $KEYMAP in
    vicmd) print -n '>' ;;
    *) print -Pn '%(!.#.$)' ;;
  esac
}

PROMPT='%(?..%B%F{red}(%?%)%f%b )'
PROMPT+='%(!.%S%B.%B%F{green})%n@%m%1v%(!.%b%s.%f%b):'
PROMPT+=$'%B%F{blue}%2v%f%b'
PROMPT+='$(_agkozak_vi_mode_indicator) '

RPROMPT='%(3V.%F{yellow}%3v%f.)'

Which outputs my prompt char as $ in insert mode or > in normal mode. How would I change it with this new feature?

@agkozak
Copy link
Owner

agkozak commented Feb 1, 2019

@AGitBoy Nice prompt! What you've got will continue to work. For a while now, though, I've been using psvar[4] to hold the vi command mode state, so if you want to you can get rid of the _agkozak_vi_mode_indicator function and replace

PROMPT+='$(_agkozak_vi_mode_indicator) '

with

PROMPT+='%(4V.>.%(!.%#.$)) '

which basically means "If psvar[4] says we're in vi command mode, then output >, otherwise see if we're a superuser, in which case output #, otherwise output $."

The new $AGKOZAK_PROMPT_CHAR setting is really intended for people who just want to change that one thing -- if there are lots of other customizations, it's best just to do it all manually, as you have done.

@agkozak
Copy link
Owner

agkozak commented Feb 5, 2019

All right. I've released v3.1 and it's now on the master branch. It includes AGKOZAK_PROMPT_CHAR, AGKOZAK_COLORS_PROMPT_CHAR, and AGKOZAK_CUSTOM_SYMBOLS, and the new features are thoroughly documented.

@Brantron
Copy link

Thanks for all your work on this, it's my second favorite plugin, only behind fzf! That said, would it be possible to support emojis in AGKOZAK_CUSTOM_SYMBOLS ?

@agkozak
Copy link
Owner

agkozak commented Mar 11, 2020

@Brantron Glad to hear it! Thanks.

I think emojis do work in AGKOZAK_CUSTOM_SYMBOLS, e.g.

image

Why don't you tell me what it is that you're trying to do and what isn't working? Try to include information about your operating system, terminal, font, etc.

@Brantron
Copy link

ahh, it's unrelated to this plugin, most emojis work but the ones that don't work I also can't echo :( thanks again for this plugin!

@agkozak agkozak closed this as completed Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants