zsh:keys:cmd-on-enter: Check PREBUFFER as well

When typing a multi-line input (e.g. `echo foo\<CR>`) BUFFER can be
empty, even though the entire input is not.

Fix this by checking if PREBUFFER and BUFFER are empty.
This commit is contained in:
2023-01-17 00:33:19 +01:00
parent 993bd5a16e
commit a7b975ae71

View File

@@ -177,7 +177,7 @@ bindkey '^[[46;5u' default_dot
CMDS_ON_ENTER=(ll gs)
REQUIREMENTS_CMDS_ON_ENTER=(true "git rev-parse")
function cmd-on-enter {
if [[ -z $BUFFER ]]; then
if [[ -z "${PREBUFFER}${BUFFER}" ]]; then
# Overwrite BUFFER and default to ll
BUFFER=" ${CMDS_ON_ENTER[${cmd_on_enter_idx:=1}]}"