Last active
August 31, 2016 12:33
-
-
Save ralt/bf35fdd8e133774fa83e to your computer and use it in GitHub Desktop.
putfile & pastebin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
[email protected]: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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
[email protected]: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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
$ putfile ~/bin/pastebin https://bin.foo/kdwE43.txt