Skip to content

Instantly share code, notes, and snippets.

@ralt ralt/pastebin.sh

Last active Aug 31, 2016
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.