I write everyday. Everyday I write. I have a quota of words to fill and after each sleeping session, I sit in front of my keyboard and begin pressing words.
I was using Emacs for this. Emacs, the One True Editor. Yet it has one flaw that makes me divert from this writing routine. It has too many features and when I see a block and some idea that I'm not big enough to put into words, I begin to play with it. Emacs is also my friend and one should keep their friends away from their workplace. Otherwise no work is done.
For this reason I began to write with `ed
<http://en.wikipedia.org/wiki/Ed_(text_editor)>[__ some time ago.
]{.title-ref}[ed]{.title-ref}[ is not my friend, it's *the standard
editor*. It's also the grandfather of ]{.title-ref}vi
<http://en.wikipedia.org/wiki/Vi>`__ but father's should not
burden the vices of their sons' you know.
=ed= was very nice to write with. It doesn't have much features. It
writes a 0
when it opens, and I type i
to insert text, then write
what I like. When I put a lonely .
in a line, it understands that I
finished my words, then by w
I save the file to the disk and see the
length of it. Length in bytes, as every true writer nowadays should
know.
=ed= is dumb and I'm really pissed off by its modded behavior but from this reason alone, I was very happy to write with it.
However I decided it's again to much to press those pesky command keys.
Man, it's i
and .
and w
. One can forget easily. And it looked I
have a tendency to learn more of its commands which passed down to its
grandchild. God save us from vices of vi.
Then I decided to concoct a script which uses cat
. Everybody knows
writers like cats and I like cat
too, it catenates text into files and
also used to print their content. It's much simpler than ed
, much
more simpler. It is not an ambivalent dork like ed
, it's a simple
animal that writes into files whatever I type into it.
It was easy to check the size of file in words after I put into words in
it. Then write a while loop to continue until I fill my daily quota. It
creates a new file, puts a header into it for `org-mode
<http://orgmode.org>[__, also adds the content of clipboard just
after the title, so I can put notes into files after a copy.
]{.title-ref}[cat]{.title-ref}[ quits by
]{.title-ref}[Ctrl-D]{.title-ref}[ and when it finishes, the script
checks the word count and if I'm still away from my daily target, it
puts a ]{.title-ref}[------]{.title-ref}` as a separator and opens
the file again. You have to finish your words either your brain bleeds
or your cat dies.
The effect? I began using it today, so I'm still not sure about the
effects but surely there's nothing to read when I press Ctrl-h i
. The
info of Emacs was highly entertaining and I was just finishing the
command line options of gnu backgammon back when I was writing with it.
They make these programs highly customizable and I can't even finish
reading their manuals.
The script is seen below. It also asks for a filename and if you don't
give, it just creates one from the date. It has some minor changes from
the one I use, because I tend to name my files in a different format and
I didn't try this one before putting it here, but here goes. Cut and
paste to a file named write-with-cat
, make it executable with
chmod +x write-with-cat
, then run. Ah, yes, you need to be on a
Unixish system or install Cygwin on Windows, but you should do that for
many other reasons too. (Even my mom uses Debian, you know.)
The second part of the script copies the written material to a selected repository directory and calls necessary mercurial commands to commit. I commented out that part, because it needs a certain directory structure.
#!/bin/bash
WORDSIZE=600
echo "Please set a (tentative) name?"
read response
if [ -z "$response" ] ; then
dirname=work-`date +%y-%m-%d`-$RANDOM
else
dirname=work-${response}
fi
tempdirname="/tmp/$dirname"
mkdir $tempdirname
docname="$tempdirname/index.org"
selection=`xsel -ob`
cat > $docname <<EOF
#+TITLE: $response
#+AUTHOR:
#+DATE: `date`
$selection
EOF
clear
cat $docname
while [ `wc -w "$docname" | cut -f 1 -d ' '` -le $WORDSIZE ] ; do
cat >> $docname
echo "\n-----" >> "$docname"
wc -w "$docname"
done
# dir=none
# echo "(1) Blog"
# echo "(2) Site"
# echo "(3) Diary"
# read response
# case $response in
# 1) dir=blog
# ;;
# 2) dir=site
# ;;
# 3) dir=diary
# ;;
# esac
# REPOSDIR=~/Repository/$dir
# if [ "${dir}" != "none" ] ; then
# mv $tempdirname $REPOSDIR
# hg add -R $REPOSDIR $REPOSDIR/$dirname
# hg commit -R $REPOSDIR -m "Autocommit"
# fi