Friday, September 09, 2016

Pastebin and the Command Line - Clipboard Access Anywhere

A couple of days ago, I setup my phone to push the clipboard to automatically. Now I wanted an easy way to access these pastes from the command line. Fortunately, the pastebin API is a breeze to use, and quite curl friendly.

Here's a shell script that pulls down the most recent paste:


## A command line tool to pull pastes from


ids() {
  curl -s -d api_option=list \
       -d api_user_key=$USER_KEY \
       -d api_dev_key=$API_KEY \
       -d api_results_limit=$count \
       '' | 
    grep paste_key |
    sed -e 's|<paste_key>||' -e 's|</paste_key>||'  

for id in `ids` ; do
   id=`echo $id | tr -d '[\r\n]'`
   curl -s$id

On Windows, I can leverage clip.exe to store the output of the most recent paste into the clipboard.

  pbget | clip

Getting content from my phone's clipboard to my Desktop's clipboard is now nearly automatic, and thanks to is archived for 24 hours. And as a bonus, I'm not limited to accessing the phone's clipboard from a local computer. Any server with curl and a net connection can now get quick access to my phone's clipboard.

No comments:

Post a Comment


Related Posts with Thumbnails