Skip to content

Instantly share code, notes, and snippets.

@joshmanders
Created August 2, 2016 15:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshmanders/1f6fae94b36d108b442c04155c016b94 to your computer and use it in GitHub Desktop.
Save joshmanders/1f6fae94b36d108b442c04155c016b94 to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
# Usage: git-io URL [CODE]
#
# Turns a github.com URL
# into a git.io URL
URL="$1"
CODE="$2"
SHORT_URL=$(curl -si https://git.io -F "url=${URL}" ${CODE:+-F "code=${CODE}"} | grep 'Location:' | sed 's/Location: //')
echo "Copied URL to clipboard."
echo "${SHORT_URL}" | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment