Last active
January 27, 2026 18:06
-
-
Save gparuthi/b69aaaafac68ccb774ab7506bb03d866 to your computer and use it in GitHub Desktop.
Show p10k style alias expansion with starship
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================================================= | |
| # 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