starship: New nodejs character positioned incorrectly
Bug Report
Current Behavior
The prompt for nodejs directories uses a new nerd-font character that does not render correctly. It’s positioned incorrectly and results in a collision with neighboring characters.
Expected Behavior
The nodejs character should not collide with neighboring characters.
Additional context/Screenshots
Possible Solution
Revert #1649.
Environment
- Starship version: starship 0.51.0
- Shell type: zsh
- Shell version: zsh 5.8 (x86_64-apple-darwin20.0)
- Shell plugin manager: none
- Terminal emulator: Terminal
- Operating system: macOS 11.2.3
Relevant Shell Configuration
# Bash style word boundaries (including / and -)
autoload -U select-word-style
select-word-style bash
# Git completions
autoload -Uz compinit && compinit
# rbenv (Ruby version manager)
# [Disabled for performance reasons]
# eval "$(rbenv init -)"
# nvm (node version manager)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH="/usr/local/sbin:$PATH"
eval "$(starship init zsh)"
Starship Configuration
# Don't print a new line at the start of the prompt
add_newline = false
# Replace the "❯" symbol in the prompt
[character]
success_symbol = "[❯]()"
# Disable the package module, hiding it from the prompt completely
# [package]
# disabled = true
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 23 (10 by maintainers)
Commits related to this issue
- starship: fix nodejs symbol reference: https://github.com/starship/starship/issues/2546 Signed-off-by: Chawye Hsu <chawyehsu@hotmail.com> — committed to chawyehsu/dotfiles by chawyehsu 3 years ago
- fix: nodejs character positioned incorrectly https://github.com/starship/starship/issues/2546 — committed to azzamsa/dotfiles by azzamsa 3 years ago
For others encountering this, the config workaround is:
should we change the default of symbol to e718? currently it is f898, https://github.com/starship/starship/blob/master/src/configs/nodejs.rs#L24 they seem similar.
after adding following config in starship.toml.
this problem is solved.
For anyone being affected by this: we used to have two spaces after the nodejs symbol to avoid this problem. However, at some point, we got rid of this because it didn’t work and also broke other terminals. (I am unable to locate the PR at the moment).
We can use a similar setting to undo the overlap issue. It gives us a slightly spaced out prompt, but the character overlapping is gone:
So as I see it, you have four options:
Options for a fix
Use the following configuration to insert enough spaces that the overlap no longer happens. This will cause excessive spacing when using other terminal emulators.
Change the symbol to a non-NerdFont symbol, e.g. the “Black Hexagon” symbol, which are usually a little better-behaved across most terminal emulators.
Use a different terminal emulator which is less bad about finding symbol widths (iTerm2 is popular, as are Hyper, Alacritty, and Kitty).
Wait for Apple to fix their software.
I suspect the difference in rendering between the node.js symbol and (for example) the git branch symbol, is that kitty will render a glyph a different size depending on, amongst other things, the amount of spaces after it: https://github.com/kovidgoyal/kitty/issues/2672.
This does not affect the git branch icon (maybe because it is already tall), but for the node.js icon it will render small if there is no space after it:
and larger if there is one space after it:
So the icon size is basically not static. Which leads to the discrepancy we’re seeing for the node.js glyph. Starship prints a space after the node.js glyph, which is eaten up by the glyph increasing in size, instead of being used as whitespace between the glyph and the version string.