Live data from Hacker News

OS X Command Line Utilities

mitchchn.me

21–30 of 243 posts

Re: OS X Command Line Utilities

#21

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.

It's nice to alias them to something shorter. Mine are set to "pd" and "qd".

Re: OS X Command Line Utilities

#22
post #12

/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

Homebrew actually uses /usr/local/Cellar for all its installations, and then makes symlinks in the relevant /usr/local/{bin,sbin} directories. Not sure if that's what you meant.

Re: OS X Command Line Utilities

#24
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//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.

Re: OS X Command Line Utilities

#26
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?

Re: OS X Command Line Utilities

#27
post #8

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!…

Definitely useful. Thanks !

Re: OS X Command Line Utilities

#28

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.

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

Re: OS X Command Line Utilities

#29

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=/Us…

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.

Re: OS X Command Line Utilities

#30
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.

Post reply on HN