ctrl-x-e without executing command immediately
I cannot tell if you will call it simple. This is a quick and dirty proof of concept:
# in Bash
_edit_wo_executing() {
local editor="${EDITOR:-nano}"
tmpf="$(mktemp)"
printf '%s\n' "$READLINE_LINE" > "$tmpf"
"$editor" "$tmpf"
READLINE_LINE="$(<"$tmpf")"
READLINE_POINT="${#READLINE_LINE}"
rm "$tmpf"
}
bind -x '"\C-x\C-e":_edit_wo_executing'
Now Ctrl xe should do what you want.
Notes:
-
I used only basic logic to set
editor
; adjust it to your needs. -
READLINE_POINT="${#READLINE_LINE}"
should place the cursor at the very end. Bash 5 wants the length in characters and the above code works; but Bash 4 wants bytes. To handle non-ASCII text in Bash 4 useREADLINE_POINT="$(printf '%s' "$READLINE_LINE" | wc -c)"
(I learned from this answer).