Script to replace URL in clipboard with a shorter one using zws.im, probably assign a keyboard shortcut to run this script.
original=`xclip -o -sel clipboard` | |
if [[ $original == https://zws.im* ]]; then | |
notify-send "Already shortened" --icon=gtk-edit | |
exit 1; | |
fi | |
json=$(curl -s "https://us-central1-zero-width-shortener.cloudfunctions.net/shortenURL?url=$original") | |
if [ $? -eq 0 ]; then | |
short="https://zws.im/$(echo $json | jq -jr '.short')" | |
if [ $? -eq 0 ]; then | |
printf $short | xclip -sel clip | |
notify-send "Link shortened" --icon=stock_cut | |
else | |
notify-send "Shortening failed" --icon=gtk-quit | |
fi | |
else | |
notify-send "Shortening failed" --icon=gtk-quit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment