agkozak / agkozak-zsh-prompt

A fast, asynchronous Zsh prompt with color ASCII indicators of Git, exit, SSH, virtual environment, and vi mode status. Framework-agnostic and customizable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sandangel opened this issue · comments

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

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.

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.

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

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!

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

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.

@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.

@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

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.

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

Any plans to merge it to main branch?

@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)?

@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 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.

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

@sandangel What operating system are you using?

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

@sandangel Try typing

 echo $AGKOZAK_ASYNC_METHOD

and see what it says.

@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.

@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

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?

@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.

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.

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 ?

@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.

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!