Bash functions for posting to blosxom from the command line
Here are those two bash functions I use at work to make my blosxom blog into a daily time log. I made them because I wanted to be able to dash off a one-liner entry into a logfile that would be easily viewable later. So, here they are:
-
Timelog function
- Make a single line entry in a post for the current day. If there’s no post yet for today, it makes that new post.
tl () { timelog_file="$HOME/blosxom/timelog/$(date +%Y-%m-%d).txt" [[ ! -f $timelog_file ]] && echo Timelog for $(date "+%A %F") >> $timelog_file time=$(date +%H:%M) [[ $# -eq 0 ]] && msg=$(cat) [[ $# -gt 0 ]] && msg="$*" echo "<li>$time $msg</li>" >> $timelog_file }
-
Note function
- Let’s me make a very simple post to my blog from the command line. I type “note” followed by the title of the note and then press enter. From then on until I press CTRL-D, I’m composing my entry. After I press CTRL-D, the note is posted.
note () { if [[ $# -eq 0 ]] then echo "Need file name on CL" return fi filename="$HOME/blosxom/notes/$*.txt" if [[ -f $filename ]] then echo Extant post file return fi cat > "$filename" }