Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created July 2, 2014 16:08
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ttscoff/76e5d7efb60d7ac04350 to your computer and use it in GitHub Desktop.
Save ttscoff/76e5d7efb60d7ac04350 to your computer and use it in GitHub Desktop.
Uses get-location/CoreLocation on a Mac and Google's geocoding API to tell you the street address of your current location
#!/bin/bash
# So you know whoami, but whereami?
# Relies on this handy hack <https://github.com/lindes/get-location>
latlong=$(/usr/local/bin/get-location 2> /dev/null \
| sed -e 's/.*<\(.*\)>.*/\1/')
address=$(curl -Ss "http://maps.googleapis.com/maps/api/geocode/json?latlng=$latlong&sensor=false" \
| grep formatted_address \
| head -n 1 \
| sed -e 's/[ \t]*"formatted_address" : "\(.*\)",/\1/')
echo "You're at $address"
@ttscoff
Copy link
Author

ttscoff commented Jul 2, 2014

You'll need get-location (and the Command Line Tools to compile it) to make this work. It's cool when it does, though.

@sjsyrek
Copy link

sjsyrek commented Jul 8, 2014

Installed. A little slow and slightly off, but I only have 2 GB of RAM on this 2009 MBA, and I live in Manhattan. Got this output (with numbers X'ed out):

You're at "formatted_address" : "XX West XXth Street, New York, NY XXXXX, USA",

Is that correct? Seems somewhat contrary to your intentions. Thanks for the neat tool, though!

@CameronBanga
Copy link

@ttscoff get-location seems to not work on Yosemite. Not expecting compatibility at this point, and it's not even a tool you wrote, but any suggestions? Seems like a fun script.

@ttscoff
Copy link
Author

ttscoff commented Jul 27, 2014

@sjsyrek must be a difference in the output for you. I just did a quick regex with sed based on the only address I was working with. I'll try and test with some other output.

@CameronBangs I haven't tried it, but it can't be too tough to fix. CoreLocation still exists and it's not a complex program. Maybe @lindes will have a chance to take a look before the release…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment