I think, therefore I am. I am, therefore I sail

Category: OS X Page 1 of 6

How to fix the “sed command expects \” error on Mac OS

If you are familiar with the sed command on Linux then you might be in for an unpleasant surprise the first time you try to use it on Mac OS.

Mac OS runs the BSD version of the sed command. As such, there are some syntax differences.

An example of a classic sed command, that is used in build scripts everywhere:

sed -i 's/WORD/REPLACEMENT' file.txt

If you run that command on Mac OS you will be very grumpily greeted with the error:

sed: 1: "file.txt": command expects \ followed by text


Oh right, this is the BSD version of sed.

You could fiddle with the command until you find something that works on Mac OS. Then you have to ensure it still works on your Linux machines as well.

Or, you could bypass the issue and install the GNU sed via Homebrew.

I choose the second option. It is easier and none of my build scripts will require changes. It can be installed with:

brew install gnu-sed

After install, there will be a new command called gsed. This is great, but still requires updating everything using sed. Simple fix, alias sed in your shell profile. I am still a bash user, so I edit ~/.bash_profile and add the line:

alias sed='gsed'

Source the profile file and voila, the familiar sed version has been restored for you on Mac OS!

Happy sedding.

iMac on a desk

How to fix missing Calibri and Cambria fonts on Mac (Bonus: Segoe UI)

If you open Microsoft formatted documents on your Mac like I do then you have probably run across the annoying message saying the Calibri or  Cambria font is missing.

For years I have ignored this as an annoyance, but today I decided to do something about it. Turns out there is a very easy fix!

Richard Taylor of RMTWeb became fed up like me and put together a package of fonts to restore Calibri and Cambria fonts on the Mac.

Getting the fonts running is trivial:

That’s it.


You will no longer get that annoying message about missing fonts!

Thanks to Richard for providing this resource! His original instructions can be found at https://www.rmtweb.co.uk/calibri-and-cambria-fonts-for-mac

Bonus: Segoe UI Font

After posting the original fonts I ran across an issue with Segoe UI fonts missing. Microsoft provides a download for them at Segoe UI and Fabric MDL2 external icon font. The install instructions are the same as above!

Photo by Patrick Ward on Unsplash

Using wget to crawl your website

If you are looking to crawl your website for something like cache warming you can do so with wget quite easily.

The following wget command will crawl a site and leave nothing behind on the local filesystem afterward.

wget --mirror -q -e robots=off -p -r --delete-after -nd http://www.isleofmtv.com
–mirror crawls the entire site
-q prevents wget from writing output to the buffer
-e robots=off ignores directives in robots.txt
-p get all page assets
-r recursively request pages
–delete-after clean up any local files after running wget
-nd prevents wget from writing a directory structure that gets left behind

Quickly list all hosts in your ssh config

I try to be a good citizen and create unique ssh keys for each service I ssh into. I setup all sorts of fun config items and one of my favorites is host aliases. I have accumulated dozens of hosts in my config file and remembering the names of each can be problematic. I tend to open the config file a couple times a day to find a host. This morning I whipped up a quick command that will dump a list of all my hosts into the terminal with one command. No more opening the config file with an editor and scrolling through it. Hopefully this will be something you can enjoy also!

Update: A commenter provided a smoother version that gets rid of the grep call. Here it is.

sed -rn ‘s/^\s*Host\s+(.*)\s*/\1/ip’ ~/.ssh/config

But wait! That is a lot to type and this was supposed to make life easier. Add this as a shell alias and simply type sshhosts to get the list!

alias sshhosts="sed -rn ‘s/^\s*Host\s+(.*)\s*/\1/ip’ ~/.ssh/config"

Mute and unmute your mic quickly with this Alfred Workflow

I am on a lot of calls for work every day and juggle several different call applications. Finding the apps mute/unmute button quickly gets tedious. On some apps the UI is so poorly designed as to make toggling the mic nearly unusable.

Enter Alfred! Alfred is an amazing productivity app. Alfred let you run custom commands and hotkeys in custom Workflows.

I created a Workflow that, once installed, allows you to mute and unmute your mic with the command-M hotkey.

To install simply download the Workflow and double click it to load it into Alfred.

Click here to download the Mic PTT Alfred Workflow

The Workflow is on Github! If you have ideas for improvements create a fork and send them to me: https://github.com/blobaugh/Mic-PTT-Alfred-Workflow

Page 1 of 6

Powered by WordPress & Beards