-
ProposalI'd love some mechanism by which you can "preview" what an abbreviation would expand to on This would be not only be a flashy and oh-so-zsh feature, but it would also reduce cognitive load by helping to disambiguate multiple similar aliases. Worked exampleImagine I have the following aliases: abbr -g "git c"="git commit -m \"%\""
abbr -g "git co"="git checkout"If I type This always makes me pause and think first, slowing me down. So some indication/hint that Possible implementationA nice way to do this might be to leverage Here's a minimal example of how this might work: function preview_expansion {
if [[ <$LBUFFER ends with an abbreviation> ]]; then
local expanded_command=$(<fetch expansion from abbreviations file>)
zle -M "${expanded_command}"
}Then just register this hook as a zsh widget on startup: zle -N zle-line-pre-redraw preview_expansion |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
|
Previewing is an interesting idea, thanks for sharing! This might be a better fit for a standalone zsh-abbr extension. Currently, zsh-abbr doesn't run anything until triggered by one of the bound keys (spacebar, for example). Checking for previews would have to be done on every keystroke. Even before wondering whether zsh-abbr should get into TUI, I'm not sure it should get into running on every input. If anyone's inspired to try to author a zsh-abbr previews plugin, I could be up for answering questions or reviewing code. For your specific zsh-autosuggestions pain point, there are two quick solutions.
|
Beta Was this translation helpful? Give feedback.
-
I have just created this simple extension which is working well for me currently: @olets Please let me know if you feel it could be improved or more tightly integrated. Otherwise, if you think this extension would be of wider interest, please consider mentioning it in the README. Thanks! |
Beta Was this translation helpful? Give feedback.
I have just created this simple extension which is working well for me currently:
@olets Please let me know if you feel it could be improved or more tightly integrated.
Otherwise, if you think this extension would be of wider interest, please consider mentioning it in the README.
Thanks!