Skip to content

Instantly share code, notes, and snippets.

@ralt
Last active August 31, 2016 12:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ralt/bf35fdd8e133774fa83e to your computer and use it in GitHub Desktop.
Save ralt/bf35fdd8e133774fa83e to your computer and use it in GitHub Desktop.
putfile & pastebin
#!/bin/bash
SSH_FOLDER=foo@bar.com:www/
BASE_URL=http://bin.foo.com/
PASTE_FOLDER=~/.pastes/
file=$(mktemp ${PASTE_FOLDER}XXXXXX)
mv $file $file.html
file="$file.html"
chmod 644 ${file}
[[ ! -z "$1" ]] && lang="-s $1"
cat - > ${file}.in
source-highlight -i ${file}.in -o ${file} ${lang}
rm ${file}.in
scp -q -o "LogLevel quiet" ${file} $SSH_FOLDER
echo -n "$BASE_URL${file##*/}" | xclip -f -selection clipboard
echo
#!/bin/bash
SSH_FOLDER=foo@bar.com:www/
BASE_URL=http://bin.foo.com/
if [[ -z "$1" ]]; then
echo "Need filename"
exit 1
fi
file_ext=$(echo $1 |awk -F . '{if (NF>1) {print $NF}}')
if [ -z "$file_ext" ]; then
file_ext="txt"
fi
file=$(mktemp /tmp/XXXXXX.$file_ext)
cp "$1" $file
chmod 644 $file
scp -q -o "LogLevel quiet" "$file" $SSH_FOLDER
echo -n "$BASE_URL$(basename $file)" | xclip -f -selection clipboard
echo
@ralt
Copy link
Author

ralt commented Aug 26, 2015

Depends on: scp, source-highlight, xclip

Puts a source highlighted file or a file (e.g. an image) on your hosting platform of your choice. Puts the resulting url in the clipboard.

Example usage:

$ echo 'hi' | pastebin
https://bin.foo/jfDj9E.html
$ pastebin
long
output
to
share
^D
https://bin.foo/ruEr8T.html
$ putfile ~/bin/pastebin
https://bin.foo/kdwE43.txt

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