Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
CLI script to copy a file to the user's public DropBox folder and put a shortened public link in the clipboard. Inspired by @matthewmccullough and @tlberglund
#! /usr/bin/env bash
# $1 file to share
db_home=$HOME/DropBox # You need to run the DropBox client on your workstation
db_id=<999999> #Put your Dropbox ID here
if [[ -f "$1" ]] ; then
cp "$1" $db_home/Public #Only works if you have an Old Style account with magic Public directory
curl \
-H 'Content-Type: application/json' \
-d '{"longUrl": "'$db_id/$(echo "${1##*/}"| gsed -e 's/ /%20/g')'"}' 2>/dev/null |
gsed -ne 's/^ *"id": "\([^"]\+\)".*$/\1/p' |pbcopy
echo $(pbpaste)
echo no valid source file "$1" found

This comment has been minimized.

Copy link
Owner Author

@alecthegeek alecthegeek commented Jul 24, 2014

This works for me. If you have problems let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment