One command I can't live without: textutil.<p>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 <i>vastly</i> better than the bloated crap that comes out of Microsoft Word or LibreOffice when you save as HTML ...<p>Install pandoc and multimarkdown as well and you've got the three pillars of a powerful, easy-to-use multiformat text processing system.
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.
I didn't know about `screencapture`. That's a fun one.<p>The Linux equivalent of `open` is `xdg-open`. I usually alias it to `op`, since `/bin/open` exists.<p>Another bit of terminal-sugar for OS X users:<p><pre><code> alias lock='/System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend'
</code></pre>
And most Linux users:<p><pre><code> alias lock='gnome-screensaver-command -l'
</code></pre>
If you find yourself accidentally triggering hot corners, the lock command is your savior.<p>I've sorta-documented this stuff over the years, but only for my own memory. <a href="https://gist.github.com/ggreer/3251885" rel="nofollow">https://gist.github.com/ggreer/3251885</a> 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.
These are awesome. I didn't know about many of them.<p>One tiny thing though, at the bottom it says<p>> 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.<p>Actually, you can launch them in other ways. Example<p><pre><code> /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir=/Users/<username>/temp/delmechrome --no-first-run
</code></pre>
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.
Another one that I can't live without:<p><pre><code> ssh-add -k keyfile
</code></pre>
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.<p>That and some of the examples in that article really make it a killer platform for Unix bits.
'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.<p>I wrote related rant once[0] when I tried to debug an issue of a misconfigured default browser.<p>[0]: <a href="http://f5n.org/blog/2013/default-browser-linux/" rel="nofollow">http://f5n.org/blog/2013/default-browser-linux/</a>
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.
/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.<p>I like the way Fink [1] uses the /sw (software) directory.<p>Does anyone have a valuable opinion on the comparison between Fink and Homebrew — or maybe MacPorts?<p>[1] <a href="http://www.finkproject.org" rel="nofollow">http://www.finkproject.org</a>
9. /usr/sbin/system_profiler<p>10. /System/Library/CoreServices/Applications/Wireless Diagnostics (with built-in wifi stumbler)<p>11. /System/Library/CoreServices/Screen Sharing.app (Built-in VNC client with hardware acceleration)<p>12. /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources (Command-line wifi configuration and monitoring tool)<p>Combine with sed, awk, and cut, and these tools can provide useful monitoring.
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: <a href="http://tiswww.case.edu/php/chet/readline/rluserman.html#SEC3" rel="nofollow">http://tiswww.case.edu/php/chet/readline/rluserman.html#SEC3</a>
mdfind / Spotlight can be a fairly powerful tool. Consider this query, which finds all Xcode projects I've tagged as "Active":<p><pre><code> ~$ mdfind tag:Active kind:xcode
/Users/jn/Code/xyz/xyz.xcodeproj
...
</code></pre>
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.
Put this in your path somewhere, find files, links, directories instantly, with globbing. Makes mdfind actually useful.<p><pre><code> $ mdf "*invoice*.pdf"
/Users/smw/Downloads/Invoice-0000006.pdf
</code></pre>
<a href="https://gist.github.com/smw/a21a9f675ed3358830da" rel="nofollow">https://gist.github.com/smw/a21a9f675ed3358830da</a>
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.<p>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.
After years of living on the command line, OS X specifically, and learning its quirks and tricks, I am actually ready to move on.<p>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.<p>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.
Additions:<p>* lunchy: wrapper over launchctl, written in Ruby – <a href="https://github.com/mperham/lunchy" rel="nofollow">https://github.com/mperham/lunchy</a><p>* brew cask: "«To install, drag this icon...» no more", as they say – <a href="https://github.com/caskroom/homebrew-cask" rel="nofollow">https://github.com/caskroom/homebrew-cask</a><p>* have fun with "say" – <a href="https://github.com/andreis/different" rel="nofollow">https://github.com/andreis/different</a>
There's been a few of these lists over the past few years, most recent one is <a href="https://news.ycombinator.com/item?id=7494100" rel="nofollow">https://news.ycombinator.com/item?id=7494100</a><p>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.
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. <a href="https://gist.github.com/jpb0104/1051544" rel="nofollow">https://gist.github.com/jpb0104/1051544</a>
Great list! Includes all the old favorites with clear explanations.<p>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! <a href="http://cl.ly/1a3s3g1u2Q2w" rel="nofollow">http://cl.ly/1a3s3g1u2Q2w</a>
If you do Go development, you can do this to quickly get to root folder of any Go package:<p><pre><code> function gocd {
cd `go list -f '{{.Dir}}' $1`
}
</code></pre>
It uses the same syntax as go list to specify packages, so you can do, e.g.:<p><pre><code> ~ $ gocd .../markdownfmt
markdownfmt $ pwd
/Users/Dmitri/Dropbox/Work/2013/GoLand/src/github.com/shurcooL/markdownfmt
markdownfmt $ _
</code></pre>
So nice.
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.<p><pre><code> ssh somehost
cd /some/dir
grep -lr foo . | remote_pbcopy
</code></pre>
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.
Two more for you:<p>sips - <a href="https://developer.apple.com/library/Mac/documentation/Darwin/Reference/ManPages/man1/sips.1.html" rel="nofollow">https://developer.apple.com/library/Mac/documentation/Darwin...</a><p>osascript - <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/osascript.1.html" rel="nofollow">https://developer.apple.com/library/mac/documentation/Darwin...</a>
It seems odd to have<p><pre><code> open /Applications/Safari.app/
</code></pre>
as an example, when<p><pre><code> open -a safari
</code></pre>
does the same thing.
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.<p><a href="http://dotfiles.github.io/" rel="nofollow">http://dotfiles.github.io/</a>
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".<p>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.
The screencapture options are wrong.<p><pre><code> "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"
</code></pre>
-c captures the cursor, W is not an option. The real command for this is:<p><pre><code> $ screencapture -C -o</code></pre>
pbpaste and pbcopy can specify multiple clipboards; one very handy thing I do is<p>"cmd-a" "cmd-c" (copy all)<p>double click on a word I'm looking for, "cmd-e" to enter it into the find clipboard<p>'pbpaste | fgrep --color `pbpaste -pboard find`'<p>I have that aliased as 'pbg'.
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.
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.<p>Otherwise good article.
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?
The biggest change I have found for my terminal was adding this to my .bash_profile:<p>export CLICOLOR=1<p>export LSCOLORS=GxFxCxDxBxegedabagaced<p>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.
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!
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.
I wonder if it's possible to make OS X to say "As you request, Stan" in Lexx's voice.<p>That alone might be sufficient reason to migrate from ubuntu.
The one utility I can't live without is caffeinate, which prevents a Mac from sleeping.<p>It's super useful for keeping long running tasks running.
The article doesn't mention the fun you can have with ssh + say.<p>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.