Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Niggling little problem with a theme

On Wed, Dec 11, 2019 at 1:37 PM Lewis Butler <lbutler@xxxxxxxxxx> wrote:
> PROMPT=$'%{$fg[magenta]%}$(toon)%{$reset_color%} %{$fg_bold[green]%}%n@%m %{$fg_bold[blue]%}%#%{$reset_color%} '
> RPROMPT=$'%{$fg[blue]%}[%T] %{$reset_color%}%{$fg[white]%}[%~]%{$reset_color%} ‘
> Works fine in nearly all cases, but occasionally when I am trying to edit a command line, the space after the prompt disappears and it makes it quite difficult to edit as the command that appears on the screen is shifted one character off.

You need to look at the "glitch" feature of prompts:

       %G     Within a %{...%} sequence, include a `glitch': that  is,  assume
              that  a  single  character width will be output.  This is useful
              when outputting characters that otherwise  cannot  be  correctly
              handled  by  the  shell,  such as the alternate character set on
              some terminals.  The characters  in  question  can  be  included
              within  a  %{...%} sequence together with the appropriate number
              of %G sequences to  indicate  the  correct  width.   An  integer
              between  the  `%' and `G' indicates a character width other than
              one.  Hence %{seq%2G%} outputs seq and assumes it takes  up  the
              width of two standard characters.

So you probably want either %{$(toon)%2G%} in your PROMPT assignment
(indicating that the output of $(toon) takes up exactly two character
widths), or to modify the "toon" function to output the %{...%} along
with the correct number of "glitches" for the emoji it prints.  The
latter is likely more easily modifiable.

Messages sorted by: Reverse Date, Date, Thread, Author