If you're using bash or zsh and you don't know the ^X^E shortcut, learn it now.
First, ensure you have a valid `EDITOR` environment variable set to your favourite editor (like vim or emacs).
Second, enter some command, but don't hit enter.
Third, use Ctrl+X Ctrl+E and learn that you can use your editor to modify the command before running it in the shell.
This is pretty helpful if you're trying to edit a long command line.
@tomasino @minego for ZSH, you just need to set it up in your ~/.zshrc http://nuclearsquid.com/writings/edit-long-commands/ @antekone thanks for this awesome tip!
@danipozo Not every day. But sometimes it is useful.
Last time it was helpful to me was when trying to figure out a problem with compilation of some software. I was copying/pasting long command lines that were autogenerated by CMake (several lines long).
In order to find the problem I needed to modify those command lines and see if my modification will help to get the compilation working. So I've used ^X^E and vim's substitution command (:%s///) to perform the modification.
@antekone Didn't know about that and found a tip to use vim-style bindings instead, thank you ❤
@antekone Also note that, if the $EDITOR exits with a non-zero exit status, the shell won't run the command. In vim, that's `:cq`. In ed(`) (without GNU's "--loose-exit-status" parameter), any editing error will produce a non-zero exit status, meaning the command won't run. Edit with care. For all editors, if you want to abort, you can delete the entire command, save, and quit.