Created
July 2, 2014 16:08
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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…