Skip to content

Commit

Permalink
feat(expansion): support expand-on-enter (has suggestions bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed Jan 12, 2020
1 parent e5b4696 commit f8356be
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions abbr
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ function abbr_expand() {
}
}

function abbr_expand_accept() {
local lbuffer=$LBUFFER
local rbuffer=$RBUFFER

RBUFFER=$rbuffer # clear suggestions for the abbreviation
abbr_expand
RBUFFER=$rbuffer # clear suggestions for the expanded command

# if [[ $lbuffer == $LBUFFER ]]; then
zle accept-line
# fi
}

function abbr_expand_space() {
abbr_expand
LBUFFER="$LBUFFER "
Expand All @@ -84,6 +97,10 @@ bindkey "^ " magic-space
bindkey -M isearch "^ " abbr_expand_space
bindkey -M isearch " " magic-space

# return expands and accepts abbreviations
# NOTE: will clear anything after the cursor!!
zle -N abbr_expand_accept
bindkey "^M" abbr_expand_accept


function abbr() {
Expand Down

0 comments on commit f8356be

Please sign in to comment.