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!
Intellectually, I mean. According to 
OK, changes in dpkg-dev 1.14.7 have forced my hand a little and
< eikke> is there any "small" thing which I could be able to do, now?
The C standards committee is apparently preparing to revise the C standard. The 
Back around 1999, I was really interested in getting all of
When using a <limit> in mutt's message index, I always try to hit 'q' to
get back to the index view, but of course there's nothing to quit. The macro
below changes 'l' such that 'q' will unlimit, and a subsequent 'q' will then
quit mutt:
After 6 weeks of teaching and over 2 months in my new apartment, I am making a short escape from NYC to visit my mom and sister in PR. In my Impacts of Technology class, we just finished a week on large-scale and complex technological systems, with a focus on industrial farming. We read a few sections of Micahel Pollan’s fanstastic book, The Ominvore’s Dilemma, which combines the odd qualities of being seductively alluring (thanks to his exquisite writing) and repulsive (thanks to the content, well at least the part on factory animal “farming”). I can’t recommend it enough and look forward to reading the rest, when I find the (magical) time to do so.
Now that I am at the airport, I am struck at how little I know about this place, which is also a large and complex technological system and I bet revealing its technological and cultural innards would provide as fascinating (although not quite as gross) of a story as that of factory animal farming.
There are many questions I would love answered: How exactly is coordination secured and what are the toughest elements to airport coordination? Where are the lines of cooperation and those of competition between airlines? What factors and values go into the design of the airport? (I know that for one thing, in American airports, there rarely seems to be enough electrical jacks; I am now sitting under the telephones, the only place with jacks in terminal 8 at JFK, and the funny thing is that there are a row of 7 unused phones and only one jack and I am sure it would be more useful to have 1 pay phone and a row of 7 jacks, instead). What sorts of airport technologies have put people out of jobs? What technologies have created new job opportunities? What sorts of social hierarchies are there in airports? Like who runs the big show? Is it a CEO? Or is something more like a university provost? What is standardized by the FAA, and what elements are more flexible, and thus different airport to airport? Is there a sense of camaraderie among airport employees, or are loyalties built primarily among employees of one airline or among the classes of workers? Given that unions are quite strong among airport employees and from the top (pilots) down (food workers), what is the political culture of airports/employees like? (I remember once overhearing a group of machinist and ground crew talking about the ugly face of globalization and NAFTA over coffee and I was dumbfounded and pretty psyched too). Are airports one of the few last remaining places in th US that provides for decent job security? Why do so many of the ground crew have such athletic, bulging calves?
The following companies, or people, are using
I just released version 0.23 of
Let's say you're a French person who has EXTENDED_GLOB
on and types HEAD^ all the time, but can't be bothered
to type a backslash before the caret. Personally, I have no
problem typing HEAD\^, but I probably only do that twice
a day.
Here are a few/several/many (depending on how you count) solutions .
They all have their downsides. Finding out their side effects is an
exercise for the reader.
Number one: setopt noextendedglob
Number two: setopt nonomatch
Number three: alias git='noglob git'
Number four: custom ZLE widget: