Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>So I figured it out. It turns out I wasnt properly escaping the ANSI color codes (I think). Everywhere I had $reset_color in my PROMPT variable, I changed that to %{$reset_color%} and it fixed it.</p> </blockquote> <p>I only discovered <a href="https://wiki.archlinux.org/index.php/Zsh#Colors" rel="noreferrer">this link</a> tonight, after messing with my prompt - I'd always wondered <em>why</em> the ZSH prompt examples seemed so needlessly complex. </p> <p>When you set up the colors in your <code>zsh</code> prompt, you should escape things with <code>%{ [...] %}</code>, so that 'the shell knows there is no output from these sequences and the cursor hasn't moved'. </p> <p>If you <em>don't</em> escape this, the shell believes that your cursor has moved (even though it hasn't). This leads to messed up prompts, and rather annoying visual effects when you use tab-completion etc. </p> <p>Here's some screenshots <em>without</em> escaping the <code>reset-color</code> prompt sequence (<code>PR_NO_COLOUR="%{$terminfo[sgr0]%}"</code>, in my prompt settings). As we can see, the cursor starts in the wrong place:</p> <p><img src="https://i.stack.imgur.com/lQU3h.png" alt="Cursor starts in the wrong place"></p> <p>It should be here:</p> <p><img src="https://i.stack.imgur.com/4fMxN.png" alt="Correctly-placed cursor"></p> <p>And after trying tab-completion without escaping, the prompt is all confused about where the text is, and where the cursor should be placed:</p> <p><img src="https://i.stack.imgur.com/6PZv6.png" alt="Cursor is in the middle of the word"></p> <p>(The cursor should be placed at the end of the directory, not halfway through). </p> <p>So the prompt sequences look like this:</p> <pre><code>PS1="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% " </code></pre> <p>because everything has to be escaped nicely inside <code>%{...%}</code> pairs. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload