Navigating (Bash) history shifts cursor and history string left when prompt contains emoji
When the Bash prompt containing emoji, when navigating through history with the up arrow, the cursor shifts to the left, by one position per emoji in the prompt.
This is relevant for example when using utilities that add additional, emoji-labelled information (Git status etc.) to the the prompt, e.g. https://starship.rs/.
To reproduce:
Without Starship:
- Configure the prompt to contain one or more emoji, e.g.
export PS1='📦>'
in/etc/bashrc
. - Navigate through history with the up arrow twice.
With Starship:
-
Disable Starship's
line_break
extension (to put its emoji-labelled info on the same line as the prompt), in~/.config/starship.toml
:[line_break] disabled = true
-
Navigate to a directory that triggers a module that uses an emoji label (e.g.
package
orpython
). Alternatively set an emoji label for thegit_branch
module and navigate to a Git project dir:[git_branch] symbol = "🌱 "