Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created July 2, 2014 16:08
Show Gist options
  • 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 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