Skip to content

Instantly share code, notes, and snippets.

@kotnik
Created April 8, 2013 14:49
Show Gist options
  • Save kotnik/5337349 to your computer and use it in GitHub Desktop.
Save kotnik/5337349 to your computer and use it in GitHub Desktop.
Self-hosted pastebin. Pipe code/text to be automatically uploaded to your server for sharing.
#!/bin/bash
USER=YOUR_USERNAME
HOST=YOUR_SERVER_HOSTNAME
WEBPATH=PATH_TO_WEBSERVER_ROOT
WEBURL=YOUR_URL
BACKUP_DIR=DIR_FOR_BACKUP
file=$(mktemp $BACKUP_DIR/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} $USER@$HOST:$WEBPATH
echo "http://$WEBURL/${file##*/}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment