Skip to content

Instantly share code, notes, and snippets.

@gparuthi
Last active January 27, 2026 18:06
Show Gist options
  • Select an option

  • Save gparuthi/b69aaaafac68ccb774ab7506bb03d866 to your computer and use it in GitHub Desktop.

Select an option

Save gparuthi/b69aaaafac68ccb774ab7506bb03d866 to your computer and use it in GitHub Desktop.
Show p10k style alias expansion with starship
# =============================================================================
# Alias Expansion Display (like p10k)
# Shows alias expansion below prompt using zle -M (no reset-prompt needed)
# =============================================================================
typeset -g _ALIAS_LAST_WORD=""
_alias_check() {
local first="${BUFFER%% *}"
[[ "$first" == "$_ALIAS_LAST_WORD" ]] && return
_ALIAS_LAST_WORD="$first"
local exp="${aliases[$first]}"
if [[ -n "$exp" ]]; then
zle -M "→ $exp"
else
zle -M ""
fi
}
zle -N zle-line-pre-redraw _alias_check
_alias_accept() {
zle -M ""
_ALIAS_LAST_WORD=""
zle .accept-line
}
zle -N accept-line _alias_accept
_alias_init() {
_ALIAS_LAST_WORD=""
}
zle -N zle-line-init _alias_init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment