Skip to content

Instantly share code, notes, and snippets.

@hashworks
Created November 6, 2020 17:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hashworks/6d6e4eae8984a5018f7692a796d570b4 to your computer and use it in GitHub Desktop.
Save hashworks/6d6e4eae8984a5018f7692a796d570b4 to your computer and use it in GitHub Desktop.
BASH function for kutt.it URL shortener services
KUTT_HOST="https://kutt.it"
KUTT_API_KEY="API_KEY"
kutt() {
if [[ "$1" == "delete" ]] && [[ -n "$2" ]]; then
curl -s -H "X-API-KEY: $KUTT_API_KEY" \
-X DELETE \
"$KUTT_HOST/api/v2/links/$2" | jq
elif [[ -z "$1" ]]; then
curl -s -H "X-API-KEY: $KUTT_API_KEY" \
"$KUTT_HOST/api/v2/links" | jq
elif [[ "$1" != "help" ]] && [[ "$1" != "--help" ]]; then
curl -s -H "X-API-KEY: $KUTT_API_KEY" \
-H "Content-Type: application/json" \
--data "{
\"target\": \"$1\",
\"password\": \"$2\",
\"expire_in\": \"$3\",
\"description\": \"$4\"
}" \
"$KUTT_HOST/api/v2/links" | jq
else
echo "kutt"
echo "kutt help"
echo "kutt <target-url> [<password> <expire_in> <description>]"
echo "kutt delete <uuid>"
return 2
fi
}
@fabianski7
Copy link

curl -s -H "X-API-KEY: $KUTT_API_KEY" \
			-H "Content-Type: application/json" \
			--data "{
				\"target\": \"$1\",
				\"password\": \"$2\",
				\"expire_in\": \"$3\",
				\"description\": \"$4\",
				\"domain\": \"your-custom-domain.tld\"
			}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment