Reduce risk of corrupted history file

When saving an updated history file, write the new version
to a <file path>.tmp and then move it to overwrite the original
rather than truncating the original in-place
Avoid saving an updated history file when there have been no dir usage events

Keep track of the time when the last dir-use event was received
and avoid saving a new history file if it is older than the
previous save event.
Move DirUseSource implementations to a separate file
Add 'rd push' command to add dirs to the history

Change syntax of client from 'rd <pattern>' to
'rd <command> <args>' where the supported commands are currently:

 query <pattern>|<id>
 push <path>

This makes the syntax for executing a query longer but queries
are usually issued via 'cdr' anyway.
Prune non-existent dirs from cache at query time

Before returning a dir in response to a query, check
that it still exists.

The stating is done at query time rather than when
loading the history to avoid unnecessary I/O on login
when the daemon starts
Sort results with equal numbers of component matches by access time

Rather than sorting lexicographically, sort by access time
Find all instances of a pattern in the dir path

Previously only the first pattern match was located
and highlighted in the output
Add 'rd list' command to list all dirs in history

This is handled via a special '*' query pattern internally.