Seven Bash Tips

Carrying on with yesterday’s theme of Bash hackery, I present to you Ian Miell’s Seven God-Like Bash History Shortcuts You Will Actually Use. If you’re anything like me, you read one of these articles and think, “Wow! That’s really neat. I’m gonna start doing that too.” Of course, you immediately forget the shortcuts and keep doing things the way you always have. Even Miell, who wrote the book on this stuff, admits that he mostly forgets the shortcuts. He says, however, that these are shortcuts that he uses everyday and that he’s actually learned them.

You may or may not “actually use” Miell’s tips but they are handy and if you work on the command line a lot, they are definitely worth knowing. Many of the tips involve quickly changing one of the words on the last command or, perhaps, switching their order. That’s useful when you misenter one of the arguments in a long command line. Rather than retyping the whole thing, you can use one of the shortcuts to minimize the amount of retyping you need to do. There are other shortcuts for doing things like a search and replace. Take a look at Miell’s post to see what you can do.

Of course, you can always bring up the last command and use the editing capabilities of Readline that I wrote about yesterday to accomplish the same things so you might not think it’s worthwhile learning the shortcuts. If you strive to absolutely minimize the number of keystrokes you type, Miell’s shortcuts will put you a bit ahead but only a bit. My own reaction is “Wow! That’s really neat. I’m gonna start doing that too.” But I probably won’t.

Posted in General | Tagged , | Leave a comment

Emacs For a Single Line of Text

What if you could use Emacs to edit the command line? Wouldn’t that be great? Well, of course, you can. Not only can but almost certainly do. I’m not talking about invoking Emacs from Bash with Ctrl+x Ctrl+e; I’m talking about readline.
If you have any experience at all with the Bash shell you probably know that you can move to the beginning of the command line with Ctrl+a and to the end with Ctrl+e just like in Emacs. That’s the Readline library in action. It turns out, though, that the library is much richer than just those two commands.

If you look at the Readline man page or library manual, you’ll see that it actually supports an astounding number of Emacs commands, mostly bound to the familiar key sequences. You can transpose characters or words, move or delete characters or words, mark and operate on regions, and even record keyboard macros. And just like in Emacs, you can bind your own key sequences to the commands. You can even configure it to use Vim key sequences.

If you’d like to find out more about Readline and discover some of the things it can do, Sinclair Target over at Two-Bit History has a very nice post on the things you didn’t know about GNU readline. Go read it right now. You’ll be glad you did.

I’ve been using Bash for decades and have always made use of the Ctrl+a / Ctrl+e trick and a couple of the other movements but I didn’t realize how much of the Emacs (or Vim) command set is implemented. It truly is, as Target says, Emacs for a single line of text.

Posted in General | Tagged , , | Leave a comment

Scroll All Mode

From Wilfred Hughes’ Emacs Command of the Day Twitter feed, we have this useful tip:

I had no idea this existed. It’s probably not something you’re going to use very often but it’s easy to imagine some use cases for it.

Posted in General | Tagged | Leave a comment

Google on Tracking

If you’re like me, you’re apt to suspect that anything Google has to say about adtech and tracking is likely to be self-serving nonsense but when they make the claim that blocking cookies is bad for privacy you’d be excused for not bothering to read further. On the other hand, it does have a powerful pull because you’re curious as to what possible argument they could make.

Not much of an argument it turns out. Over at Freedom to Tinker, Jonathan Mayer and Arvind Narayanan take a steely-eyed look at Google’s latest pronouncement on cookies and privacy and give it a thorough fisking. Their post, Deconstructing Google’s excuses on tracking protection, refutes Google’s claims point by point.

They don’t spend much time on “blocking cookies is bad for privacy” because Google’s argument—it would only lead to worse behavior such as fingerprinting—is so weak that it doesn’t need much debunking. As Mayer and Narayanan point out, that would be like the police saying that they don’t want to crack down on pickpockets because the criminals would turn to worse behaviors like mugging.

If you’ve read Google’s original post, you owe it to yourself to read Mayer’s and Narayanan’s rebuttal. They do a wonderful job of demolishing Google’s arguments and demonstrating their self-serving nature. Their most telling point is a quote from Shoshana Zuboff’s The Age of Surveillance Capitalism in which Zuboff says asking Google to give up violating our privacy is futile because doing so represents an existential threat to their business. It’s why I’ve long felt that we’ll never talk Google and the other adtech practitioners into behaving: you’d be asking for their suicide. Short of something like a rigorously enforced European style GDRP, they’ll never change. Maybe not even then.

Posted in General | Tagged | Leave a comment

Paul Ford on Uses This

Ever since I stumbled upon it back in 2011, I’ve been a big fan of Uses This (nee The Setup), which features short interviews with tech or creative people. Each interview is the same in that they ask the identical four questions:

  1. Who are you and what do you do?
  2. What hardware are you using?
  3. What software are you using?
  4. What would be your dream setup?

It’s in my feed so I never miss an episode. Some of the interviews are with silly people and therefore themselves silly but most are interesting and I very often learn something or get an idea that I can use in my own work.

The most recent interview is with Paul Ford, the CEO of Postlight, whom I’ve written about before. Ford is a thoughtful guy and a good writer so it’s always interesting to read him.

His interview is, I think, the longest I’ve ever seen on Uses This. He gives long detailed answers to the questions as well as explanations of why he made the choices he did. He is, of course, an Emacs/Org user and says that he spends 80 per cent of his life in Emacs.

He’s a CEO but still spends a lot of time on technical issues so he uses and builds a lot of tools. When he’s not in Emacs, he likes to work on the command line where he uses the Z shell and tmux. If you’re looking for some thoughts on a workflow that’s not targeted specifically at someone in engineering, take a look at Ford’s interview. It’s enjoyable and you may get some ideas.

Posted in General | Tagged , | Leave a comment

Emacs 26.3-RC1

I didn’t even know there were plans for an Emacs 26.3 but there are and the first release candidate is available. If you don’t want to live on the edge enough to be running the development version of Emacs 27.1, perhaps you’d enjoy the safer route of helping to test Emacs 26.3 by trying out the release candidate.

Posted in General | Tagged | Leave a comment

A Real World Use Case of Occur

Protesilaos Stavrou has posted a very nice video on using editable occur to solve a real life editing problem. The basic strategy is to use occur to locate all the occurrences of the problem to be fixed, type e in the occur buffer to make it editable, and then use a keyboard macro or other means of your choice to make your changes. The changes are, of course, reflected in the original buffer and are written to disk when you exit the edit mode of occur.

This is very reminiscent of abo-abo’s refactoring workflow that I wrote about back in 2015. The idea is basically the same: use some sort of grep-like operation to get all the relevant lines in a buffer, make the buffer editable, make your changes, and write those changes back to the file(s) they occurred in.

If you like this sort of thing, abo-abo has a video demonstrating a workflow similar to Stavrou’s. It is, I think, hard to find better examples of the awesomeness of Emacs’ editing capabilities than these videos by Stavrou and abo-abo.

As a final note, I was pleased to discover that you can make an occur buffer editable simply by pressing e. I always did it by toggling the read-only state with Ctrl+x Ctrl+q. I’m not sure why I didn’t know about using e since I use the facility all the time but then I’m always learning something new about Emacs that you’d think I would already know.

Posted in General | Tagged | Leave a comment

Apple Gets Serious About Web Tracking

In some very welcome news, Apple has announced that it will be implementing and enforcing a new anti-tracking policy in Safari. The new WebKit Tracking Prevention Policy lays out what types of tracking they will attempt to prevent and states explicitly that any attempts to bypass their anti-tracking protections will be treated just like any other exploitation of a security vulnerability. They also state that there will be no exceptions no matter how worthy the organization seeking one or how benign their intentions.

The types of tracking that they are seeking to prevent are all cross-site tracking and all covert tracking. Covert tracking is basically tracking that’s hidden from the user. It includes such things as fingerprinting and convert stateful tracking that surreptitiously stores tracking information on the user’s computer using facilities not intended for that purpose.

In their article about the announcement, The Next Web speculates that the move will force other browsers, such as Chrome, to take similar actions. I’m a little skeptical about that since the point of Chrome is to make it easier for Google to track user behavior, a point amply demonstrated by their recent decision to log you into Google under the covers when you’re logged into any Google account. Of course, some browsers, like Mozilla, have already taken similar steps and the WebKit announcement specifically gives them a shout out for being the inspiration for their own steps.

I’m under no illusion that Apple’s and Mozilla’s actions will end the scourge of adtech but I do welcome anything that makes it harder for them to spy on us.

Posted in General | Tagged | Leave a comment

The Emacs Problem Revisited

Saturday, I wrote about Slava Akhmechet’s The Nature of Lisp, which discussed why Lisp is such a powerful language. A day or two afterwards, I serendipitously came across a tweet pointing to Steve Yegge’s old post, The Emacs Problem. That’s a really great post and if you haven’t read it yet, you definitely should. I’ve written about it a number of times including here and the series of posts starting with this one on treating data as code. Those last posts are among my favorites in the Irreal canon. Among other things they demonstrate the power of Emacs viewed as a kind of Lisp Machine.

Yegge’s and Akhmechet’s posts are complementary. They both start by considering XML as the solution for a problem and show that

  1. Expressing the data structure as an S-expression makes it less verbose and much easier to read.
  2. Once expressed as an S-expression, the data can be thought of as code and made to perform useful transformations on itself.

A lot of this boils down to Lisp being really good at text manipulation or, as Yegge puts it, the only language that’s really good at it—at least for non-trivial data. Yegge’s post starts by considering the notion that Lisp is terrible for text manipulation, that Emacs proves that, and that Emacs should be rewritten in some other language such as Ruby. By the end of his post, that notion is a smoldering heap of ashes.

Akhmechet, on the other hand, doesn’t consider Emacs at all. He just lays out the case that Lisp, although hard to grasp at first, is a very powerful language and very often the right solution. Emacs is, I submit, proof of that assertion.

Posted in General | Tagged | Leave a comment

The Truth About PowerPoint

But then we already knew that.

Posted in General | Tagged | Leave a comment