Skip to content

Instantly share code, notes, and snippets.

@Tomin1
Created December 25, 2014 21:24
Show Gist options
  • Select an option

  • Save Tomin1/902513592cc9c103bc3f to your computer and use it in GitHub Desktop.

Select an option

Save Tomin1/902513592cc9c103bc3f to your computer and use it in GitHub Desktop.
#!/bin/sh
# This script is made by Tomi Leppänen aka Tomin (http://tomin.dy.fi/)
# You are free to use, copy, redistribute and modify this script
# as long as you accept that ***I won't take any responsibility
# for this code and it comes without any warranty***
# This script works as pastebincl would but it takes the URL from
# the output of pastebincl and pastes it to clipboard.
# It is recommended to alias this script to some better name
# Clipboard to use, values: 'clipboard' for keyboard,
# and 'primary' for mouse-middle-click
# or 'both' for both of them
CLIPBOARD='primary'
# Check depenciens
if [ -z `which pastebincl` 2> /dev/null ]
then echo "Pastebincl is requred! Install pastebincl"
exit
fi
if [ -z `which xclip` 2> /dev/null ]
then echo "Xclip is required! Install xclip"
exit
fi
if [ -z `which grep` 2> /dev/null ]
then echo "Grep is required! Install grep"
exit
fi
if [ -z `which sed` 2> /dev/null ]
then echo "Sed is required! Install sed"
exit
fi
URL=$(pastebincl $@ < /dev/stdin |grep URL |sed 's/URL: //' )
# The code
if [ $CLIPBOARD == "both" ]; then
echo -n "$URL" |xclip -selection clipboard
echo -n "$URL" |xclip -selection primary
else
echo -n "$URL" |xclip -selection $CLIPBOARD
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment