Commands with lots of arguments sometimes use slash escaped newlines to make them easier to read on the web. Here is a silly example

echo -n \
"hello" \

I'm not sure how to paste and edit this "properly"

Pasted into bash you get

$ echo -n \
> "hello" \
> "world"

Now if I navigate with the back arrow key on OSX, I can only edit the line with > "world", not the first two lines. Usually I have to paste into a temp file to fix up a command.

Is there a better way to perform this paste which allows editing any line? bash setting which makes this work in a nicer way?

  • You need an editor which displays CR and LF and you will see that this is not possible since there is an <kbd>ENTER</kbd> in the paste. Put it in one line without CRLF and you won't have the problem. – h0ch5tr4355 Nov 2 '15 at 7:36

When you have such a command on several lines you can, if you're using bash in emacs mode (usually the default one) ctrl+x ctrl+e it will open your favorite editor, as specified in your EDITOR variable.

Or you can type fc, this will open the editor on the last command you've typed, then you can edit it as you want, then feel free to quit, and it will be executed.

| improve this answer | |
  • the editor shortcut is nifty. type fc? – pseudo647 Nov 2 '15 at 10:30
  • It's opening an editor on the last command in your bash history, it's a bash built-in command – Pierre-Alain TORET Nov 2 '15 at 10:37
  • It seems nice for some quick prototyping, but as soon as you need to fix/edit your last command, all the formatting is gone so it's a complete mess in the end. – devoured elysium Jul 1 '19 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.