Bug 678578 - Cursor position when completing and using a prompt with colour escape characters is wrong
Summary: Cursor position when completing and using a prompt with colour escape charact...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: zsh
Version: 13
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: James Antill
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-02-18 14:08 UTC by Enrique
Modified: 2011-02-19 18:18 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-02-18 15:03:32 UTC
Type: ---


Attachments (Terms of Use)

Description Enrique 2011-02-18 14:08:39 UTC
Description of problem:

 I am using a prompt with some colour characters, like:

PROMPT=$'\e[0;32muser@host:\e[0;34m%/+ \e[0m'

which uses escape sequences to display green and blue colours.
However, if I press tab to complete files, the cursor position is moved to the right, like:

user@host:/tmp+ ls file           ls file
file1  file2
 
 The first "ls file" is what I typed, while the second one appears when I press tab. It seems that the sequence characters are also counted to place the cursor after completion.
 Related to that is the breaking of long lines before one reaches the rightmost end of the terminal. That makes also very annoying to recover commands from the history longer than the terminal width.


How reproducible:
 
 Always

Comment 1 James Antill 2011-02-18 15:03:32 UTC
1. Don't use \e directly, use %F{red} and %K{blue} etc.

2. Use %{\e[0;32m%}blah ... which tells the prompt that the characters are zero width (also see the docs. for %G.

Comment 2 Enrique 2011-02-19 18:18:28 UTC
 Option 2. worked perfectly. It is a pleasure to see a promptly and accurate response.
 Thank you!


Note You need to log in before you can comment on or make changes to this bug.