Skip to content

Instantly share code, notes, and snippets.

@MellonQ MellonQ/j2b.sh
Last active Aug 29, 2015

Embed
What would you like to do?
#! /bin/bash
# Requirements:
# http://code.google.com/p/googlecl/ - CLI tool for google services.
# http://stedolan.github.com/jq/ - lightweight and flexible command-line JSON processor
# Change dir to stored messages. Use https://gist.github.com/borman/8771803
cd ~/UserName/
# Make some dirs
mkdir /tmp/j2b.posts/
mkdir /tmp/j2b.trash
for i in $(ls -1 | sort -ug); do
echo "$i:"
jq -r ".[0]|.timestamp,.tags,.body" "$i"
echo "~~~~~~~~~~~~"
echo
echo "Do you want to post this shit?"
read k
if [ -n "$k" ]; then
echo "K, let me to post it."
TMPFILE="$(mktemp -p /tmp/ j2b.XXXX)"
jq -r -M '.[0]|.body' "$i" > "$TMPFILE"
google blogger post --title "$(jq -r -M '.[0]|.timestamp' $i)" --tag "$(jq -c -M '.[0]|.tags' $i | sed s/'\['// | sed s/'\]'// | sed s/'"'//g)" "$TMPFILE"
rm "$TMPFILE"
mv "$i" /tmp/j2b.posts/
else
echo "Yay! World is so wonderful without your shit!"
mv "$i" /tmp/j2b.trash
fi
echo "================================================"
done
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.