Some GUI apps use OS X location services, but I want to retrieve a Mac's physical location from the command line. This could be useful for running scripts, switching settings etc. The mechanism should be CoreLocation, not a Geo IP service (data too low-res, needs online connection).

Minimum requirement is output of longitude and latitude. Nice would be a number indicating the precision. Super nice: a geocoder that provides location names.

Please do not include answers directly in the question, it tends to confuse people and makes it rather difficult to understand what the question actually is. If you want to add sample output to the different solutions offered you can do so directly by editing the answers.
–
patrix♦Dec 17 '14 at 13:34

5 Answers
5

A simple command line tool. No options, just runs and outputs Lat/Long, accuracy in meters, and a timestamp. It will need OS X Location Services to be turned on (System Preferences > Security & Privacy), and permission to gather your location (OS X will prompt you on first run).

I'm the author of LocateMe, and I just discovered that I have to copy LocateMe into the /Applications folder for it to work in Mountain Lion. I'm not sure what I'd have to do to avoid that -- probably something about getting a cert, which I'm not likely to pursue anytime soon.

In the meantime, for LocateMe and probably the others, try copying them to /Applications and see if you have better luck.

Also, it now supports --once if you are only looking for a single output, rather than continuous output.

Lastly, there is a full binary on the project page as well if you would rather not compile it yourself. You will still need to authorize ("Would you like this app to be able to access your location") on the first app run.