Table of Contents
dreamlog
A dreamlog management system written in bash.
I've decided to start writing down my dreams when I wake up. This is recommended if you want to remember your dreams, and, especially, if you want to try lucid dreaming1), dreaming with awareness that you are dreaming (which can even give one the ability to control one’s dreams, and, thus, do fun stuff, like make a plate of bacon appear, or fly, or something).. I keep a laptop next to the bed, but ssh into my main box where I keep this script (or get up and walk to the office…like 4 steps from my bedroom door).
#!/bin/bash ################################# # dreamlog - by tony baldwin # # http://tonybaldwin.me # # keeping a log of dreams # # released according to GPL v.3 # ################################ source ~/.dreamlog.conf cd ~/.dreamlog filedate=$(date +%Y%m%d%H%M%S) if [[ $1 = r ]]; then if [[ $2 ]]; then cat $2* | less else for i in $(ls -Rt *.dream); do cat $i; done | less fi else if [[ $1 = e ]]; then $editor $2 else if [[ $1 = v ]]; then less $2 else if [[ $1 = h ]]; then echo "dreamlog - opens a new dreamlog file to edit in your chosen editor. dreamlog r - reads all entries (cats all files in the dir, pipes to less) dreamlog r yyyymmdd - reads entries from date yyyymmdd. One can specify just yyyymm, or just yyyy, even. dreamlog l - lists all dreamlog entries. Like r, it can be narrowed down with date parameters. dreamlog e filename - opens dreamlog file filename for editing. dreamlog v filename - opens dreamlog file filename for viewing. dreamlog s searchterm - searches for searchterm in dream entries. dreamlog h - displays this help message. dreamlog management system by tony baldwin, http://tonybaldwin.me, released according to GPL v. 3" else if [[ $1 = l ]]; then if [[ $2 ]]; then ls -1t | grep $2 else ls -1t fi else if [[ $1 = s ]]; then cd /.dreamlog grep -iw $2 * else date=$(date) echo -e "\n$date\n\nWRITE HERE\n\n-----------\n" >> $filedate.dream $editor $filedate.dream fi fi fi fi fi fi # This program was written by anthony baldwin - tony@tonybaldwin.org # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. exit
Installation and Use
Run the install.sh
Writing Entries
When I run “dreamlog” (script with no other variable), it creates a new file with the yyyymmddhhmmss.dream (so, right now, this would be 20121110122623.dream), and opens it for editing in vim (yes, you can substitute your favorite editor, emacs, nano, whatever, or just $EDITOR).
I'm in the habit of doing :r !date (gives something like “Sat Nov 10 15:49:38 EST 2012”) at the beginning of entries and drawing a line at the end (—-), which facilitates reading them with the “r” option (see below), but you can head/tail them however you like.
Reading the DreamLog
If I do “dreamlog r” (read dreamlog), it cats every file in the directory and pipes it to less, in reverse chronological order, newest to oldest, like any normal blog. To read an entry from a specific date, or entries from a specific time period, “dreamlog r $filedate” where $filedate would just be any date parameter, such as all for a year “yyyy”, all for a month “yyyymm”, or even to grab a specific day “yyyymmdd”, i.e., for, say, 10 November 2012, one would just do “dreamlog r 20121110”.
Listing Entries
If I do “dreamlog l” (list dreamlog entries), it lists all files in that directory. Like the “r” option, one can narrow down the listings to a specific period, such as “dreamlog l 201209″ to list only entries from September, 2012, for instance.
Searching in Entries
To search for a word in the entries, do “dreamlog s $searchterm”.
Posting to Friendica Dreams Group
We have a Friendica group at dream@free-haven.org for posting and discussing dreams. I decided this script needed a “friendica plugin”, so, I've added this following little tidbit (at line 42, after vim ~/.dreamlog/$filename.dream) which allows me to optionally post the dream entry to said group, if I choose:
read -p "Post to Dreams group on free-haven? (y/n) " post if [[ $post = y ]]; then echo -d "#dream @dreams\nposted with dreamlog - http://tonyb.us/dreams\n" >> ~/.dreamlog/$filedate.dream ud="$(cat ~/.dreamlog/$filedate.dream)" read -p "Privately, as in ONLY to the group? " priv if [[ $priv = y ]]; then if [[ $(curl --ssl -u USERNAME:PASSWORD -d "status=$ud&source=dreamlog&contact_allow=5284" https://free-haven.org/api/statuses/update.xml | grep error) ]]; then echo "Error!" else echo "Success!" fi else if [[ $(curl --ssl -u USERNAME:PASSWORD -d "status=$ud&source=dreamlog" https://free-haven.org/api/statuses/update.xml | grep error) ]]; then echo "Error!" else echo "Success!" fi fi fi
It asks, of course, and if I respond with “y”, it sends the content of the entry to my profile and the group. It also asks if I want to make the post private, as in only posted to the group, not my public timeline, which I think is a good option.
Oh, and, of course, you have to change USERNAME:PASSWORD to YOUR username and password.
Links
- get it on github: https://github.com/tonybaldwin/dreamlog
- download this script: http://tonybaldwin.me/downloads/dreamlog.v1.tar.gz
- Join the Dreams group on Friendica to post, discuss, and analyze your dreams.
- short link to this page: http://tonyb.us/dreams
— tonybaldwin 2012.11.10.15.41

