Created
February 18, 2015 22:43
-
-
Save landswellsong/0d109949ae91f04869bd to your computer and use it in GitHub Desktop.
Clipboard to DPaste
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
#!/bin/sh | |
# Use this to paste the contents of your clipboard to dpaste | |
# Requires curl and xclip, pushing notifications requires libnotify | |
# TODO: some kind of GUI dialog allowing to select highlighting language probably? | |
CLIP_TARGET="clipboard" # Target clipboard to use -selection option to xclip, see man 1 xclip for usage | |
EXPIRY="days=1" # Expiration time, see dpaste API for options | |
POSTER="$USER" # Poster identification, username by default | |
# Image for notification, feel free to pick an icon" | |
NOTIFY_IMAGE="/usr/share/icons/oxygen/64x64/mimetypes/text-enriched.png" | |
URL=$(xclip -o -selection $CLIP_TARGET | curl -s -F "expiry_$EXPIRY" -F "poster=$POSTER" -F "content=<-" http://dpaste.com/api/v2/) | |
echo "$URL" | xclip -selection $CLIP_TARGET | |
# Comment the following if you don't want notifications | |
notify-send -i "$NOTIFY_IMAGE" \ | |
"Clipboard dpasted" \ | |
"$URL" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment