Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor in the wrong location in Docker #1555

Closed
sjackman opened this issue Mar 7, 2018 · 6 comments
Closed

Cursor in the wrong location in Docker #1555

sjackman opened this issue Mar 7, 2018 · 6 comments
Labels

Comments

@sjackman
Copy link

sjackman commented Mar 7, 2018

Description

The cursor is in the wrong location after a command exits with a non-zero status. The cursor is on top of the third chevron of the default prompt ~ # ❯❯❯. I see this issue when I use Prezto in the Docker image ubuntu:xenial on macOS. It works as expected when I use it on macOS without Docker being involved.

Expected behavior

After an unsuccessful command, the cursor would be two characters after the last chevron.

Actual behavior

After an unsuccessful command, the cursor is directly on top of the last chevron. The next character that I type replaces the last chevron.

Steps to Reproduce

docker run -it ubuntu:xenial
apt-get update && apt-get install git zsh
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
zsh
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
  ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
zsh
false

Versions

  • Prezto commit: b3c27bb
  • ZSH version: 5.1.1
  • OS information: Ubuntu 16.04 LTS (Xenial Xerus) in Docker for Mac 17.12.0-ce-mac55 (23011) on macOS High Sierra 10.13.3
  • Apple Terminal Version 2.8 (400)
@sjackman
Copy link
Author

sjackman commented Mar 7, 2018

screen shot 2018-03-06 at 19 25 27

Press x

screen shot 2018-03-06 at 19 26 01

@notjrbauer
Copy link

notjrbauer commented Apr 5, 2018

I had the same issue on various machines with and sometimes without ssh.
I tracked it down to problems with wrongly set LANG variable.

try locale if something only says "C" thats the problem

I fixed it with following lines in .zprofile

# fixes strange cursor position / formating bug
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

@sjackman
Copy link
Author

sjackman commented Apr 5, 2018

My locale is set to POSIX. export LC_ALL=en_US.UTF-8 fixed it! Thanks, John! 💯

@robtandy
Copy link

robtandy commented Jun 1, 2018

On the ubuntu docker images page it says

"Given that it is a minimal install of Ubuntu, this image only includes the C, C.UTF-8, and POSIX locales by default. For most uses requiring a UTF-8 locale, C.UTF-8 is likely sufficient (-e LANG=C.UTF-8 or ENV LANG C.UTF-8)."

For me, setting LANG=C.UTF-8 fixed the issue with the ubuntu:artful and ubuntu:bionic images which i tested this on

@belak
Copy link
Collaborator

belak commented Jun 1, 2018

Thanks for the updates everyone! It looks like this issue is related to using a non-unicode locale with unicode in the prompt. There isn't a ton we can do about this on the prezto side, so the best fix is setting your locale to one that's unicode compatible.

EDIT: Specifically, if I had to guess, it would be related to wide unicode characters

@belak belak closed this as completed Jun 1, 2018
@belak belak added the Invalid label Jun 1, 2018
@sjackman
Copy link
Author

This issue bit my again, but under a different circumstance. This bug started occurring when ssh'ing into a remote Linux machine, and it had been working reliably the day before. I wasn't what had changed. I turns out that I changed the locale of my macOS laptop from 🇺🇸 to 🇨🇦. That caused my locale on the remote Linux machine to change from en_US.UTF-8 to en_CA.UTF-8. It seems that those environment variables are being passed through ssh. export LC_ALL=en_US.UTF-8 fixed it. The remote machine was not have that locale installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants