Skip to content

Commit

Permalink
added functions.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
gleicon committed Jan 19, 2013
1 parent a6e035e commit 87c51c3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions functions.sh
@@ -0,0 +1,18 @@
pasteit_post=http://p.chu.pe/pasteit
pasteit_get=http://p.chu.pe/raw

function xpbcopy() {
tmp=/tmp/xpbcopy.$$
trap "rm -f ${tmp}" EXIT
echo -n "raw=1&codebody=" > $tmp
IFS=$"\n" cat "${1:-/dev/stdin}" >> $tmp
if [[ -x `which curl` ]]; then curl --data-binary @${tmp} ${pasteit_post}
elif [[ -x `which wget` ]]; then wget --post-file=${tmp} -qO- ${pbserver}
else echo "xpbcopy requires curl or wget"; exit 1; fi
}

function xpbpaste() {
if [[ -x `which curl` ]]; then curl ${pasteit_get}/$1
elif [[ -x `which wget` ]]; then wget -qO- ${pbserver}/$1
else echo "xpbpaste requires curl or wget"; exit 1; fi
}

0 comments on commit 87c51c3

Please sign in to comment.