Manage Simplenote with sncli
Duly Noted
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).
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.
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}
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).
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.
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.
Infos
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
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.
News
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.