pipx

I’m not a python person. But some interesting CLI utilities are written in python, including eyeD3 and visidata.

Enter pipx – it creates little (huge?) pip sandboxes for your different utilities, so you don’t have to worry about one breaking if you need to upgrade the other.

Installation isn’t hard if you’re comfortable using pip, but I’m not a python person, so I used port install pipx.

Duff – duplicate file finder

I’ve got this folder called vast/todo/t.temp that’s got a 100 GB of stuff from old computers in it. Typically, I just copy stuff there and tell myself I’ll get back to it. There are 61,287 files, none less than a year old, and (as of now) only 5 of those 60-thousand files are less than 2 years old.

How will I ever “get back to” making sense of all that junk? Enter duff – the CLI duplicate file finder. Just say:

$ duff *.txt

and it tells you something like this:

2 files in cluster 1 (19925 bytes, digest 8b5cc01edd340e91957b54f10c22d6d3283b7962)
ccc.txt
zzz.txt

Then you decide whether you want to nuke ‘ccc.txt’ or ‘zzz.txt’. Bob’s wife’s your aunt.

Installation is just port install duff

Extracting Text from Word DOCX files using Pandoc

Back in the day, I would use antiword to extract the text from a Word .DOC file. But it only understands DOC. Over the years, more and more Word files have been using the “open” (ha ha) DOCX format, which antiword doesn’t read. So I found Pandoc, which does much, much more.

$ pandoc -i some.docx -t plain > some.txt

There’s also a convert-to-Markdown option:

$ pandoc -i some.docx -t markdown > some.md

I find, however, that the Markdown produced by docx2md is more to my liking. It’s less cluttered, as it doesn’t aim at fidelity to the Word document’s formatting to the same degree as pandoc, but only the basics.

To install pandoc you can use the Macports version, but lately, I’ve found it easier simply to install the official binary Mac OSX PKG.

Macports Cheatsheet

I used to use homebrew, but before that I used MacPorts. (And long, long, before that, fink.) The past year or two I’ve come back to MacPorts. But I forget what the commands are. (Honestly, I get them confused with apt, but that’s a separate problem.)

The usual thing to do is to search and then install:

  • port search whatever
  • port info whatever
  • port variants whatever
  • port install whatever +somevariant

The other thing is to update the stuff you’ve already installed

  • port -d selfupdate
  • port list outdated
  • port upgrade outdated

And sometimes get rid of the old stuff

  • port list inactive
  • port uninstall inactive

Update: I left out two important commands:

  • port list installed # what got installed
  • port list leaves # what you installed

iTunes Misbehavior (Part 934)

I still use iTunes sync my iPhone periodically to my computer (mainly so I can retrieve photos off the phone). Every time I do, I get to watch this:

It copies several hundred unchanged songs back onto my phone. This is apparently a bug. A known bug, known for years, that Apple just won’t fix because it’s Apple being Apple. Screw them.

(This bug is perhaps unrelated to a separate problem — honestly, a bug — wherein someone decided it would be a good idea to change the file’s “modification” time every time a song was played. This is an idea so stupid I simply cannot imagine how anyone thought it was clever.)

Useful gems, 2020 edition

Since the gem ecosystem keeps changing, and since I don’t write new programs very often, here’s a list of my favorite gems for developing command-line interface tools.

Option parsing gem: slop. (Since micro-optparse looks moribund; see here.) But (looking at programs I’ve written) I also seem to like trollop, a/k/a optimist. But I also like the fine-grained control of OptionParser.

Debugging output (not the same as logging): pastel

Invoking system functions gem: tty-command. (See also tty-config and tty-file.) But sadly, tty-command (or how I’ve used it) gets me warnings that bellyache about the 2.7 named argument splat problem.

Wrapper for ImageMagick: About a decade ago, I couldn’t get RMagick (rubymagick?) to compile and I’ve never gotten around to checking back. For awhile I used %x<convert ...> or whatever, but now, if I’m working with images, I’ve sometimes found mini-magick helpful.

Proper Capitalization of Text Strings That Are Titles: titleize.

Parsing Biblical references (e.g., Romans 8:39 and Genesis 12:1-4): pericope.

Plus Kramdown and HAML and SASS (which is no longer written in Ruby).

Bash Completion Problem

I have this problem and can’t figure out what causes it. Once in awhile (more recently the past month or so, unless I’m imagining it) my bash autocomplete adds a trailing slash when it doesn’t belong there.

Just like in this 10-year old StackExchange article. Which doesn’t seem to solve the problem.

Q: if I have to learn about bash completion anyway, should I learn how to do my own bash completion scripts? Because I’ve found that tab to expand is about as smart as I want it to be. (I’m always frustrated on my Linux system because the default there is to notice what the command is and only offer to expand certain compatible filetypes.) Here are two places to get started:

Q: I’ve moved (back) to MacPorts in the past year. Is that the problem? I don’t think so, since I’m still using the /bin/bash that comes with Mac OSX. (See here to fix that.)



Configuring Useful CLI Utilities

This is a sort of directory to help me remember what I want to install on new machines (or new operating systems)

★★★ Cowboy’s dotfiles (like the init.d files but for a regular user)

Hackernoon’s Favorite CLI Utilities

BKuhlmann’s Mac OS configuration

Nate Landau’s bash_profile (described here)

fzy fuzzy finder

colout – a sort of g/re/p tool but colorizing the matches

xsv – csv manipulation

Crystal – I have to try porting some of my slower Ruby utilities to it.

renameutils – would you believe “utilities for renaming things?”

DIY init-style status messages

Heinlein’s Juveniles — Silly Book Challenge, #2

The second book in this very occasional series is … well, any of Heinlein’s juveniles. The cover is from the final book in the series, Have Space Suit, Will Travel (1958). It features bug-eyed monsters, space pirates, and a plucky hero who saves the earth from alien invaders over Labor Day weekend and still makes it back in time to get a free-ride scholarship at M.I.T. and throw a milkshake at the antagonist. Plus, we are taught a handy mnemonic for the order of the nine planets (see below) and a parable about frogs that isn’t the one about boiling them slowly. (Sorry for all the spoilers, but you’ve had 62 years.)

For this posting of my #2 fiction book, I could have picked any one of the series. They’re all great (except, I guess, Rocket Ship Galileo, the first). I mean, they were great when I first read them, starting in junior high school, when the science was only a little bit dated. (Venus had turned out not to have swamps, for example, and Mars never had canals. Jupiter’s EM environment would probably make Ganymede a poor place to farm.) Starting in 1953, after a few books set in our solar system, Heinlein got wise and set his stories somewhere more romantic.

But despite that, the juveniles are still great. Honestly, they’re better than most of Heinlein’s non-YA fiction. Practically all of it. Especially if you see Starship Troopers as the YA fiction that it ought to have been.

What are you waiting for? Get started! For a complete list, see the wikipedia article (search “heinlein juvenile”). But you’ll need to get them new. We never put the old ones back into circulation.