Reducing Typing with Aliases

As you use the rtimelog program more, typing long strings for individual entries becomes annoying. If you are working on the same projects or tasks on a regular basis, you might find typing the detail annoying even if you want it for reporting.

Note

Aliases started out as a really simple text replacement to allow shortening command typing.

Slightly more advanced replacement text is now supported with the idea of trying to reduce the number of aliases.

Defining Aliases

The rtimelog program supports defining aliases in your .timelogrc file. These aliases can be either full events or partial events. The aliases are defined in a [alias] section in your .timelogrc file. They take the following form:

[alias]
   email = start +Misc @Email
   proja = start +ProjectA
   int   = push +Misc @Questions

When rtimelog encounters an alias at the beginning of its command line, it replaces the alias with the string after the equals. This allows you to define full events or partial events easily. To use an alias, use the alias as the command when calling rtimelog:

  $ rtimelog email

This gets converted to

  $ rtimelog start +Misc @Email

The proja alias above is a good example of a partial event. You would use the alias like:

  $ rtimelog proja @ConfCall Client design team

This is equivalent to typing

  $ rtimelog start +ProjectA @ConfCall Client design team

Alias Templates

Over time, I often find myself adding new aliases for events relating to new projects and deleting aliases that I no longer use. After a while, I noticed that I tended to make clusters of aliases for particular projects. All of the extra alias maintenance seemed ridiculous. What I really needed was a way to make aliases that were templates, rather than just replacement strings.

If the expansion string for an alias contains the string {}, it is handled a bit differently. For example, if we assume the following aliases:

    email = start +Misc @Email
    code  = start +client:{} @Code
    doc   = start +client:{} @Doc
    test  = start +client:{} @Test

rtimelog replaces the {} with the argument that comes after the alias. So using the code alias as follows:

  $ rtimelog code Bob New UI

is equivalent to typing

  $ rtimelog start +client:Bob @Code New UI

This expansion continues until all {} strings are replaced. If we try to replace a {} and there is no corresponding argument, the {} will be left in place. This has dramatically improved the entry detail I use without requiring nearly as much maintenance of my aliases.