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

Start of command gets doubled with tab-completion #2176

Open
marier-nico opened this issue Jan 20, 2021 · 19 comments
Open

Start of command gets doubled with tab-completion #2176

marier-nico opened this issue Jan 20, 2021 · 19 comments
Labels
🐛 bug Something isn't working as expected.

Comments

@marier-nico
Copy link

Current Behavior

Whenever I start typing a command and use tab-completion, the first characters of the command get repeated at the start of the line.

Expected Behavior

Tab completion should work the same regardless of whether or not I'm using Starship.

Additional context/Screenshots

This shows the behavior with Starship. The first time I press Tab, the name of the folder is completed. The second time I press Tab (to show available subfolders), for some reason, an additional ll gets added at the start of the line.
starship-double-letter

This shows the behavior which I expect to happen. The only difference between these two examples is that I commented out the line to eval starship init. This is what led me to conclude that Starship was causing the behavior.
starship-expected-behavior

I also tried to disable all the other extensions / plugins that get loaded in my .zshrc (aside from Starship), and I can still observe the same behavior.

Environment

  • Starship version: 0.48.0
  • zsh version: zsh 5.8 (x86_64-pc-linux-gnu)
  • Operating system: Arch Linux (Kernel: 5.10.8-arch1-1)
  • Terminal emulator: alacritty 0.7.1 (but this also happens on kitty 0.19.3)

Relevant Shell Configuration

# Source zsh-autosuggestions
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
ZSH_AUTOSUGGEST_USE_ASYNC=yes
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

# Source zsh-syntax-highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# Source aliases
source ~/.dots/config/zsh/aliases.zsh

# Source ssh-agent
source ~/.dots/config/zsh/ssh-agent.zsh

# Load venv-wrapper
eval "$(venv-wrapper init)"

# Load pyenv
eval "$(pyenv init -)"

# Load starship (prompt)
eval "$(starship init zsh)"

Starship Configuration

[aws]
disabled = true

[battery]
disabled = true

[character]
success_symbol = "[⤚](bold green)"
error_symbol = "[⤚](bold red)"
vicmd_symbol = "[⤙](bold green)"

[cmake]
disabled = true

[conda]
disabled = true

[crystal]
disabled = true

[dart]
disabled = true

# [directory]

# [docker_context]

[dotnet]
disabled = true

[elixir]
disabled = true

[elm]
disabled = true

[env_var]
disabled = true

[erland]
disabled = true

[gcloud]
disabled = true

# [git_branch]

# [git_commit]

# [git_state]

# [git_status]

[golang]
disabled = true

# [hostname]

# [java]

# [jobs]

[julia]
disabled = true

# [kubernetes]

# [line_break]

[lua]
disabled = true

# [memory_usage]

# [hg_branch]

[nim]
disabled = true

[nix_shell]
disabled = true

# [nodejs]

# [package]

[ocaml]
disabled = true

[openstack]
disabled = true

[perl]
disabled = true

[php]
disabled = true

# [python]

[ruby]
disabled = true

# [rust]

# [shlvl]

[singularity]
disabled = true

[swift]
disabled = true

# [status]

# [terraform]

# [time]

# [username]

[zig]
disabled = true

[custom]
disabled = true

[purescript]
disabled = true
@marier-nico marier-nico added the 🐛 bug Something isn't working as expected. label Jan 20, 2021
@chipbuster
Copy link
Contributor

We often see this issue when LANG or LC_ALL are misconfigured. What do you have your locales set to and what are the default values of those two variables?

@marier-nico
Copy link
Author

Oh interesting! I looked through the FAQ for info on locales and noticed this bit

If LC_ALL is not a UTF-8 value, you will need to change it.

I'm guessing this might be the issue in my case, given that it's not currently set to anything.

LANG=fr_CA.UTF-8
LC_CTYPE="fr_CA.UTF-8"
LC_NUMERIC="fr_CA.UTF-8"
LC_TIME="fr_CA.UTF-8"
LC_COLLATE="fr_CA.UTF-8"
LC_MONETARY="fr_CA.UTF-8"
LC_MESSAGES="fr_CA.UTF-8"
LC_PAPER="fr_CA.UTF-8"
LC_NAME="fr_CA.UTF-8"
LC_ADDRESS="fr_CA.UTF-8"
LC_TELEPHONE="fr_CA.UTF-8"
LC_MEASUREMENT="fr_CA.UTF-8"
LC_IDENTIFICATION="fr_CA.UTF-8"
LC_ALL=

I just tried to use eval "$(LC_ALL="fr_CA.UTF-8" starship init zsh)" instead of just eval "$(starship init zsh)" and that does work how I would expect it to! I wonder why that's required though, it seems like LC_ALL is intended for troubleshooting.

LC_ALL is the only LC_* variable which cannot be set in locale.conf files: it is meant to be used only for testing or troubleshooting purposes, for example in /etc/profile.

Arch Wiki

Do you think it working with LC_ALL="fr_CA.UTF-8" is an indication of another issue with my configuration perhaps?

@davidkna
Copy link
Member

Do you have LC_ALL= like that in your profile/locale.conf? That might cause it to be set to an empty string and cause the issue.

@marier-nico
Copy link
Author

I've only modified the /etc/locale.conf file (its contents are only LANG=fr_CA.UTF-8), so I don't think that's it 🤔

@chipbuster
Copy link
Contributor

@marier-nico Yeah, this is a bit of a weird point. I was actually drafting a PR to change the FAQ when I saw your issue, and now I vaguely recall that we'd seen an issue like this before where having LANG set wasn't enough to fix the issue, though setting LANG alone has solved pretty much example of the issue I've seen in the last year.

It's also a little surprising to me that setting LC_ALL for just the init phase is enough to get rid of the problem, since all that really does in ZSH is define some function hooks and register them with precmd/preexec. The actual drawing/rendering is done independently each time in the main environment, which presumably doesn't have LC_ALL set.

@marier-nico
Copy link
Author

I can't really explain it either, especially since I'm not at all familiar with what LC_ALL does under the hood 😅

I'd be happy to provide any system info that could be helpful if you'd want to try to get to the bottom of this. Otherwise I figure we can close this since we found a way to make it work.

@optikfluffel
Copy link
Contributor

I have the same issue on macOS (10.15.7) using zsh with zsh-autosuggestions.

@Ray-Eldath
Copy link

Have the same issue on Windows 10 2004 with Windows Terminal. but in my case only 0.49.0 have this issue while 0.48.0 and older seems works fine.

@davidkna
Copy link
Member

@Ray-Eldath Interesting. I don't think the only change to the powershell init script in 0.49.0 (#2104) could have caused this. But are sure this is related to the starship update? Windows Terminal also just had a big update.

@Ray-Eldath
Copy link

@Ray-Eldath Interesting. I don't think the only change to the powershell init script in 0.49.0 (#2104) could have caused this. But are sure this is related to the starship update? Windows Terminal also just had a big update.

Sorry for late reply.
I've recorded a GIF about different behavior between 0.48.0 and 0.49.0. seems it's pretty clear to me that the issue came up only after I switched to the newer version with scoop reset.

starship

@davidkna
Copy link
Member

davidkna commented Feb 2, 2021

@Ray-Eldath Can you check if #2258 fixes your issue?
Edit: Looks like it fixes your issue.

@dooreelko
Copy link

For me it was LC_CTYPE=C. now i only have
export LC_ALL=en_US.UTF-8 and all is back to normal.

844196 added a commit to 844196/dotfiles that referenced this issue Nov 18, 2021
ryuheechul added a commit to ryuheechul/dotfiles that referenced this issue May 15, 2022
It was caused by wrongly unsetting $STARSHIP_SHELL

a related issue was found at starship/starship#2176
@ryuheechul
Copy link
Contributor

ryuheechul commented May 15, 2022

@ryuheechul
Copy link
Contributor

In another specific case with WSL on Ubuntu 22.04 with Zsh, nothing related locale worked for me except export LC_ALL="C.UTF-8" . Somehow export LC_ALL="en_US.UTF-8" didn't work so I settled with C.UTF-8 instead.

@davidkna
Copy link
Member

@ryuheechul Perhaps the corresponding en_US.UTF-8 is not installed in your WSL system? It uses a minimal Ubuntu installation.

@ryuheechul
Copy link
Contributor

ryuheechul commented Sep 13, 2022

@davidkna That's what I thought initially too but strangely that doesn't seem to be the case with Ubuntu 22.04. I tried multiple ways to ensure the whole suite of en_XX to be installed but still failed with any except with C.UTF-8 even though system reports en_XX is installed and I kind of gave up on en_XX for now...

Perhaps the corresponding en_US.UTF-8 is not installed in your WSL system? It uses a minimal Ubuntu installation.

@kode54
Copy link

kode54 commented May 29, 2023

This is also a problem on macOS, which doesn't even set any locale variables in the shell by default. Setting LANG=en_US.UTF-8 in my .zshrc fixes it.

@wookiesh
Copy link

wookiesh commented Oct 8, 2023

Same issue, @ryuheechul's answer put me on track, and I ended up using eval $(/usr/bin/locale-check C.UTF-8) to fix the issue.

@mhanberg
Copy link

I am on a fresh Ubuntu MATE 23.10 installation with starship installed via nix (nix profile install nixpkgs#starship) and the only thing i could get it work with zsh is adding export LC_ALL="C.UTF-8" to my zshrc.

setting it with export LC_ALL="en_US.UTF-8" did not work, and also printed odd warnings (shown below)

/nix/store/lf0wpjrj8yx4gsmw2s3xfl58ixmqk8qa-bash-5.2-p15/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/nix/store/lf0wpjrj8yx4gsmw2s3xfl58ixmqk8qa-bash-5.2-p15/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working as expected.
Projects
None yet
Development

No branches or pull requests

10 participants