Chris Lamb: Top 10 interactive shell anti-patterns
In general, if you’re doing a repetitive task by hitting lots of keys, you’re doing it wrong. Not only are you wasting time, you’re wearing out your keyboard and damaging your wrists and fingers.
Here are the ten most common anti-patterns (actually amelioration patterns) that I commonly see in other people’s line editing:
- Repeating a command by retyping it
Press Ctrl-p and Enter, or “!!“. Zsh users get “r” as well. You can even get the command n times before, use “!-1“. Using the arrow keys is obviously flawed - find out how to unmap them in your shell. - Manually changing back to your previous directory
Give “cd -” a whirl. - Typing a long command (or sequence of commands) excessively often
Obviously wrong, but I see it so often it’s worth mentioning. Try using an alias and put it in your shell’s startup file. If the command is parameterised, you could construct a simple function. If you are writing software, look into the build systems available for your language - the basics of GNU Make can be mastered within 20 minutes or so, and have many other benefits too. - Opening another shell when the current process blocks
(e.g. You realise the command you started is going to take a lot longer than you thought) Pause the current process with Ctrl+z and then put the job in the background with bg. fg will bring it to the foreground again. Fewer shells mean you stay focused on what you were trying to achieve. - Searching history by grep’ing ~/.bash_history, or Up Up Up … etc.
Use CTRL+r (or “/” in vi-mode) for search-as-you type. You can immediately run the command by pressing Enter. - Adding a prefix to a command with Up Home $command Space
(e.g. You ran a command that really needed sudo). Try: $prefix !! - Changing a command with Home Right Right Right Right … BkSpace BkSpace … etc.
(e.g you accidentally ran chown instead of chmod) Try: $new_command !* - Retyping significant parts of the previous line
Try using !$ to get the right-most argument on the previous line (you can also use !:2 to get the second argument, etc.):$ command arg1 /long/path/to/file $ command2 arg2 /long/path/to/file $ command3 arg1 arg3 /long/path/to/file$ command arg1 /long/path/to/file $ command2 arg2 !$ $ command3 arg1 arg3 !$ - Using Home/End to move to the beginning/end of the line
This is how you completely ruin your wrists. Use Ctrl+a and Ctrl+e. - Hitting tens of keys to make a substitition
(e.g. you made a trivial mistake in the middle of your previous command). Use ^foo^bar. If you forget the other nine, try this one - stop punishing yourself for making mistakes!
Now that through black magic, voodoo, and a working network driver I have
Avahi working on my NAS and UPnP working on my SoundBridge, I can
get back to the task of learning a bit about
Intellectually, I mean. According to
OK, changes in dpkg-dev 1.14.7 have forced my hand a little and
Last Saturday we organised the
Logically, Argentina won against Scotland tonight after a.....quite boring
match.
Scotland, as expected for them unfortunately, wasn't able to put speed in
their game, the only way to beat Argentina this year. Even with that poor
game (Lamont, their rear player, was a disaster), Scotland finished quite close to ARG, who didn't play brilliantly with
many approximations (Hernandez being a bit arrogant, trying to kick too many
drop goals) and a bit of luck.
So, nothing really impressive in that match. Does that mean that South
Africa has better chances to qualify for the final: who knows? Argentina can
be unpredictable...but it seems they are a little bit burned out (they don't
really have 30 top players and some of their key players appear tired).
The semi-finals will feature France-England (about 50-50 chances from what
we saw up to now) and South Africa-Argentina (60-40, in my opinion). Next
week-end, Stade de France.
Somewhat unbelievably (to me at least) there is still wireless in my mother’s backyard and it has only gotten better and stronger. But let’s face it, writing in garden lounge chairs among the frogs, birds, sun, rain and wind are sub-optimum for thinking and writing, so I am always looking for good and, most especially, gratis wireless.
I was pretty psyched to find a new cafe,
Thanks to the people who commented on my
As I have been such a good girl recently, I deserved some prize. I’ve always been in love with tiny light lappys, so I got myself one from ebay. It’s a 10″ 800 MHz Sony Vaio that weights slightly above 1 Kg, which means that I’d be able to carry it to anywhere I want. Debian has installed smoothly on it, even though I’ve had some problems due to the lack of CD/DVD and floppy drives, and my inability to make Debian Installer start from an USB pen. Most of it seems to be working properly right now, only small configuration issues are still pending. I’m really happy
Via
For some odd reason, the trusted Perl module