Created
November 6, 2020 17:25
-
-
Save hashworks/6d6e4eae8984a5018f7692a796d570b4 to your computer and use it in GitHub Desktop.
BASH function for kutt.it URL shortener services
This file contains 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
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 | |
} |
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
kutt "https://github.com"
kutt
kutt delete accefebc-f139-4f08-8b6a-e45b89ce0873