Saga
.

This entry is about a tool called Saga,
https://github.com/cratuki/standard/blob/master/saga


:: Chronological tracking

When you work on lots of projects, it is easy to lose data into a fog of
subdirectories.

I generally think about data chronologically. I might forget the name I gave a
project, but will remember that I was working on it in August around the same
time as another project that I do remember.

You may have heard of Evernote. Saga serves a similar purpose to Evernote. But
it is way simpler. With tools like Evernote, I worry what happens when I need
to access data, and find they have gone out of business.

There are no such problems with Saga. Below I will describe a tool for
accessing it. The amount of code involved is shorter than the length of this
post.


:: Usage

Saga creates directories which are named so that when you sort them all you
get them back in chronological order.

Basic usage:

```sh
$ saga         # default usage echos the complete list of files
[...]
20111031.cturner.bump.aa.python.twisted.standardio.insults
20111108.cturner.bump.aa.freepascal
20111205.cturner.bump.aa.curses.client
20111221.cturner.bump.aa.golang
20111226.cturner.bump.aa.roguelike.messaround
20111230.cturner.bump.aa.moria
$ saga sample  # this creates a new directory and echo the filename
/home/cturner/saga/20120101.bump.cturner.ad.sample
$ saga -z      # echos the name of the most recently created dir
/home/cturner/saga/20120101.bump.cturner.ad.sample
$ cd `saga -z` # dash z is useful for cd
$ pwd
/home/cturner/saga/20120101.bump.cturner.ad.sample
$ 
```

Browsing the filesystem from the console, so we can see those structures,

```sh
$ cd $HOME/saga
$ cd saga
$ ls -lF
[...]
drwxr-xr-x  2 cturner cturner    4096 2011-10-31 17:21 20111031.cturner.bump.aa.python.twisted.standardio.insults/
drwxr-xr-x  2 cturner cturner    4096 2011-11-08 07:08 20111108.cturner.bump.aa.freepascal/
drwxr-xr-x  2 cturner cturner    4096 2011-12-05 22:39 20111205.cturner.bump.aa.curses.client/
drwxr-xr-x  4 cturner cturner    4096 2011-12-21 13:45 20111221.cturner.bump.aa.golang/
drwxr-xr-x  5 cturner cturner    4096 2011-12-26 15:18 20111226.cturner.bump.aa.roguelike.messaround/
drwxr-xr-x  3 cturner cturner    4096 2011-12-30 17:23 20111230.cturner.bump.aa.moria/
```

Note that we use tokens like 'aa' and 'ab'. If we create several entries on
the same day, we can still retain chronological order.

It is good to have the date, username and host encoded into the directory.
Imagine you are looking through your records in five or ten years time. You
can know exactly the circumstances in which the entry was raised.

You may have copied the directories between several computers in that time.
All the unix times will be wrong. But the directory is named to give you
good context.


:: Searching

Searching:

```sh
$ saga | grep python
20090506.craig.xussbaum.aa.python.getopt
20090507.craig.xussbaum.aa.couchdb.python
20090707.craig.xussbaum.ac.cocos.python
20090717.craig.xussbaum.aa.bpython
20101031.cturner.bump.aa.python.wikitools.pattern.dev
20101031.cturner.bump.ac.python.fuse.pattern.dev
20101204.cturner.bump.aa.python.threading.roguelike.sir_lewk.tetrisrl
20110611.cturner.bump.aa.extending.python.with.c
20111031.cturner.bump.aa.twisted.standardio.insults
$ ls
example.py
$ cat example.py
#
# http://twistedmatrix.com/pipermail/twisted-python/2007-October/016109.html
#
# start with twistd -noy example.py
#
import os, tty, sys, termios

from twisted.application import service
[etc]
```


:: Use links to keep track of frequently-used directories

If you had to navigate into saga all the time, you would find yourself doing
a lot of typing.

There is a simple solution to this.

Create a directory, /home/your_name/l.

L is short for 'link'.

Make symbolic links from ~/l to you favourite saga directories.


:: Close

I created this system originally because on any given day I would deal with
data from multiple customers and wanted to have perfect retention with a
responsive system. No web bug tracking system could match this for speed.

Since creating it, I have also found it useful for capturing code snippets,
and pretty much everything else in my life also.

Here is the tool: https://github.com/cratuki/standard/blob/master/saga