5

I remember running across this command a while back although I do not remember the command itself. As I remember it, you ran the command, it would create a temp buffer that would then be edited by the default editor (vim) and upon closing the buffer, the command would be executed.

Eg:

$ <buffer edit command>
~ # Write bash temp script
~ for i in *; do
~     echo $i
~ done
$ file1
$ file2
$ file3
$ ...

Does anyone know what this command is? It is like writing a bash script in vim only without saving the file and just running it.

1
  • 3
    Are you thinking of fc, or was it a standalone command? Commented Jul 30, 2018 at 20:13

2 Answers 2

12

You want to bind some key combo to edit-and-execute-command. I use:

bind '"\C-e": edit-and-execute-command'

in my ~/.bashrc. When I hit Ctrl-e, it invokes $EDITOR and lets me edit the command. When I save and quit, it executes the edited command.

2
  • 2
    Thats it, it was not a command but a shortcut thank you. Commented Jul 30, 2018 at 20:18
  • 2
    @Drew FYI, the default key combination for this is C-x C-e (that is, hold Ctrl and then first hit x and then e). Commented Jul 30, 2018 at 23:03
6

If you run set -o vi (or have it in your ~/.bashrc), then pressing v in normal mode (i.e., press Esc and then v) will bring up a buffer as you describe.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.