momo-lab / zsh-abbrev-alias

This zsh plugin provides functionality similar to Vim's abbreviation expansion.
MIT License
119 stars 14 forks source link

How to *not* choose the abbreviation #11

Open c0deaddict opened 4 years ago

c0deaddict commented 4 years ago

I like the idea of this plugin a lot and want to move change all my aliases to this. However, i'm stuck with one use case. Say i have an abbrev defined like this:

abbrev-alias -g gs="git status"

Typing gs<SPACE> or gs<ENTER> will expand the abbreviation, wonderful. But what if I want to run the command gs (ghostscript)? Is there a binding that will cancel the attempt to abbreviate?

momo-lab commented 4 years ago

try to <C-x><SPACE> or <C-x><ENTER>

c0deaddict commented 4 years ago

That works! Thank you :)

jetm commented 3 years ago

@momo-lab <C-x><SPACE> or <C-x><ENTER> doesn't work for me. Is there another alternative to avoid expanding an abbreviation?

momo-lab commented 3 years ago

Please tell me the execution result of the bindkey command. It may be overwriting the settings created by this plugin.

# bindkey | grep "\^X" 
"^X^B" vi-match-bracket
"^X^F" vi-find-next-char
"^X^J" vi-join
"^X^K" kill-buffer
"^X^M" accept-line    # <- Need this line
"^X^N" infer-next-history
"^X^O" overwrite-mode
"^X^R" _read_comp
"^X^U" undo
"^X^V" vi-cmd-mode
"^X^X" exchange-point-and-mark
"^X " __abbrev_alias::no_magic_abbrev_expand    # <- Need this line
"^X*" expand-word
"^X=" what-cursor-position
"^X?" _complete_debug
"^XC" _correct_filename
"^XG" list-expand
"^Xa" _expand_alias
"^Xc" _correct_word
"^Xd" _list_expansions
"^Xe" _expand_word
"^Xg" list-expand
"^Xh" _complete_help
"^Xm" _most_recent_file
"^Xn" _next_tags
"^Xr" history-incremental-search-backward
"^Xs" history-incremental-search-forward
"^Xt" _complete_tag
"^Xu" undo
"^X~" _bash_list-choices
jetm commented 3 years ago

It seems I have the two lines, but I still unable to avoid the expand

$ bindkey | grep "\^X"
"^X^M" accept-line
"^X^R" _read_comp
"^X^S" prepend-sudo
"^X " __abbrev_alias::no_magic_abbrev_expand
"^X." fzf-tab-debug
"^X?" _complete_debug
"^XC" _correct_filename
"^Xa" _expand_alias
"^Xc" _correct_word
"^Xd" _list_expansions
"^Xe" _expand_word
"^Xh" _complete_help
"^Xm" _most_recent_file
"^Xn" _next_tags
"^Xt" _complete_tag
"^X~" _bash_list-choices
momo-lab commented 3 years ago

There seems to be no problem with the definition of bindkey.

Since abbrev-alias also registers alias gs ='git status' at the same time, the command equivalent to git status is executed even if gs<C-x><Enter>. This technique only suppresses prompt expanding.

If you want to suppress the registration of alias, there are currently the following workarounds.

abbrev-alias gs ='git status'
unalias gs
momo-lab commented 3 years ago

If <C-x><Enter> key expands to the prompt, I can't think of a cause. Sorry...

jetm commented 3 years ago

The problem with unalias gs is gs expand to git status when a press Enter or Space