Assuming you're using the bash shell, the following can be helpful when composing long command lines.
Start typing on the command line and then type Ctrl-x Ctrl-e, it should drop you into your system's default editor (hopefully Vim) and allow you to edit the command line from there. Once finished, save the command line, and bash will run the command.
Subscribe to:
Post Comments (Atom)
10 comments:
If you are using bash and you like vim, you should likely consider just using vi mode. Use "set -o vi" and then you can press escape and start editing the line in place using vi commands.
Also, once you have 'set -o vi', you can hit the 'v' key in command mode to edit the command line in $EDITOR.
Like the first poster said, use 'set -o vi' ... it also works in zsh.
Oooooh!
Thank you!
> Also, once you have 'set -o vi', you can hit the 'v'
Hmm interesting
9-year HC Vim user here, I'll RSS your stuff!
;)
... and on the 'set -o vi' front, if you find that you do like using vi editing mode (and what's not to love about it :), add 'set editing-mode vi' to your .inputrc, and vi mode will work in any readline based client, eg psql, irb, ...
Question: is there a way to get bash to NOT run the command when the editor exits?
David, just clear the buffer and there will be no command to run when you are returned to the command line.
@David, to leave vim without running the command, type :q!<Enter>; to run the command, type ZZ.
@David: to leave without running the command, do ":cq". This exits vim with an error code so that bash ignores it.
Post a Comment