jcanfield
7/31/2013 - 10:27 PM

Bash function to use the goo.gl URL shortener on stdin. See <https://developers.google.com/url-shortener/v1/getting_started> TODO: pbc

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

# 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
    )
}