
OS X Command Line Utilities - brianwillis
http://www.mitchchn.me/2014/os-x-terminal/
======
cstross
One command I can't live without: textutil.

Basically it's a command-line front end to Apple's TextKit file import/export
library. Works with a bunch of rich text/word processor formats, including
OpenDoc, RTF, HTML 5, and MS Word. Critically, the HTML it emits is _vastly_
better than the bloated crap that comes out of Microsoft Word or LibreOffice
when you save as HTML ...

Install pandoc and multimarkdown as well and you've got the three pillars of a
powerful, easy-to-use multiformat text processing system.

~~~
mitchchn
Pandoc and multimarkdown are the greatest. I've never found a way to fit
textutil into that workflow, though. Is there anything it can do that pandoc
can't by itself?

~~~
cstross
Textutil handles a couple of apple-specific file formats (rtfd, webarchive)
that do an embrace-and-extend on open(ish) standards.

(Annoyingly it _doesn 't_ provide a way to get at the guts of Apple's own
Pages files. Which sucks because the only tools for transcoding Pages are
Pages itself, and icloud.com.)

~~~
mitchchn
Thanks! I played with this last night and wrote about it in my followup:
[http://www.mitchchn.me/2014/and-eight-hundred-
more/](http://www.mitchchn.me/2014/and-eight-hundred-more/)

------
eschaton
What always surprises me is that so many don't know or use the directory stack
commands, pushd and popd. I'll admit I was also ignorant of them until
something like 2005, but once I learned of them I switched and never looked
back. Now I can't see someone write or type "cd" without a little bit of a
cringe.

~~~
ggreer
Many people love them, but I never got the hang of pushd and popd. These days,
I use a CDPATH and z[1]. I also use zsh, which supports handy little things
such as cd - (cd to previous directory).

If you haven't tried it, I highly recommend z. It's impossible to Google for,
but it's oh-so-convenient.

1\. [https://github.com/rupa/z](https://github.com/rupa/z)

~~~
bronson
'cd -' is implemented by the cd command using the OLDPWD environment variable.
It works in all shells.

~~~
ggreer
I did some digging and it turns out I had autopushd set. No wonder I didn't
understand the usefulness of pushd/popd; I was already using them.

Also, by "cd -" I meant cd -[tab], cd -1, cd -2, etc.

~~~
mokkol
Thanks! didnt know the tab feature.

------
ggreer
I didn't know about `screencapture`. That's a fun one.

The Linux equivalent of `open` is `xdg-open`. I usually alias it to `op`,
since `/bin/open` exists.

Another bit of terminal-sugar for OS X users:

    
    
        alias lock='/System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend'
    

And most Linux users:

    
    
        alias lock='gnome-screensaver-command -l'
    

If you find yourself accidentally triggering hot corners, the lock command is
your savior.

I've sorta-documented this stuff over the years, but only for my own memory.
[https://gist.github.com/ggreer/3251885](https://gist.github.com/ggreer/3251885)
contains some of my notes for what I do with a clean install of OS X. Some of
the utility links are dated, but fixing the animation times really improves my
quality of life.

~~~
rimantas
cmd+shift+eject

~~~
X-Istence
Ctrl + Shift + Eject

or

Ctrl + Shift + Power (on MacBook Pro's that don't have an eject key)

Cmd + Shift + Eject doesn't do anything.

~~~
AdamGibbins
This sleeps/suspends rather than just locking. Equivalent to closing your
MacBook.

~~~
X-Istence
If you have your Mac set to never sleep/are using Caffeine for instance, then
it simply puts the display to sleep, the rest of the computer keeps on humming
along.

Not entirely equivalent to closing your MacBook.

------
greggman
These are awesome. I didn't know about many of them.

One tiny thing though, at the bottom it says

> Recall that OS X apps are not true executables, but actually special
> directories (bundles) with the extension .app. open is the only way to
> launch these programs from the command line.

Actually, you can launch them in other ways. Example

    
    
        /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome  --user-data-dir=/Users/<username>/temp/delmechrome --no-first-run
    

Will start a new instance of Chrome with it's own datastore in
~/temp/delmechrome. add some URL to the end to have it auto launch some
webpage. Delete ~/temp/delmechrome to start over.

~~~
_jsn
Although this technically works, in some cases it may lead to strange bits of
misbehavior. (Depending on where you do it, the app may end up in the wrong
audit session or mach namespace, and it may also be missing some environment
variables that it was expecting).

The open command does allow you to specify command-line arguments to pass to
the application (via --args), which is generally a safer way to do things.

~~~
veidr
But the open command doesn't allow you to pass the environment, and Apple
seems hellbent on breaking every workaround they've implemented over the years
(e.g. ~/.MacOSX/environment.plist).

So, doing Foo.app/Contents/MacOS/Foo is often the only way to launch a GUI app
while inheriting the full environment that you have on the command line.

I often have to do this to launch various developer tools, and have them be
able to inherent important environment variables, e.g. database credentials or
secrets,

~~~
micampe
_> But the open command doesn't allow you to pass the environment_

Uh? I’ve been using open to pass NSZombieEnabled and other debugging stuff to
apps all the time and it works.

From man open(1):

    
    
        Opened applications inherit environment variables just
        as if you had launched the application directly through
        its full path.  This behavior was also present in Tiger.

~~~
veidr
What?! Awesome! I would _swear_ that was once not the case... (checks man
page)

    
    
        Opened applications inherit environment variables just
        as if you had launched the application directly through
        its full path.  This behavior was also present in *Tiger*.
    

Sigh, I'm _old_...

------
pling
Another one that I can't live without:

    
    
       ssh-add -k keyfile
    

Integrates with keychain meaning you can have a passworded private key without
having to play around with ssh-agent and shells and profiles. Put keychain
access in the menu bar and you can lock the keychain on demand as well.
Integration of ssh into the OSX workflow is absolutely awesome.

That and some of the examples in that article really make it a killer platform
for Unix bits.

------
wink
'open' is on of the things I long for most as a Linux user. There are several
ways to achieve something that are all inferior or downright broken. Usually
you don't have a huge problem, until you have. xdg-open for example could've
solved this, if it was universally working.

I wrote related rant once[0] when I tried to debug an issue of a misconfigured
default browser.

[0]: [http://f5n.org/blog/2013/default-browser-
linux/](http://f5n.org/blog/2013/default-browser-linux/)

~~~
reedlaw
xdg-open works for me with the GNOME-configured default application.

~~~
JasonFruit
While xdg-open also works well for me with KDE's default applications, when I
used to use Openbox or LXDE, it was much less successful. The breadth of the
group of tools that respond correctly to KDE settings as opposed to the less-
common environments has been one of the reasons I've been so happy to switch.

------
DCKing
Could you imagine Apple would have gone for BeOS or a custom developed kernel
with no significant terminal-based userland when making OS X? It would
probably still be used by many casual users or those doing graphical work, but
I doubt it would be used by hackers at all.

~~~
0x0
Didn't BeOS ship with bash and everything?

~~~
DCKing
Whoops. Yes it did. Haiku still does: [http://www.haiku-
os.org/docs/userguide/en/bash-scripting.htm...](http://www.haiku-
os.org/docs/userguide/en/bash-scripting.html)

------
nmc
/usr/local is the default location for user-installed stuff, but I personally
like to have my package manager do its stuff in a separate directory.

I like the way Fink [1] uses the /sw (software) directory.

Does anyone have a valuable opinion on the comparison between Fink and
Homebrew — or maybe MacPorts?

[1] [http://www.finkproject.org](http://www.finkproject.org)

~~~
patrickmay
I agree about staying out of /usr/local. I install stuff there -- I don't want
my package manager taking it over. That's kept me away from Homebrew.

~~~
tvon
It does bother me that Homebrew advocates using /usr/local, that is a choice
that needs justification and I don't believe they offer anything convincing.

That said, you can configure homebrew to use any path (check the wiki), you
just have to set other environment variables as needed (eg, PATH). For example
I'm currently using /opt/homebrew.

(note: a large downside to this is that you have to compile everything and
cannot take advantage of Homebrew's pre-compiled "bottles" for some packages)

~~~
patrickmay
/opt/homebrew would be consistent with other large systems. I'd like to see
that be the default.

------
Monkeyget
This was supposed to be few lines of remarks. It expanded quickly in relation
with my enthusiasm for this topic.

I've been investing some time in the command line on my Mac. I am moving from
a dilettante going to the shell on a per-need basis to a more seasoned
terminal native. It pays off handesomely! It's hard to convey how nice it to
have to have a keyboard-based unified environment instead of a series of
disjoined mouse-based GUI experiences.

Here are some recommendations pertaining to mastering the command line on a
Mac specifically:

-You can make the terminal start instantaneously instead of it taking several seconds. Remove the .asl files in /private/var/log/asl/. Also remove the file /users/<username>/Library/Preferences/com.apple.terminal.plist

\- Install iterm2. It possesses many fancy features but honestly I hardly ever
use them. The main reason to use it instead of the default Terminal
application is that It just works©.

-Make your terminal look gorgeous. It may sound superficial but it actually is important when you spend expanded period of time in the terminal. You go from this [http://i.imgur.com/cx3zZL8.png](http://i.imgur.com/cx3zZL8.png) to this [http://i.imgur.com/MQbx8yK.png](http://i.imgur.com/MQbx8yK.png) . You become eager to go to your terminal instead of reluctant. Pick a nice color scheme [https://code.google.com/p/iterm2/wiki/ColorGallery](https://code.google.com/p/iterm2/wiki/ColorGallery) . Use a nice font (Monaco, Source Code Pro, Inconsolata are popular). Make it anti aliased.

-Go fullscreen. Not so much for the real estate but for the mental switch. Fullscreen mode is a way to immerse yourself into your productive development world. No browser, no mail, no application notification. Only code.

-Install Alfred. It's the command line for the GUI/Apple part of your system. Since I installed it I stopped using the dock and Spotlight. Press ⌘+space then type what you want and it comes up. In just a few keystrokes you can open an application, open gmail/twitter/imdb/..., make a webs search, find a file (by name, by text content), open a directory,... It's difficult to describe how empowering it is to being able to go from 'I want to check something out in the directory x which is somewhere deep deep in my dev folders' to having it displayed in 2 seconds flat.

-Make a few symlinks from your home directory to the directories you use frequently. Instead of doing cd this/that/code/python/project/ you just do cd ~/project.

-Learn the shell. I recommend the (free) book The Linux Command Line: [http://linuxcommand.org/tlcl.php](http://linuxcommand.org/tlcl.php) . It guides you gently from simple directory navigation all the way up to shell scripting.

-Use tmux. Essential if you want to spend some time in the terminal. You can split the window in multiple independent panes. Your screen will have multiple terminals displayed simultaneously that you can edit independently. For example I'll have the code in one side and on the other side a REPL or a browser. You can also have multiple windows each with its own set of panes and switch from on to the other. With the multiple windows I can switch from one aspect of a project to another instantly. E.g: one window for the front-end dev, a second one for the backend and another for misc file management/git/whatever.

-Pick an editor and work towards mastery. I don't care if you choose vi or emacs. You'll be surprised how simple features can make a big change in how you type. You'll be even more surprised at how good it feels

The terminal is here to stay. It's a skill that bears a lot of fruits and that
deprecate slowly. The more you sow the more you reap.

~~~
gradstudent
> \- Install iterm2. <snip> The main reason to use it >instead of the default
> Terminal application is that It just works©.

What's wrong with the default Terminal application? I use it daily and have
been for close to a decade. I never found myself wishing it did anything than
what it already does.

> -Use tmux.

Meh. For most people screen works just as well. Perhaps more importantly, you
can rely on screen being available pretty much anywhere. Just like vim.
Speaking of which: vim is great. Use vim. The world needs more vim.

~~~
_ak
iTerm2 does vertical and horizontal splitting better than Terminal.app.

tmux does vertical and horizontal splitting better than screen.

That's my rationale for using iTerm2 and tmux instead of Terminal.app and
screen.

(yes, I'm aware that screen has improved its splitting recently, but I
switched to tmux in 2011, after seeing a presentation about it by Nicholas
Marriott)

~~~
gradstudent
Why split your terminal if you have screen / tmux?

~~~
Monkeyget
iterm has special integration with tmux. The big advantage is that you can
quickly scroll the history with the mouse which is way faster and more
convenient that going back up screen by screen with a shortcut.

Also with some work you can synchronize the OSX clipboard with tmux's one.

~~~
mitchty
I scroll using the mouse in tmux all the time in any mouse capable terminal
(aka not Terminal.app, also regular linux terms).

I have a toggle to turn it on off in my tmux.conf, have a looky:
[https://github.com/mitchty/src/blob/master/dotfiles/tmux.con...](https://github.com/mitchty/src/blob/master/dotfiles/tmux.conf#L126)

~~~
aroch
You can scroll in Terminal.app too, use the MouseTerm SIMBL plugin

~~~
ch4s3
Well, once you're bolting on plugins for features that come with iTerm2, why
not use iTerm2?

~~~
aroch
Because I find iTerm to be a pile of crap on most of my systems

~~~
mitchty
Out of curiosity iTerm or iTerm2? If the latter what is crap about it?

I have one huge gripe that I haven't been able to fix but its not that huge a
deal. Every so often the terminal will lose its mind and start displaying
mouse escape sequences. Nothing resets it out of this state, have to close
whatever window I have open and start anew. Not a huge deal due to tmux but
annoying enough to frustrate.

------
runjake
9\. /usr/sbin/system_profiler

10\. /System/Library/CoreServices/Applications/Wireless Diagnostics (with
built-in wifi stumbler)

11\. /System/Library/CoreServices/Screen Sharing.app (Built-in VNC client with
hardware acceleration)

12\.
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources
(Command-line wifi configuration and monitoring tool)

Combine with sed, awk, and cut, and these tools can provide useful monitoring.

------
torrent-of-ions
Another thing you can do to improve speed is learn the keybindings for
readline. They are the same keybindings as emacs, and lots of other things use
readline too like python shell, sqlite, etc. A very useful set of keys to have
in your muscle memory. See the readline manual:
[http://tiswww.case.edu/php/chet/readline/rluserman.html#SEC3](http://tiswww.case.edu/php/chet/readline/rluserman.html#SEC3)

~~~
shawndumas
if your a vi/vim user in you're .inputrc set:

    
    
        set editing-mode vi
        set keymap vi-command
    

see more settings @
[https://github.com/shawndumas/dotfiles/blob/master/readline/...](https://github.com/shawndumas/dotfiles/blob/master/readline/.inputrc)

~~~
cerberusss
This won't work for some standard stuff that OS X ships with, for instance
Python (when started as a command-line interpreter). That's because .inputrc
is read by the GNU readline utilities, and Apple links with the BSD
equivalent.

To make this work for Python:

Add a file called .editrc with the following content:

bind -v

Add a file called .pythonrc with the following lines:

import rlcompleter import readline

Add a line to your .bashrc which makes Python run .pythonrc when it starts
interactively:

export PYTHONSTARTUP="$HOME/.pythonrc"

Now Python will understand your vi keystrokes :-)

------
_jsn
mdfind / Spotlight can be a fairly powerful tool. Consider this query, which
finds all Xcode projects I've tagged as "Active":

    
    
      ~$ mdfind tag:Active kind:xcode
      /Users/jn/Code/xyz/xyz.xcodeproj
      ...
    

Queries like this also work in the Cmd-Space UI, or as a Saved Search. By
default each term is joined with AND, but you can specify OR too.

------
smw
Put this in your path somewhere, find files, links, directories instantly,
with globbing. Makes mdfind actually useful.

    
    
      $ mdf "*invoice*.pdf"
      /Users/smw/Downloads/Invoice-0000006.pdf
    

[https://gist.github.com/smw/a21a9f675ed3358830da](https://gist.github.com/smw/a21a9f675ed3358830da)

------
barbs
I use multiple POSIX environments (OS X at work, Linux Mint and Xubuntu at
home), and I find it handy to create common aliases for differently
implemented commands to keep the environments consistent.

For example, I set the letter 'o' as an alias for 'open' on OS X, and to
"thunar" on Xubuntu and "nemo" on Linux Mint.

------
milla88
My favorite command is 'say'. You can do all kinds of silly voices.

Try this out: say hello -v Good

~~~
minikomi
Just mucking around, came up with this:

    
    
        wc -l < /usr/share/dict/words | xargs -I {} jot -r {} 100000  | paste -d " " - /usr/share/dict/words | sort | awk '{print $2 "! "}' | say

~~~
pavel_lishin
If you install coreutils (`brew install coreutils`), you can cut that down a
bit:

    
    
        gshuf /usr/share/dict/words | head -n 10 | awk '{print $1 "! "}' | say

------
pirateking
After years of living on the command line, OS X specifically, and learning its
quirks and tricks, I am actually ready to move on.

Right now I am more interested in creating simple visual interfaces on top of
UNIX-y tools, for my own personal use cases. The main benefit of this is the
ability to better experiment with and optimize my workflows for different
properties as needed through different combinations of single responsibility
interfaces and single responsibility programs.

I am sensing that there is great promise in seeing much higher APMs (actions
per minute) for many tasks, even compared to the all-powerful command line.
Also, there are lots of interesting possibilities for better visual
representations of data to improve comprehension and usability.

~~~
twic
Why do you think that having a visual interface will make it easier to
experiment with your workflow?

This is a genuine question - personally, i find command line interfaces to be
far more hackable than graphical ones, so i would expect the opposite to be
true, and hence i'm interested in your perspective.

~~~
pirateking
The command line is a textual interface, and both code and data can be
represented as text at a low level. It would seem that this is a good thing
for efficiency and usability, as it minimizes context switching between
interface paradigms, and offers direct access to a low level representation of
the system using a high bandwidth input device (a keyboard).

I still think textual interfaces are a great thing for those reasons, but I
don't believe they are the best thing in many cases. Yes, they are very
capable and customizable, but have serious weaknesses with usability,
especially when working with data of higher dimension.

I don't really think of it as text versus graphics, but rather an issue of
data being represented in its best form for doing some particular work with
it, and having the best interfaces to those different forms and the work. The
traditional one-domain/one-application GUI model is unsustainable for this
purpose, and has the weakness of constant context shifting. Composable visual
interfaces are an anti-application paradigm, and more focused on data flow. To
avoid problems with pure visual programming environments, symbols would still
be considered the best representation for certain work (like editing text and
working with logic).

------
ansimionescu
Additions:

* lunchy: wrapper over launchctl, written in Ruby – [https://github.com/mperham/lunchy](https://github.com/mperham/lunchy)

* brew cask: "«To install, drag this icon...» no more", as they say – [https://github.com/caskroom/homebrew-cask](https://github.com/caskroom/homebrew-cask)

* have fun with "say" – [https://github.com/andreis/different](https://github.com/andreis/different)

~~~
xraystyle
Speaking of fun with "say", this was a hit around my office for a while:
[https://github.com/xraystyle/talking-
computer](https://github.com/xraystyle/talking-computer)

------
allavia88
There's been a few of these lists over the past few years, most recent one is
[https://news.ycombinator.com/item?id=7494100](https://news.ycombinator.com/item?id=7494100)

It seems like a large portion of HN is less experienced re sysadmin, but is
interested in it nonetheless. Perhaps there's room to make a 'codecademy for
unix' type course? Curious to see what folks thing.

~~~
mitchchn
It does feel I'm retreading ground that's already been covered too many times,
but my whole motivation for this blog was more or less what you're observing.
There's a huge group of people on the fringes of hacker culture who are
looking for a way in and don't know where to start. Definitely a fan of the
idea of 'Nixacademy.

------
jpb0104
Here is a very handy script that takes a screenshot, places it in Dropbox's
public directory, shortens the public URL, then puts the short URL in your
clipboard. Making for very quick screenshot sharing. It combines a few of
these hints.
[https://gist.github.com/jpb0104/1051544](https://gist.github.com/jpb0104/1051544)

------
archagon
Great list! Includes all the old favorites with clear explanations.

This is only tangentially related, but I recently wrote a little Automator
Service to gather any selected file and folder paths from Finder. I very often
need to grab the path of something for programming-related stuff, and doing it
from the command line or with the mini-icon drag-and-drop takes way too long.
Maybe somebody here will find it useful!
[http://cl.ly/1a3s3g1u2Q2w](http://cl.ly/1a3s3g1u2Q2w)

~~~
CGudapati
Definitely useful. Thanks !

------
shurcooL
If you do Go development, you can do this to quickly get to root folder of any
Go package:

    
    
      function gocd {
          cd `go list -f '{{.Dir}}' $1`
      }
    

It uses the same syntax as go list to specify packages, so you can do, e.g.:

    
    
      ~ $ gocd .../markdownfmt
      markdownfmt $ pwd
      /Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/shurcooL/markdownfmt
      markdownfmt $ _
    

So nice.

------
hibbelig
I want "remote pbcopy"! I'd like to be able to log in to any remote host
(usually Linux in my case), then tack something onto the command line I'm
typing to copy it into the pastebuffer.

    
    
        ssh somehost
        cd /some/dir
        grep -lr foo . | remote_pbcopy
    

I guess something like this is possible with GNU Screen or with Tmux, and
perhaps the Tmux/iTerm interaction helps, but I've never figured it out.

~~~
pikachu_is_cool
On your Mac:

    
    
        ssh -R 19999:localhost:22 remote_host
    

On the remote host:

    
    
        command_that_prints_stuff | ssh localhost -p 19999 pbcopy
    
    

________

The first command routes the port 19999 on the remote host to port 22 on the
computer you're using.

ssh part on the second command connects to 19999 (and thus 22 on your
computer) and runs the pbcopy command in the current shell (which is the pipe
from command_that_prints_stuff)

~~~
enneff
Why not just

    
    
        ssh remote_host command_that_prints_stuff | pbcopy
    
    ?

~~~
pikachu_is_cool
Depends on the situation, if you want to run a quick script then yours would
be better. If you're spending a lot of time in remote_host then mine might
make more sense.

------
js2
Two more for you:

sips -
[https://developer.apple.com/library/Mac/documentation/Darwin...](https://developer.apple.com/library/Mac/documentation/Darwin/Reference/ManPages/man1/sips.1.html)

osascript -
[https://developer.apple.com/library/mac/documentation/Darwin...](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/osascript.1.html)

------
RazerM
It seems odd to have

    
    
      open /Applications/Safari.app/
    

as an example, when

    
    
      open -a safari
    

does the same thing.

~~~
kranner
Except that the first one is supported by TAB-completion.

~~~
cobbal
With the right zsh plugin, either of them will tab complete properly. (I think
"osx" from oh-my-zsh is the one that does it on mine)

Edit: looks like this is actually built into zsh. Slightly surprised, but just
goes to show I know almost nothing about the shell I use every day.

~~~
kranner
Yes but I use the default bash, as do probably most OS X users.

------
gotofritz
Also worth mentioning is dotfiles (not specific to OS X). Basically various
well known "power users" share their bash, homebrew, etc settings on github so
that they can easily set up a new machine with minimum of fuss. There are a
lot of neat trick in those boilerplate files.

[http://dotfiles.github.io/](http://dotfiles.github.io/)

------
nicksergeant
Why the hell would someone change the title from "Eight Terminal Utilities
Every OS X Command Line User Should Know" to "OS X Command Line Utilities".

The original title is clearly more accurate / useful / canonical. The
overwritten title is ambiguous. This is indeed not a list of every OS X
command line utility.

~~~
dang
I changed it. The HN guidelines call for taking linkbait out of titles ("every
user should know") and for not having arbitrary numbers in titles—which are
also a form of linkbait. Taking those things out as well as the redundancies
(terminal/command-line, utilities/users) yields something pretty close to "OS
X Command Line Utilities".

I don't see any ambiguity. The article is precisely about OS X Command Line
Utilities; it doesn't matter how many there are in the list. Nor is it
misleading. There's no implication of completeness.

------
mmaldacker
no love for macport?

~~~
archagon
My understanding is that macports is a lot more finicky and hacky, especially
when it comes to built-in dependencies. homebrew is specifically designed to
avoid such problems.

~~~
twic
My understanding is quite the opposite. There are a number of trivial
differences between MacPorts and Homebrew - for example, MacPorts recipes are
written in Tcl, Homebrew's are written in Ruby, MacPorts puts things in
/opt/local, Homebrew puts things in /usr/local/Cellar, MacPorts gets its
metadata with rsync, Homebrew uses Git. But there is, as far as i know, only
one non-trivial difference: MacPorts links everything against versions of
libraries that it has installed, whereas Homebrew links them against the ones
supplied by Apple.

The Homebrew maintainers think that linking against Apple's libraries is
better, because you need to install less stuff.

The MacPorts maintainers used to agree, several years ago, and used to do just
that. Then, Apple released a software update which changed some libraries and
broke everyone's MacPorts installations. So then they changed their mind. Now,
they think that linking against their own, coherently managed, set of
libraries is better, because Apple can't break stuff.

To me, Homebrew just looks like an exercise in reproducing others' work
without learning from their experiences. I don't see any advantages to it
myself.

Less fundamentally, there's also quite a difference in the number of packages.
MacPorts's homepage indicates that they have 18530 ports. An ls|wc in
Homebrew's repository indicates that they have 2802 formulae. That said, i
suspect that 95% of what people actually need is in the collection that
Homebrew has.

~~~
filmgirlcw
I don't think Homebrew was so much reinventing the wheel, as it was trying to
create a modern replacement in an era when MacPorts/DarwinPorts was stagnate
and Fink was in a similar state of upheaval.

I remember having issues getting Fink and MacPorts to run correctly in the
early days of Snow Leopard, which was frustrating if you needed a library.
Homebrew came in, was easier to install and had less legacy code issues.

As for tbe package counts, I'd say _most_ of those packages are probably
relics from the PPC days. I was hesitant to switch to Homebrew, but in really
do think it has a better implementation.

I did try MacPorts for the first time in over a year on a new system recently,
and it has improved dramatically.

But really, package management systems are all about reinventing the wheel.
I'm glad both projects are active.

------
vladharbuz
The screencapture options are wrong.

    
    
        "Select a window using your mouse, then capture its contents without the window’s drop shadow and copy the image to the clipboard:
    
        $ screencapture -c W"
    

-c captures the cursor, W is not an option. The real command for this is:
    
    
        $ screencapture -C -o

~~~
mitchchn
It was a typo, but it was supposed to be the -W flag not -o. Fixed now.

------
salgernon
pbpaste and pbcopy can specify multiple clipboards; one very handy thing I do
is

"cmd-a" "cmd-c" (copy all)

double click on a word I'm looking for, "cmd-e" to enter it into the find
clipboard

'pbpaste | fgrep --color `pbpaste -pboard find`'

I have that aliased as 'pbg'.

~~~
archagon
Aaaaand I just learned about Cmd-E and Cmd-J. Love all the little useful
shortcuts OSX has. :)

------
stretchwithme
The hot keys for screen capture are more useful for daily use. You can paste
what you've capture directly into most email clients. Or go to Preview where
creating a new file uses what's on your clipboard if its an image.

------
fuzzywalrus
Notably the screen capture terminal command, while neat, is sold as "more
flexible". I think the author is unaware of Command+shift+4 followed by
tapping the spacebar. It'll give you the window capture.

Otherwise good article.

~~~
wilmoore
If you have Cloudup installed, that command sequence will also upload the
screenshot automatically.

[https://cloudup.com/about](https://cloudup.com/about)

------
chrismorgan
I don’t use a Mac, but have used espeak-via-ssh to deliver a message to my
sister who was near my laptop, from the comfort of my bed… I could have (a)
called out, or (b) gotten up, but where would the fun have been in that?

------
chrisBob
The biggest change I have found for my terminal was adding this to my
.bash_profile:

export CLICOLOR=1

export LSCOLORS=GxFxCxDxBxegedabagaced

I thought that was one of the most amazing things when I used a linux system,
but OS X is black and white by default.

~~~
tvon
`ls -G` will show colors with BSD ls, much like `ls --color' with GNU ls.

------
nemasu
This is neat. I'll be getting a mac soon, and this is right up my ally.

------
huskyr
Awesome. I knew about `pbcopy`, but i never knew you could also pipe stuff
into it. That saves a lot of time saving script outputs to temporary text
files and copying!

~~~
Touche
alias copyssh="cat ~/.ssh/id_rsa.pub | pbcopy"

~~~
theOnliest
Or without the extraneous cat: "pbcopy < ~/.ssh/id_rsa.pub"

~~~
Touche
Ah yes, thanks, I always forget about <

------
RexRollman
Personally, I was surprised that there is not a command line interface to OS
X's Notification system. Seems like it would be handy for long running batch
jobs.

~~~
pdx6
Install this:

[https://github.com/alloy/terminal-
notifier](https://github.com/alloy/terminal-notifier)

Add this to your .bashrc:

function notify { terminal-notifier -title "$1" -message "$2" }

~~~
RexRollman
Interest. Thank you.

------
guard-of-terra
I wonder if it's possible to make OS X to say "As you request, Stan" in Lexx's
voice.

That alone might be sufficient reason to migrate from ubuntu.

~~~
cerberusss
+1 for the reference!

------
fmela
The '-name' argument of mdfind makes it useful to find files with the query
string in the name. E.g.: "$ mdfind -name resume".

------
conradev
The one utility I can't live without is caffeinate, which prevents a Mac from
sleeping.

It's super useful for keeping long running tasks running.

~~~
veidr
Why not just disable sleep? I only ever sleep my Macs manually (if ever).

~~~
gotofritz
it's useful to be able to switch between the two without having to open up the
preferences

------
cormullion
If you work with images a lot, look up sips. I use it a lot, for converting
images, rescaling and resizing, etc.

------
lastofus
The article doesn't mention the fun you can have with ssh + say.

My co-workers and I used to ssh into the iMacs of non-technical users in our
office and have a good laugh from a nearby room.

~~~
mitchchn
It does mention that. Read again :)

------
hackeroni
Thanks for sharing

