There are many services you can use to make long url's a bit friendly, but all work the same, you need to open your browser point to the selected service and post your url on a form to get a shortener version.
But we can learn how to use different osx tools to access this services and parse the response. First using terminal script, the main idea is using "curl", a standard program included on every unix distro to make an http request, then copy the result to the clipboard.