Meet Jotr - A note-taking app for the CLI
Tags: notes, cli, terminal
Published: 2019-10-21 21:42:46

{% github hakash/jotr no-readme %}

> **Disclaimer:** This project is in beta. Help is needed to test it to root out issues that might have escaped me. Documentation and everything needs scrutiny.
> 
> Thanks for reading!

If you are like me you really hate context switching. Jumping out of a train of thoughts to go fiddle in some GUI when you are in on the deep end in a terminal is really less than optimal.

Personally I use various apps for taking notes of different kinds, in different contexts, and try to minimize switching out of a context to take or read notes. Partly due to the overhead of the navigation, but also the imminent danger of getting distracted.

I, and a lot of my fellow developers out there, suffer in various degrees of what I jokingly call "The 'Oooh Shiny!' Syndrome". This is the thing that happens when your eye catches something distracting. This can be a notification, an unrelated, but interesting question on Stack Overflow, some article you scan by looking for something or even urges to suddenly dig into some other tech.

Sure, most of us have a good grip on this, but let's be honest. When you have a mammoth task of the boring or uncomfortable kind, it's just too easy to start procrastinating.

Reducing context switching, entering "zen-mode" in all apps that support it, turning on Do Not Disturb where ever possible and so forth is all good tips here. Several members of this community has made detailed posts about this exact topic, earning hundreds of reactions.

## How Jotr can help a little - a user manual of sorts

Jotr is, as stated above, a note-taking app for the CLI. It allows you to stay in the terminal and avoid visual cues and distractions just to find some previous recorded info, or add some new notes, or "jots" as we coined them.

It is centred around tags, and each jot you add gets added to one or more tags. Using tags is optional of course, and omitting them will just default the jots to use the "Random"-tag.

Install it using `npm i -g jotr`

### Adding data

You can add jots using a full terminal editor that's built-in, or add them using a `git commit -m "Some message"` style, to reduce context switching even more.

```bash
jotr js node react -c Node is awesome to serve React-driven pages
```

This one-liner gives you the jot `Node is awesome to serve React-driven pages` connected to the tags `js`, `node` and `react` tags. Quotes are optional as long as you don't use characters with special meaning in the shell.

### Reading data

To list all your jots you can use `jotr -l` or `jotr --list`.

```bash
$ jotr -l
Your jots so far:
js:
  - Node is awesome to serve React-driven pages
node:
  - Node is awesome to serve React-driven pages
react:
  - Node is awesome to serve React-driven pages
```

Now, when you get a lot of jots, listing them all becomes tedious and unruly. For this situation you can list only certain tags:

```bash
$ jotr -l js
Your jots tagged with js:
js:
  - Node is awesome to serve React-driven pages
```

If you cant remember the exact tag, you can search or grep with `jotr -g [search term]` or `jotr --grep [search term]`:

```bash
$ jotr -g node
Your jots matching node
js:
  - Node is awesome to serve React-driven pages
node:
  - Node is awesome to serve React-driven pages
react:
  - Node is awesome to serve React-driven pages
```

If you want to know what tags exist, you can use `jotr -t` or `jotr --tags` to list them:

```bash
$ jotr -t
The tags currently registered:
js
node
react
```

### Altering, deleting or editing your jots

The data storage of Jotr is file-based, and uses a simple YAML-format to save the data ordered by the tags. As of yet, Jotr does not support editing or deleting single jots, but a new, more complex storage-format is being considered to support this.

Until then Jotr does give you an option to edit the file-storage directly by using the `jotr --edit`. This loads up the entire YAML-file in the internal editor for your editing pleasure. I urge you to do an export (se below) before you manually edit the YAML-file, as a corrupt YAML-file will not function correctly.

### Purge and export

Naturally you can export your data to a YAML or JSON file:
```bash
$ jotr --export mynotes.yml
$ more mynotes.yml 
js:
  - Node is awesome to serve React-driven pages
node:
  - Node is awesome to serve React-driven pages
react:
  - Node is awesome to serve React-driven pages


$ jotr --export mynotes.json
$ more mynotes.json 
{"js":["Node is awesome to serve React-driven pages"],"node":["Node is awesome to serve React-driven pages"],"react":["Node is awesome to serve React-driven pages"]}
```

Done with your list? Want to purge it? Sure: 
```bash
$ jotr --purge
Are you sure you want to purge all data? (y/N)
```

## Summary

Still with me? Great!

As you can see, you can easily stay in the terminal, jotting down things to remember, drafting commands or even use it as a multi-item clip-board.

Personally I see it as a good tool for remembering commands, settings, flags or even miniature scripts, easily called up where ever you are in the file system.

Sure, Jotr does not support synching across devices, but as a SysOps or DevOps tool, this can be positive, as you keep the data only in your profile, locally on the machine.

### Bonus

Did you know that the core of Jotr is built to be embedded in other systems as a library? Check out the repo to learn more about this. Click on the "library" link.

Thank you so much for your attention!

I'll catch you later with updates, tips, trick or other tidbits.

Cheers!

-Morten