Temporary Tasks and the Stack

You may find yourself needing to temporarily pause your current task to work on another, with the intent to come right back. This kind of interrupt happens so commonly, that I added functionality to the timelog system early on to deal with it.

Note

The concept of a stack is fairly well-known to developers, but may not be as comfortable to non-developers. A stack makes it easy to deal with temporarily saving something and restoring it later. The useful property of a stack is that you can push multiple things on a stack and then easily remove them in the opposite order. This is known as a “last in, first out” process.

Stack Usage

The push command saves the current task to the stack, and changes to supplied task.

  $ rtimelog curr
  2023-10-24 20:10 +projA @Code
  Duration: 1:23
  $ rtimelog stack top
  $ rtimelog push +projA @Meeting
  $ rtimelog curr
  2023-10-24 21:33 +projA @Meeting
  Duration: 0:00
  $ rtimelog stack top
  +projA @Code

When you are ready to come back to the previous task, you use the resume command.

  $ rtimelog resume
  $ rtimelog curr
  2023-10-24 21:40 +projA @Code
  Duration: 0:00
  $ rtimelog stack top

When you find yourself toggling between two tasks for some reason, the swap command uses the stack in a more advanced way.

Assuming we start work on the Foo project.

  $ rtimelog start +Foo @Monitor
  $ rtimelog curr
  +Foo @Monitor
  $ rtimelog stack top

Later, we want to push the Bar project.

  $ rtimelog push +Bar @Monitor
  $ rtimelog curr
  2023-10-24 21:53 +Bar @Monitor
  Duration: 0:00
  $ rtimelog stack top
  +Foo @Monitor

Next, we want to go back the Foo project, knowing that we will come back to Bar shortly. We can use swap for that, and we’ll use the tools to see the log and the stack.

  $ rtimelog swap
  $ rtimelog curr
  2023-10-24 21:54 +Bar @Monitor
  Duration: 0:00
  $ rtimelog stack top
  +Foo @Monitor

Notice that Foo and Bar have swapped places.

Stack Reporting

To see the task descriptions on the stack, use the stack ls.

  $ rtimelog stack ls

If you just want to know the top item on the stack, use stack top.

  $ rtimelog stack top

Stack Maintenance

If you use the stack a great deal, you may find that it begins to grow out of hand. You’ll probably decide that some of the items on the stack are no longer useful and can be discarded. The following commands support manipulation of the stack.

If you want to discard task descriptions from the top of the stack, use the stack drop command.

  $ rtimelog stack drop

To discard everything on the stack, use stack clear.

  $ rtimelog stack clear

If the most recent task descriptions might still be useful, but the older items could be removed, you can use the stack keep.

  $ rtimelog stack keep