zsh-users
 help / color / mirror / code / Atom feed
* Niggling little problem with a theme
@ 2019-12-11 21:35 Lewis Butler
  2019-12-11 22:18 ` Perry Smith
  2019-12-12  0:28 ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Lewis Butler @ 2019-12-11 21:35 UTC (permalink / raw)
  To: zsh-users

I have a theme that is a modification of the candy.zsh-theme that uses an emoji for the prompt (I have a version for three different systems using the 🍰 and 🍎 for rPi and Macs as well as this one for my FreeBSD machines).

👹 root@mail # cat ~/.oh-my-zsh/themes/bsd-candy.zsh-theme
function toon {
  echo -n "👹"
}


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%} ‘
---EOF

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.

Is this just an artifact of using multi-byte character?

(My terminal is normally macOS’s Terminal.app, but this issue also happens when I am on the console on the freeBSD machine.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Niggling little problem with a theme
  2019-12-11 21:35 Niggling little problem with a theme Lewis Butler
@ 2019-12-11 22:18 ` Perry Smith
  2019-12-12  0:28 ` Bart Schaefer
  1 sibling, 0 replies; 5+ messages in thread
From: Perry Smith @ 2019-12-11 22:18 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1993 bytes --]



> On Dec 11, 2019, at 3:35 PM, Lewis Butler <lbutler@covisp.net> wrote:
> 
> I have a theme that is a modification of the candy.zsh-theme that uses an emoji for the prompt (I have a version for three different systems using the 🍰 and 🍎 for rPi and Macs as well as this one for my FreeBSD machines).
> 
> 👹 root@mail # cat ~/.oh-my-zsh/themes/bsd-candy.zsh-theme
> function toon {
>  echo -n "👹"
> }
> 
> 
> 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%} ‘
> ---EOF
> 
> 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.
> 
> Is this just an artifact of using multi-byte character?
> 
> (My terminal is normally macOS’s Terminal.app, but this issue also happens when I am on the console on the freeBSD machine.

The one experiment I would do is use “script” … its a command that drops you into another shell and captures all the input and output into a file called “typescript”.  Its on Mac and I’d be shocked if it isn’t on BSD.

The first question would be can you recreate the problem while inside script?  And if so, then get out of script (with ^D) and look at the typescript file and see if you can figure out the differences between the working case and the non-working case.  For example, are some characters in the non-working case not bring sent out or perhaps some characters are written in a different order.  Looking at the typescript file can be hard.  I use emacs for that which tends to not get confused.  Another choice is to pass it through od.

The other thought / question is if COMBINING_CHARS on or off makes any difference.  /etc/zshrc on Catalina sets that on some cases.


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2966 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Niggling little problem with a theme
  2019-12-11 21:35 Niggling little problem with a theme Lewis Butler
  2019-12-11 22:18 ` Perry Smith
@ 2019-12-12  0:28 ` Bart Schaefer
  2019-12-12 10:30   ` Lewis Butler
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2019-12-12  0:28 UTC (permalink / raw)
  To: Lewis Butler; +Cc: Zsh Users

On Wed, Dec 11, 2019 at 1:37 PM Lewis Butler <lbutler@covisp.net> 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Niggling little problem with a theme
  2019-12-12  0:28 ` Bart Schaefer
@ 2019-12-12 10:30   ` Lewis Butler
  2019-12-12 10:44     ` Roman Perepelitsa
  0 siblings, 1 reply; 5+ messages in thread
From: Lewis Butler @ 2019-12-12 10:30 UTC (permalink / raw)
  To: Zsh Users

On 11 Dec 2019, at 17:28, Bart Schaefer <schaefer@brasslantern.com> wrote:
> You need to look at the "glitch" feature of prompts:

Thanks, I’ll give that a try. I still haven’t figured out exactly when this happens, so I’ll keep an eye on it.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Niggling little problem with a theme
  2019-12-12 10:30   ` Lewis Butler
@ 2019-12-12 10:44     ` Roman Perepelitsa
  0 siblings, 0 replies; 5+ messages in thread
From: Roman Perepelitsa @ 2019-12-12 10:44 UTC (permalink / raw)
  To: Lewis Butler; +Cc: Zsh Users

On Thu, Dec 12, 2019 at 11:31 AM Lewis Butler <lbutler@covisp.net> wrote:
>
> On 11 Dec 2019, at 17:28, Bart Schaefer <schaefer@brasslantern.com> wrote:
> > You need to look at the "glitch" feature of prompts:
>
> Thanks, I’ll give that a try. I still haven’t figured out exactly when this happens, so I’ll keep an eye on it.

It likely happens when you type `ls<TAB>` or hit Ctrl-R.

Roman.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-12 10:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-11 21:35 Niggling little problem with a theme Lewis Butler
2019-12-11 22:18 ` Perry Smith
2019-12-12  0:28 ` Bart Schaefer
2019-12-12 10:30   ` Lewis Butler
2019-12-12 10:44     ` Roman Perepelitsa

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).