osx

How to copy the macOS Terminal path to the clipboard alvin May 15, 2017 - 9:24am

If you want to copy the current macOS Terminal path to the clipboard, you can do it with this simple command:

$ pwd | pbcopy

pwd prints the path to STDOUT, and pbcopy reads that and copies it to the macOS clipboard. Once the path is on the clipboard you can paste it into your other applications.

Of course you can also create an alias, like this:

alias path="pwd | pbcopy"
How to copy text from the MacOS Terminal to the clipboard alvin April 10, 2017 - 5:48pm

If you ever need to copy text (or a text file) from the MacOS Terminal to the Mac clipboard, I can confirm that the macOS pbcopy command works. It reads from STDIN and copies the text to the clipboard, so commands like these work:

$ echo "foo bar baz" | pbcopy

$ cat /etc/passwd | pbcopy
MacOS/GoDaddy ssh error: Unable to negotiate, no matching host key type found, their offer alvin November 24, 2016 - 3:00pm

As a quick note, I haven’t tried to log into one of my GoDaddy websites in several months, and when I tried to log in just now I got this macOS ssh error message:

Unable to negotiate with <ip-address here> port 22: no matching host key type found. Their offer: ssh-dss
How to replace newline character with sed on Mac OS X (macOS) alvin November 12, 2016 - 3:57pm

I don’t have much time to explain this today, but ... if you want to see how to use the sed command on a Mac OS X (macOS) system to search for newline characters in the input pattern and replace them with something else in the replacement pattern, this example might point you in the right direction.

How to fire Mac OS X notifications with AppleScript (and Scala) alvin November 3, 2016 - 9:06pm
Table of Contents1 - A “Hello, world” MacOS AppleScript notification2 - AppleScript: Mac notification with a sound3 - How to add a title and subtitle to your notification4 - Running from Scala or Java5 - See also6 - Summary

Summary: This tutorial demonstrates how to fire MacOS system notifications with AppleScript (and Scala or Java).

In this article I assume that you already know at least a little bit about how to use AppleScript, and just want to know how to trigger a MacOS notification. At the end of the tutorial I show how to invoke the AppleScript code using Scala and Java.

Mac exodus? alvin October 30, 2016 - 3:41pm

I haven’t been blown away by MacOS (nee OS X) in quite some time, and the latest MacBook design seems to have annoyed even more developers. A good thing about this is that it got me looking into Qubes OS, “a reasonably secure operating system.”

Apple’s philosophy of “we design the hardware and software” works well when people like your work, but when people don’t like your design it’s easy to lose customers.

Two more Textmate commands (capitalize, CSV to list) alvin September 11, 2016 - 10:43am

As a “note to self,” I wrote two more Textmate commands yesterday, one to capitalize each word in a selection of words, and another to convert a CSV list of words to a simple list. Here’s the source code for the Capitalize command:

#!/bin/sh

perl -ne 'print ucfirst $_'

The $_ portion of that Perl command isn’t required, but I include it as a reminder to myself about how Textmate commands and snippets work.

Here’s the source code for my Textmate command that uses the Unix tr command to convert a CSV list of words (such as a paragraph of comma-separated words) into a simple list of words:

#!/bin/sh

tr , "\n"

As you can see, those commands are fairly simple. If you know Unix/Linux and then know a little about how to write Textmate commands, you can usually get it to do what you want. I like that you can use any Mac/Unix programming language or tool to solve the problem at hand.

Apple has an iOS/macOS “Stagefright” security flaw alvin July 21, 2016 - 6:12pm

According to Forbes and other sources, Apple now has its own version of a “Stagefright” security flaw, and it affects all but the most recent versions of iOS and Mac OS X. Theoretically all it requires is that a hacker sends your phone one text.

Apple’s minimalist security announcements are here: iOS 9.3.3 update, OS X update.

How to set the Java version on Mac OS X (macOS) systems alvin July 20, 2016 - 8:11pm

I don’t remember where I first found this line of code, but if you put it in your Mac OS X ~/.bash_profile file, it’s an easy way to set your Mac Java version:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

I can confirm this works with the Bash shell on Mac OS X 10.10. When I run the java -version command after opening a new Mac Terminal window, the output is 1.8.0_25.

A slightly more difficult way to set your Mac Java version is to look under the /Library/Java/JavaVirtualMachines directory to see which versions are installed, and then manually set the version.

What is the Mac OS X (macOS) fonts folder? (to add new fonts) alvin July 15, 2016 - 4:33pm

Apple/Mac FAQ: I want to add new fonts to my Mac, what is the Mac OS X (macOS) fonts folder?

Just put any new font files in the Library/Fonts folder under your home directory. For instance, my Mac OS X username is alvin, so the correct fonts folder is: