new lines in sed on mac

Let’s say I have a file:

2016-03 line 1.2016-03 line 2.2016-03 line 3.2016-03 line 4.

What I would normally execute:

sed 's/2016-03/\n2016-03/g' infile > outfile

But in OS X this resulted in output similar to:

2016-03 line1.n2016-3 line2.n2016-3 line3.

I tried on this for a bit before searching for the solution. The solution was to add /'$'\n which finally output what I was after:

sed 's/2016-03/\'$'\n2016-3/g' infile > outfile

2016-03 line 1.
2016-03 line 2.
2016-03 line 3.
2016-03 line 4.

Adding to the Favourites Sidebar

drag and drop folder to osx favourite sidebarWhen that happens, there are two other options:

  • File > Add to Sidebar
  • Keyboard shortcuts

Sometimes the File menu option is not available, but the keyboard shortcut CTRL + CMD + T is usually right to go.

You could try dragging a subfolder into place and then ESCAPEing out of it. This will usually open up the past the re-add the folder you couldn’t add a moment ago.


Installing Macports and md5deep on OSX

When it comes to installing packages and you have to make a decision between MacPorts or Homebrew I first went and visited their home pages (linked previously) and couldn’t make a decision based on what I saw to go either way. I didn’t want to install both, so I googled a bit more. I suggest you do the same since I don’t want people doing something JUST because I said so, go make your own decision :P

Having said that, I based my decision primarily on these points:

  1. the number of packages available in MacPorts (almost 25K) vs Homebrew’s (3K)
  2. the ease of Apache/PHP updates
  3. I’m comfortable with the command line and file/system permissions

Why do I want to install macports?

Because I’m a dunce at compiling, configuring, making stuff myself. And I’ve wanted md5deep for too long.

Now to install all I typed was:

sudo port install md5deep

and it was done.

It really was that simple.


I can’t sum it up any better than the author already has:

I wrote a little tool for OS X to alleviate a constant pain point for me, the lack of click through on multi-monitor setups. You know how when you have an application in the background on OS X, you have to click the application once (to give focus), then click again to do something? This annoys me to no end on my multi-monitor setup, because I can see the thing I want to click on, but I have to click it twice to make it register.

XClickThrough solves this problem by capturing your click, figuring out what you were clicking on, setting that application front most, then clicking on the target element for you.

Just a couple of points to note:

  1. depending on your security settings, if the application doesn’t load up because it comes from an untrusted source, simply bring up the context menu (right click or two-finger click) and hold down Option as you click the menu option: Open, and
  2. as mentioned on the author’s page, on Mavericks, you’ll have to enable the app in Accessibility Security & Privacy Settings.



Clean Installs for OSX Upgrades

Yosemite ad as it appears in the App Store

Yosemite ad as it appears in the App Store

I have a few Mac Minis floating around and some time ago I upgraded one of them to Mavericks. It did have an older version of Snow Leopard on it (pre 10.6.8) and after connecting it to the Internet and upgrading it to 10.6.8, I was able to download and install Mavericks.

But I didn’t want to do an upgrade, I wanted a whole fresh install. Using the upgrade version from the App Store, a clean install isn’t an option.

Fortunately, it’s not that hard to do.

Continue reading

Screen Capture an Active Application Window in OSX

Here’s a handy little feature I didn’t know about it OSX. To take a screen capture of an application window use COMMAND + SHIFT + 4 then SPACE then move the cursor to the area to be captured and CLICK.

This is very handy. I use COMMAND + SHIFT + 3 and COMMAND + SHIFT + 4 all the time, and I had bumped into the clipboard copy by accident at one time, but the SPACEBAR shortcut is something to keep in the memory banks.

Here’s a complete list.

Command+Shift+3 Capture entire screen and save as a file
Command+Control+Shift+3 Capture entire screen and copy to the clipboard
Command+Shift+4 Capture dragged area and save as a file
Command+Control+Shift+4 Capture dragged area and copy to the clipboard
Command+Shift+4 then Space bar Capture a window, menu, desktop icon, or the menu bar and save as a file
Command+Control+Shift+4 then Space bar Capture a window, menu, desktop icon, or the menu bar and copy to the clipboard

Freeze rows/columns in OSX’s Numbers spreadsheet

You can’t easily freeze rows or columns in the “Excel sense” in Numbers–Apple’s version of a spreadsheet.

But what you can do is create header rows and header columns (the default grey ones) that ARE frozen.

In Numbers:
>> open the document inspector
>> table inspector (3rd option for me, looks like a yellow table)

There are three “headers” and “footers” drop downs. At the bottom of the first two is an option to FREEZE that element. This only applies to header and footer rows/columns, but that should about solve the problem. It’s not as nice as excel’s approach (which in my opinion is a little ‘cleaner’), but it works.

accented characters in osx

selectable accents for the letter 'a'

selectable accents

UPDATE: I upgraded my OS X to Mountain Lion recently and I am not sure if it is as a result of the upgrade, or some other setting change I may have made, but now if I hold down a letter key for a short period, I get a tool-tip style box (right) that then allows me to select the appropriate accent. This doesn’t work for all letters, but it does make it more convenient.

I had a need to be able to print accented characters on certain letters, mainly being vowels, but potentially others as well. Most character sets have a limited set of accents, and most of them only apply to certain letters, and others don’t have the accents I want.

For example I want to print 5 main types of accents, being:

à á ā â ǎ

another example

x̀ x́ x̄ x̂ x̌

I’m using a macbook pro and pages in OSX, although this applies to any application, this is how I did it:

Open up System Preferences >> Personal >> Language and Text >> Input Sources

Once there, add a new keyboard, in this case I added “US Extended”.

Now to add some accents, I need to type the accent first, and then the character, but this only works for some letters (I suppose those that can be normally accented), but as you can see above, I have accented the letter ‘x’. So achieve this you must type the letter first and then [option]+[shift]+[code]. Not too hard, the five I need are:

  • a bar over the letter – ā – [option]+a then type the letter
  • a ‘v’ over the letter – ǎ – [option]+v then the letter
  • a ‘^’ over the letter – â – [option]+^ then the letter
  • a ‘`’ over the letter – à – [option]+` then the letter, and finally
  • a ‘ ́’ over the letter – á – [option]+e then the letter

^ <– is [shift]+6
` <– is the back tick, or key with the tilde (~) on it
́ <– is the quote mark key with single and double quotes [‘,”]

It was that simple :-)

note: I am learning the thai language and it is a very tonal language and inflections on letters are necessary to determine the tone of the word, hence I need this ability. These 5 marks above fit the bill perfectly, although the bar one really isn’t needed, but at least now I have the option of including it, or not including it.

Originally found here:…