#7420·starship

$fill miscounts width of ZWJ emoji sequences (e.g. ‍ in home_symbol), producing extra fill characters

Author: rwestMSFTCreated Apr 24, 2026Updated Sep 25, 2026
Labels🐛 bug

pkg_version:1.25.0 branch: commit_hash: build_time:2026-04-18 11:10:42 +00:00 build_env:rustc 1.94.1 (e408947bf 2026-03-25) (Homebrew),

Generated bug report:

Current Behavior

Borrowing design cues from Powerlevel 10k, I have a two-line prompt. In iTerm2, when I am in my home directory, I want to use a ZWJ emoji character instead of ~ as the path name. When I do this, the clock wraps the last two characters to the next line.

Expected Behavior

The clock should not wrap to the next line when using a ZWJ emoji character as my path name.

Additional context/Screenshots

It seems like the Rust unicode-width crate doesn't handle ZWJ emoji sequences when calculating the display width of prompt content: it sums individual codepoint widths as opposed to recognizing the sequence renders as a single glyph.

To work around this, I tell the terminal it's two characters shorter than it thinks. The effect is that the clock is not quite right-aligned, but at least it doesn't wrap.

bash
__fix_tw() { [[ "$PWD" == "$HOME" ]] && __STW=$(( COLUMNS - 2 )) || __STW=$COLUMNS; }
precmd_functions+=(__fix_tw)
PROMPT="${PROMPT//\$COLUMNS/\$__STW}"

Possible Solution

Calculate the ZWJ emoji as a single glyph.

Environment

  • Starship version: 1.25.0
  • zsh version: zsh 5.9 (arm64-apple-darwin25.0)
  • Operating system: Mac OS 26.4.1
  • Terminal emulator: Apple_Terminal 470
  • Git Commit Hash:
  • Branch/Tag:
  • Rust Version: rustc 1.94.1 (e408947bf 2026-03-25) (Homebrew)
  • Rust channel: release
  • Build Time: 2026-04-18 11:10:42 +00:00

Relevant Shell Configuration

bash
# ---------------------------------------------------------------------------
# zsh configuration. PATH and other env vars are set in ~/.zshenv.
# ---------------------------------------------------------------------------

# History
HISTFILE="$HOME/.zsh_history"
HISTSIZE=50000
SAVEHIST=50000
setopt HIST_IGNORE_ALL_DUPS HIST_FIND_NO_DUPS HIST_EXPIRE_DUPS_FIRST HIST_SAVE_NO_DUPS
setopt SHARE_HISTORY INC_APPEND_HISTORY EXTENDED_HISTORY

# Completion: case-insensitive, hyphen-insensitive, colorized.
autoload -Uz compinit
compinit
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' menu select
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"

# Editor
export EDITOR='nano'
export VISUAL='code --wait'
export LANG=en_US.UTF-8

# Aliases
<snip>

# fzf
eval "$(fzf --zsh)"
export FZF_DEFAULT_COMMAND="fd --hidden --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type=d --hidden --strip-cwd-prefix --exclude .git"
_fzf_compgen_path() { fd --hidden --exclude .git . "$1"; }
_fzf_compgen_dir()  { fd --type=d --hidden --exclude .git . "$1"; }

# zsh plugins (installed via Homebrew)
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /opt/homebrew/share/zsh-history-substring-search/zsh-history-substring-search.zsh

# Bind Up/Down to substring history search (type "git" then ↑ to walk past git commands)
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down

# Word movement and editing
bindkey '^[[1;3D' backward-word    # Alt+Left
bindkey '^[[1;3C' forward-word     # Alt+Right
bindkey '^[^?'    backward-kill-word  # Alt+Backspace
bindkey '^U'      backward-kill-line  # Ctrl+U (kill to start of line)

# iTerm2 shell integration
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

# Custom functions
function myprs {
  GH_PAGER="" gh search prs --state open --author @me --limit 200 --json title,url --template '{{range .}}- [{{.title}}]({{.url}}){{"\n"}}{{end}}'
}

# atuin (history sync). Must come before plugins that bind ^R if you want atuin to win.
. "$HOME/.atuin/bin/env"
eval "$(atuin init zsh)"

# Starship prompt. Customize via ~/.config/starship.toml.
eval "$(starship init zsh)"

# Starship undercount workaround for emoji.
__fix_tw() { [[ "$PWD" == "$HOME" ]] && __STW=$(( COLUMNS - 2 )) || __STW=$COLUMNS; }
precmd_functions+=(__fix_tw)
PROMPT="${PROMPT//\$COLUMNS/\$__STW}"

# Syntax highlighting must be sourced AFTER all other widget-modifying plugins.
source /opt/homebrew/opt/zsh-fast-syntax-highlighting/share/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh

# zoxide must be initialized last.
export _ZO_DOCTOR=0
eval "$(zoxide init zsh --cmd cd)"

Starship Configuration

toml
# Starship config replicating p10k style.
# Use ANSI palette indices from p10k.
# Line 1: segments + fill dots + time. Line 2: character only.

format = """
[](fg:7)\
[ ](bg:7 fg:232)\
[](bg:4 fg:7)\
$directory\
[](bg:3 fg:4)\
$git_branch\
$git_status\
[](bg:none fg:3)\
$fill\
$cmd_duration\
[](fg:7)\
$time
$character"""

add_newline = true

[fill]
symbol = "·"
style = "fg:240"

[character]
success_symbol = "[❯](bold green)"
error_symbol = "[❯](bold red)"
vimcmd_symbol = "[❮](bold green)"

[directory]
style = "bg:4 fg:254 bold"
truncation_length = 0
truncate_to_repo = false
truncation_symbol = ""
read_only = " "
home_symbol = "‍"
format = "[ $path ]($style)[$read_only]($read_only_style)"

[directory.substitutions]
"‍/" = "~/"

[git_branch]
symbol = " "
style = "bg:3 fg:232"
format = "[ $symbol$branch ]($style)"

[git_status]
style = "bg:3 fg:232 bold"
format = "[$ahead_behind$staged$modified$untracked$renamed$deleted$conflicted$stashed ]($style)"
ahead = "⇡${count} "
behind = "⇣${count} "
diverged = "⇡${ahead_count}⇣${behind_count} "
staged = "+${count} "
modified = "!${count} "
untracked = "?${count} "
renamed = "»${count} "
deleted = "✘${count} "
conflicted = "~${count} "
stashed = "*${count} "

[cmd_duration]
min_time = 2_000
style = "bold yellow"
format = "[ took $duration ]($style)"

[time]
disabled = false
style = "bg:7 fg:0"
format = "[ $time ]($style)"
time_format = "%H:%M:%S"

[dotnet]
style = "bold 105"
format = " [$symbol($version )]($style)"
heuristic = true

[aws]
disabled = true
[azure]
disabled = true
[gcloud]
disabled = true
[kubernetes]
disabled = true
[nodejs]
disabled = true
[python]
disabled = true
[ruby]
disabled = true
[rust]
disabled = true
[golang]
disabled = true
[java]
disabled = true
[package]
disabled = true
[hostname]
disabled = true
[username]
disabled = true
[terraform]
disabled = true