In bash, if you set $EDITOR to your favorite text editor, you can send the current line to $EDITOR with ctrl-x ctrl-e. After editing the command you can save and exit for the command to execute.
Just type "fc"
With previous commands, one can also specify a particular editor instead of default $EDITOR
For example, to edit the previous command with ed when EDITOR=vi
fc -e ed
A quick way to make shell scripts from command line history in vi mode (where 15th entry in history is the desired command line): fc 15
w1.sh
%d
wqGot it from here https://twitter.com/arjie/status/1575201117595926530?s=46&t=...
bind '\C-e: edit-and-execute-command'