Last active
December 8, 2016 10:51
-
-
Save crater2150/2dce1f14bd5d5233cdad965ce0a2f6f7 to your computer and use it in GitHub Desktop.
accept and infer for people forgetting to use it before pressing enter
This file contains 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
# if there is currently something typed, accept-and-infer-next-history like usual | |
# if the input line is empty, recall the last command and infer based on that | |
# needs deduplication of history disabled! (unsetopt HIST_SAVE_NO_DUPS HIST_IGNORE_ALL_DUPS) | |
local function accept-or-recall-then-infer-history() { | |
if [[ -z $PREBUFFER$BUFFER ]]; then | |
zle up-line-or-history | |
zle infer-next-history | |
else | |
zle accept-and-infer-next-history -- "$@" | |
fi | |
} | |
zle -N accept-or-recall-and-infer-history | |
bindkey "\e^M" accept-or-recall-and-infer-history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment