Created
July 31, 2013 22:27
-
-
Save trentm/6126755 to your computer and use it in GitHub Desktop.
Bash function to use the goo.gl URL shortener on stdin. See <https://developers.google.com/url-shortener/v1/getting_started> TODO: pbcopy it too if that command is available
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
# echo URL | googl | |
function googl { | |
local url=$(cat <&0) | |
( | |
set -e pipefail; | |
echo "{}" \ | |
| json -e "this.longUrl='$url'" \ | |
| curl -sf https://www.googleapis.com/urlshortener/v1/url \ | |
-H 'Content-Type: application/json' -d@- \ | |
| json id | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment