back
202 comments
This article was nice, but it indicated that you need to change the system preferences in order to change the voice. It turns out that you can pass the -v flag to use a different voice, or "-v ?" to get a list of names.

So you can do

    say -v Samantha Help, I'm trapped in this castle!
or

    say -v Princess Help, I'm trapped in this castle!
But wait, it gets even better: The Mac comes with a number of voices for other languages, such as French, Hebrew, Chinese, and Arabic. And it turns out that the voices will work in English as well, using that country's accent. I just tried it with a few different languages, and was amazed by how well this worked, within reason:

    say -v Sin-ji  "Hello, I am Chinese.  What do you want to eat?"
    say -v Thomas  "Hello, I am French.  What do you want to eat?"
    say -v Carmit  "Hello, I am  Israeli.  What do you want to eat?"
And yes, I should get back to work...
Another fun one:

    say -v cellos dum dum dum dum dum dum dum he he he ho ho ho fa lah lah lah lah lah lah fa lah full hoo hoo hoo
Edit: 'In the Hall of the Mountain King' if anyone is curious.

There is also 'Pomp and Circumstance':

    say -v Good dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum
and Chopin's 'Funeral March':

    say -v Bad dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum dum
This is great, and the voices apparently only know how to speak English, and their own language!

That is, typing

    say -v Milena "Здравствуйте, меня зовут Milena.
Actually says, "Zdravstvuyte...", while typing

    say -v Bruce "Здравствуйте, меня зовут Milena.
Results in "Cyrillic capital letter 'Z'. Cyrillic small leter 'd'.", etc.
I must say...being a sysadmin with the ability to ssh into developers' laptops remotely in our domain...this is one of the more fun commands ;)
Imo the non-English voices speaking English aren't that useful as accented voices, because, at least for the Latin-alphabet ones, they're dominated by spelling-to-phonology mapping errors, like misreading diphthongs. It's an okay representation of someone who really speaks no English trying to sound out written English as if it were German, but it's not very similar to what a German accent in English sounds like, since a typical German accent isn't dominated by misreadings.

If it were open source you could probably get better results by hacking it up to parse in the "right" language and then only realizing the phonology in the "wrong" language, instead of both parsing and speaking in the "wrong" language.

just gonna leave this here...

  say -vjun "[[inpt TUNE]] h {D 100; P 233.08:0 233.08:100} OW {D 200; P 233.08:0 233.08:100} l {D 100; P 220:0 220:100} IY {D 200; P 220:0 220:100} f {D 100; P 233.08:0 233.08:100} AA {D 500; P 233.08:0 233.08:100} k {D 100; P 174.61:0 174.61:100} IY {D 500; P 174.61:0 174.61:100} n {D 50; P 174.61:0 174.61:100} g {D 50; P 174.61:0 174.61:100} S {D 100; P 155.56:0 155.56:100} IH {D 400; P 155.56:0 155.56:100} t {D 100; P 155.56:0 155.56:100} IH {D 200; P 233.08:0 233.08:100} t {D 100; P 233.08:0 233.08:100} s {D 100; P 233.08:0 233.08:100} AA {D 200; P 220:0 220:100} d {D 100; P 233.08:0 233.08:100} AY {D 500; P 233.08:0 233.08:100} n {D 100; P 174.61:0 174.61:100} OW {D 400; P 174.61:0 174.61:100} s {D 200; P 155.56:0 155.56:100} OW {D 500; P 155.56:0 155.56:100} r {D 200; P 155.56:0 155.56:100}"
This is how iPod Voiceover titles are recorded.

Which is rather lovely, because someone in Apple HQ has decided that the (London) band Saint Etienne must be French, and so Thomas faithfully reports that the current track is "Leek a Motorweh".

OMG the Dutch voice sounds perfect.

   say -v Xander "Ik houdt van appeltaart met slagroom in Scheveningen op zondag."
You can also use the voice from html5 but support is really shoddipy and buggy. Safari provided all the voices. Chrome not so much.

http://greggman.github.io/text2speech/

There's also some singing like voices.

`say` reminds me of the *SAY command that came with Superior Software's Speech! program for the BBC Micro. Software-only speech synthesis on an 8 bit micro with limited sound hardware was very impressive!
pbpaste and pbcopy never really occur in ambiguous situations, so I wrote the following shell script:

  function clip { [ -t 0 ] && pbpaste || pbcopy }
This is easier to type and allows for the following:

  % echo hello | clip
  % clip
  hello
For Linux users, `xdg-open` is the equivalent of `open`. The latter exists on Linux, but it will open a socket.

There are a number of utilities that handle copy/paste, but `xclip` is probably the most widely used.

Screenshots can also be done a number of ways, but `scrot` is my favorite. The two most useful flags to pass with it are `-s` and `-d`.

As for `launchctl`, `systemctl` is what you want to use to do the same things.

Note that these equivalents all address the same functionality, but the syntax may be different.

A key command is missing: textutil.

textutil is a general purpose front end to the core text engine and is one of the cleanest docx-to-html converters I've run across, with a bunch of file formats supported and charset encoding translations, metadata manipulation commands, and assorted juicy goodness for people who have to mess with word-processed text.

Ironically the only common-on-Apple document format it can't do anything with is that of Apple's Pages word processor ...

I would add caffeinate, which prevents the Mac from going to sleep. It can do this indefinitely, for a fixed period of time, or after a process is done running. You can even specify that process either as the PID of an existing process or by invoking it through caffeinate itself.
`say` is one of my favorite little things about OS X. In a couple of my build script, I have throw in a couple random say commands if say is installed on the system. Everyonce in a while a Dev will ping me when their computer speaks to them.

I created a gist that says a random starwars quote in each of the systems supported voices.

https://gist.github.com/balasuar/6bf1c64594780836cfcd

This is a great intro. Here's my favorite OS X Terminal trick:

⌘. (command period) is a hotkey not defined in the menu for sending BREAK. This is automatically equivalent to ctrl+c in shells, ctrl+g in emacs and ESC in Vim. Similarly, ⌘K is short for clearing the screen. These are much more ergonomic than the standards on Mac laptops and wireless keyboards.

I can recommend using iTerm2 as the command line app. Apples Terminal has improved. But iTerm2 has a lot of handy features. A great terminal.

https://www.iterm2.com

One nice application I've found of pbpaste is when I want to count things I find in a browser. For example, to count the (approximate) number of comments in this thread, you can copy all text using Cmd+A, Cmd+C, then run this:

pbpaste | grep ago | wc -l

In this case there are easier (and more accurate) ways, but in other situations you can use it to find the length of a list on the web where it would otherwise be harder.

And if you'd like to use some of those utilities on GUI apps, don't forget the utility to bind them all: Automator.app. It'll let you interact with terminal and GUI apps in all sorts of interesting ways. For example, you could create a global keyboard shortcut to upload the selected text to a pastebin.
Remove unwanted formatting from text in the clipboard:

    alias pbclean='pbpaste | pbcopy'
I'm surprised they didn't mention anything about the command line utilities to manage the mac's airport (scan for wireless networks, list network interface names, etc). I did a quick blog post about these a while back: http://blog.mattcrampton.com/post/64144666914/managing-wifi-...
A nice complement to the command line "open" command is adding a shell launcher to OSX finder. I have some instructions how to do this here: http://www.win-vector.com/blog/2012/05/enhance-osx-finder/
Nice commands. Also 'sips' for batch resizing images.

If you aren't on OSX you can try the following for a simple 'say' alternative. It has some great robotic/singing voices, too.

https://github.com/Jam3/says

This was posted last year and did very well on HN [1]. I remember because it is literally the thing that got me interested in using the command-line as a power user...I'm embarrassed to say I hadn't really understood piping, but curling texts from Gutenberg into `say` was a fun introduction. Now I constantly use open, pbpaste, and pbcopy... learning about screencapture was also extremely helpful for my blogging and tutorial writing, as I've written a few wrappers around it to customize and optimize its output, including auto-uploading it and creating a snippet I can quickly paste into a blog post.

Great list!

[1] https://news.ycombinator.com/item?id=7747982

say -v cellos "Dum dum dum dum dum dum dum he he he ho ho ho fa lah lah lah lah lah lah fa lah full hoo hoo hoo"

:)

I have fond memories of discovering my college roommate's open SSH connection, and using "say" to great effect.
The first of these is easier as:

  open -a Safari
mdfind also has a -name option that allows one to search for the query in the filename rather than contents.
Does anybody know of a good alternative to "at" on OS X? I know it's there but not enabled by default, I went through the paces required to activate it long ago but it something in Yosemite seems to have broken atrun and I can't find anything about it anywhere online.
Also dtrace and some of the included scripts like opensnoop are awesome.
Great list, some really useful commands.

One question: What's wrong with "locate"? It is really fast because the file system contents are indexed. As long as you understand that it's not going to pick up the latest new files without running "updatedb" (sudo/usr/libexec/locate.updatedb" in os x) first, it's much better than find if you're doing a quick search.

However, I didn't know spotlight has a CLI. Cool.

Oftentimes I'll have something on the clipboard, so pbpaste | grep is good. But sometimes the thing I want to search for is long, such that I don't want to type it for the grep.

Fortunately, pbpaste takes a -pboard flag for selecting a different buffer. So cmd-e some text to put it on the find pasteboard, then 'pbpaste | fgrep --color -i "`pbpaste -pboard find`"'

I usually have this aliased to 'pbg'

Sadly Xcode3's excellent merge tool seems inaccessible from the command line in Xcode4. Anyone have a fix? http://stackoverflow.com/questions/13163670/how-to-use-xcode...
Non-case sensitive really bothers me with OS X
"Many a Linux power user has tried to use locate to search for files on a Mac and then quickly discovered that it didn’t work."

Rather, that it gives you instructions for getting it to work. How's a Linux power user getting by without following such instructions to turn on one of their favorite utilities?

I use: open vnc://myServer.local

It will open up the screen sharing app and connect for you :)

Paging mods for headline change. I suggest, "OS X Command Line Utilities"
I've documented many of these utilities here: http://ss64.com/osx/
Anyone happen to know how he's getting archey output to be colour for the Apple logo? my iTerm and Terminal is just in white/black.
There is also `tmutil` to manage time machine backups, can be handy, especially in scripts.
#6 is the likes of what got us detentions in middle school
The "alphabetical list of all OS X commands" page this article links to is cute. :)

    say 'ay ay. ay ay. smoke weed. every day.'
I like do harmless pranks on coworkers who don't lock their computers

    yes "lock your computer, numbskull" | xargs say
Just repeats the phrase in a monotone computer voice over their headphones. I only do this to engineers, tried it on a PM once, never again.
What's with all the buzzfeed-level headlines making HN frontpage the past few days?

Not to say this isn't a useful list (for OSX users that is), but I can't possibly be the only one weirded out by this.

Great list, not a big fan of homebrew personally, or its creator who seems to be full of himself. I'd recommend pkg_src from joyent[0]. homebrew seems to have a lot of the hip webdev packages, but pkg_src and joyent's repository is the real deal when it comes to hardcore UNIX package management. Some friends have a nice bootstrap for pkg_src on OS X called saveosx[1], too.

[0]: https://pkgsrc.joyent.com/install-on-osx/

[1]: http://www.saveosx.org/