When learning to love the command line, nothing made a bigger difference to me than when I discovered I could edit commands with out pressing and holding the arrow keys. That was just slow and awkward. There is a better way. Really you only need two or three little tricks and you will be in a whole new world of productivity.
If you can only learn one thing, learn these two keyboard shortcuts:
Jump to the beginningPressing
Mnemonic: Control-Awesome I can move back to the beginning with out holding the arrow key.
Also I find I remember this because the A key is the furthest left key on the home row.
Jump to the endPressing
Now, take a few minutes to go give those a try. I’ll wait.
Want some more? Rad. But a little caution if you are just learning these things: just pick a couple and find ways to use them until they are second nature. Practice. If you think you are ready for more, here you go. I think these are the next most useful:
Delete Back a WordPressing
Mnemonic: Control-Why did I type that Word
Delete to the EndPressing
Mnemonic: Control-Kill to the end of the line
Delete to the BeginningPressing
Mnemonic: Control-Uhh that wasn't right
I think these are the most critical shortcuts to learn, and have made life on the command line damn nice.
Really I should end this post here, but am somehow compelled to mention this thing called input modes.
There are two input modes that a command line will use: vi or emacs.
The examples above assume you are using emacs mode for your shell. This is the default for bash and most other shells. If you are having problems with them you may need to set the input mode. In bash you can simply run
set -o emacs
I can hear you asking “But wait, you are a vim guy, why do you use emacs mode for your shell?”
Well, it wasn’t an easy choice. I thought I would like vi mode on the command line. And I tried to use it. I wanted to want to. But in the end it was just never felt right.
Control-X Control-Eor running
The only thing you should do is pick some tools and learn them. Don’t worry about what some random blog article says. Don’t worry about those kids on irc demanding you use zsh. Don’t worry about editors – learn something. It will all translate in some way, won’t be wasted effort. Most important thing you can do as a developer is train how to use your tools.
What command line tricks do you use to make your day happier?blog comments powered by Disqus