-
-
Save jcanfield/ff4f084c9104ff281988d8f519421bce 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 hidden or 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