Manage Simplenote with sncli

Duly Noted

Article from Issue 235/2020
Author(s):

If you're using Simplenote, check out sncli, a Python-based tool for syncing and managing your notes.

Despite the proliferation of Markdown-based and regular note-taking tools and services, Simplenote remains a popular choice for note-keeping. There are many reasons for its enduring success. Although the service is continuously being improved and tweaked, it manages to maintain a delicate balance of functionality and simplicity. In addition to essential features like tagging, Markdown support, and search, Simplenote also makes it possible to collaborate on notes, as well as to publish them on the web. And creature comforts like word count and versioning make Simplenote an ideal writing tool. In short, you'll be hard pressed to find a service or software that offers a similar level of functionality free of charge.

Although Simplenote offers desktop applications, they are basically web apps disguised as desktop tools. Fortunately, the service provides an API, so there are several third-party solutions for integrating Simplenote into your preferred editor. For example, if you happen to use Emacs, you'll be pleased to learn that there is a plugin that lets you work with your Simplenote notes without leaving the convenience of your favorite text editor.

But if you are looking for a standalone client that allows you to sync Simplenote notes as well as manage and edit them using any text editor, sncli [1] might be right up your alley. This handy Python-based tool allows you to work with Simplenote notes online and offline, providing synchronization functionality and a wide range of useful features (Figure 1).

Figure 1: You can preview notes directly in the terminal or open them in your preferred text editor.

Getting Started

Sncli is written in Python, and the easiest way to install it on a mainstream Linux distribution is to use the pip tool. Before you proceed, make sure that this tool is installed on your system. Run the which pip3 command, and you should see the path to the pip3 executable. If the output of the command is blank, you need to install the pip3 package using the default package manager of your Linux distribution. On openSUSE, you can do this using the command:

sudo zypper in python3-pip

With pip installed on your system, run the command:

sudo pip3 install sncli

Before you launch sncli, you need to create a .snclirc configuration file (Listing 1). Sncli supports a wide range of configurable options that you can specify in the configuration file, but as a minimum you need to specify your Simplenote credentials to give sncli access to your account. To do this create a .snclirc file in your home directory and paste the lines from Listing 1 into it.

Listing 1

.snclirc

[sncli]
cfg_sn_username = USER
cfg_sn_password = PASSWORD

Replace USER and PASSWORD in Listing 1 with your actual Simplenote username and password. Save the changes, open the terminal, and run the sncli command.

During the first start, sncli performs a full synchronization. And depending on the number of notes in Simplenote, it may take a moment. Once the sync is finished, you should see sncli's main interface with a list of notes.

Features

Despite its simplicity, the text-based interface packs in a lot of useful information (Figure 2). To begin with, all notes are color-coded, which makes it easier to quickly view their status. For example, the green color marks the notes that have been updated in the last week, and brown is used for notes that have been updated in the last month. The notes that have not been updated in a year are light blue. The interface itself is split into four columns. The first column from the left displays the modification date of each note. The next column shows the note's current status and the note's flags. For example, you'll see the * flag next to a pinned note, and all Markdown-formatted notes are marked with the m flag. When you trash a note, the T flag is added to it until sncli synchronizes the changes. The not yet synced notes have the X flag next to them, while the published (or shared) notes are marked with the S flag. Finally, the middle column shows a list of notes, and the last column lists the tags assigned to notes.

Figure 2: Sncli's main screen provides an informative overview of all notes. In the color scheme used above, the newest notes are in red.

Since sncli has a text-based interface, all operations are performed using the keyboard. The default key bindings in sncli mimic those in the vi editor. So you can use the j and k keys to go up and down the list of notes. To scroll one page up, use the b key, and to scroll one page down press Ctrl  +f. The g lets you jump to the top, and pressing G jumps to the bottom. To quickly preview the currently selected note, press Enter, while hitting Space will open the note in the default editor (i.e., the editor defined by the $EDITOR environmental variable). Remember that sncli is easy to customize (Figure 3). If you prefer to use a different editor for editing notes, add the following line to the .snclirc file (replace emacs with the desired editor installed on your system):

cfg_editor = emacs {fname} +{line}
Figure 3: You can customize sncli's configuration and behavior by specifying parameters in the .snclirc file.

There are a few other keys that are worth memorizing right from the start: C to create a new note, t to add and edit tags, p to pin the current note, and m to enable Markdown formatting for the current note. Finally, h displays a quick overview of all key bindings in sncli (Figure 4).

Figure 4: The help screen in sncli is only one key press away.

If the default key scheme is not your cup of tea, you can easily reconfigure it by specifying the appropriate key parameter in the .snclirc file. For example, if you prefer to use the e key instead of Space to open a note for editing, add the line below to the configuration file:

kb_edit_note = e

The help screen is evoked with h and shows parameters for all supported key bindings (e.g., kb_down and kb_up for up and down keys), and you can use them to reconfigure the default key scheme.

Speaking of configuration, there is one more option you might want to specify while you are at it. When you open and edit a note, it's not updated in sncli until you close the editor. Until then, the editor uses a temporary file in the default temporary directory (e.g., tmp). This means that if your editor or the entire system crashes, all unsaved changes will be gone. To prevent this from happening, use the cfg_tempdir option to specify a persistent directory for temporary notes (replace USER with your actual username in the example below):

cfg_tempdir = /home/USER/.sncli/tmp/

If the directory doesn't exist, you have to create it manually.

Sncli saves synchronized notes as files in the JSON format in the ~/.sncli directory, and you can use the sncli dump command to save them all in a single Markdown file:

sncli dump >> allnotes.md

If you have a large number of notes in Simplenote, you'll be pleased to learn that sncli provides search functionality (Figure 5). Hit /, enter the search string, and press Enter to see the list of matching notes. You can also enter multiple words in the search field, and sncli will search for all the specified words. If you need to find a specific phrase, wrap it in quotes (e.g., "Japanese history"). By default, sncli searches titles, the content of each note, and tags. However, you can limit the search to tags only using the tag: prefix, for example: tag:travel. Keep in mind that regular searches are not case-sensitive. Sncli also supports searches using regular expressions.

Figure 5: Sncli features powerful search functionality.

Being a command-line tool, sncli can be used for automating Simplenote-related actions. For example, using the sncli create command, you can create notes directly from the command line. The following command pipes the output of the echo command to sncli, which creates a note with the received output as its title:

echo 'New note' | sncli create -

It's also possible to pipe notes in the JSON format to the sncli import command:

echo '{"tags":["travel","tokyo"],"content":"Tokyo travel notes"}' | sncli import -

Conclusions

Sncli provides a clever solution to the problem of missing synchronization functionality in Simplenote. This clever command-line tool is not only easy to deploy and use, it also offers a wide range of useful features: from the main screen that offers an overview of the notes and their statuses to flexible search capabilities and extensive customization. If you use Simplenote as your preferred note-taking tool, sncli is a must-have.

The Author

Dmitri Popov has been writing exclusively about Linux and open source software for many years, and his articles have appeared in Danish, British, US, German, and Russian magazines and websites. You can find more about his work on his http://www.tokyomade.photography website.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News