3 ms·
> For the same reason I'll often Ctrl+C and start again instead of trying to backspace and correct. Try ctrl-x ctrl-e to edit the command in your choice of edi
by mkl 2mo ago
> For the same reason I'll often Ctrl+C and start again instead of trying to backspace and correct.
Try ctrl-x ctrl-e to edit the command in your choice of editor ($EDITOR).
Editing commands is not hard with a few keys. At least learn alt-b and alt-f to go a word back or forward. Often ctrl-left and ctrl-right will do the same thing easier (depends on your terminal). Ctrl-w deletes back to the previous space, alt-backspace and alt-d delete the previous and next word respectively. There are many more keys in the manual, but those cover most things.
- _doctor_love 2mo agoGreat advice. On the Mac, make sure to set up Alt/Option as "meta key".
- userbinator 2mo agoSo instead of just retyping the command (much less than 1s), I have to remember to open the editor, and then think of how to edit it, and then execute those steps? Hell no. At that point I'll have long lost my original train of thought. The original command, and at least the subsequent one, are already in my mind and can be output immediately. Any deviations from that plan are going to be much slower. ctrl-x ctrl-e Just thinking about that almost makes my fingers hurt. A chorded sequence of two keys, same side of the keyboard, nearly in a vertical line on the top and bottom row, is basically the slowest and most awkward possible combination to type.
- db48x 2mo agoOnly because you’re typing it incorrectly. Use both hands. One presses the modifier, the other types the letter. That's why you have modifiers on both sides! C-x means to use your right hand to hold down control, while using your left to type the x.
- userbinator 2mo agoX E is still a terribly slow sequence to type.
- db48x 2mo agoNot that slow; maybe you just need practice. Alternatively just bind it to whatever key you prefer by editing your `~/.inputrc`. Add a line like this to it: "\C-e": edit-and-execute-command and you will only have to type control-e to edit the current command. Don’t forget that `bind -P` will list all the current key bindings. It’s rarer, but you might also have some keys bound not to internal commands but to strings or external commands. You can list those with `bind -S` and `bind -X` respectively. Also, don’t forget that lots of other things use readline too. You can use the same key bindings in many interactive environments, such as your favorite programming language’s REPL, your SQL prompt, calculators like bc or units, your favorite debugger, etc. If you come across a command environment that doesn’t use readline directly you can run it with rlwrap to remedy that. The more you use them the more places you will find where they are useful, and the more utility you will get out of them.
- vrighter 2mo agothis is overkill and way slower for most short commands. And you still need to scroll to wherever you need to edit. doesn't save anything, really.
- Ferret7446 2mo agoIf you use vi or emacs you can edit directly using the bash/readline editor. (Or if you use emacs, then you already have a full editor in your shell)