Subscribe Now
Trending News

Blog Post

Show HN: A note-taking CLI for zipfile enthusiasts
News

Show HN: A note-taking CLI for zipfile enthusiasts 





Sonse (Stephen’s Obsessive Note-Storage Engine, pronounced son·say) is a command-line note management application. It allows you to create, edit and maintain your plaintext notes while keeping them archived in a single human-readable zip file.

If you’ve got a bunch of loose text files lying around and you’d like to keep them organised, Sonse is for you. It’ll keep them safe, sorted and sensible, forever.

Note: Sonse is designed primarily for Linux and Linux-based operating systems; in particular it uses several Linux defaults and environment variables for its basic functions. Mac OS should work (please tell me if it doesn’t), but Windows is unsupported at this time.

Installation

Sonse requires Python 3.10 and a few dependencies. You can install it one of two ways:

PyPi Package

You can get the official PyPi package with pip:

$ pip install sonse
$ sonse --help

This will install Sonse with a sonse executable you can run directly. Nice and easy.

Source Code

You can also clone this repository or download the latest release and run the source code yourself, if you’re interesting in tinkering with the code:

$ git clone https://github.com/rattlerake/sonse.git
$ cd sonse
$ pip install -r requirements.txt
$ python -m sonse --help

You’ll need to install the dependencies and run Sonse from the Python module, or create an alias for it.

Setup

Archives

Sonse stores notes at $HOME/.config/sonse/sonse.zip. If it can’t find a valid archive, it will create one at that location.

The archive is a single standard zip file containing notes ending in .txt. Each file is formatted in UTF-8 and has a lowercase name, like this:

sonse.zip/
- alpha.txt    # Name: "alpha"
- bravo.txt    # Name: "bravo"
- test-123.txt # Name: "test-123"

These names are used in commands and are always rendered as lowercase without punctuation, excluding hyphens and underscores. If you try to create a note called FOO_BAR, Sonse will interpret it as foo_bar.

Name Disambiguation

Sonse can disambiguate note names based on the prefix you type, allowing you to save time typing. If more than one note matched what you’ve typed, Sonse will tell you what matches:

$ sonse list
alpha
bravo-one
bravo-two

$ sonse read a
This is note alpha.

$ sonse read bravo
Error: ambiguous name, did you mean: 'bravo-one', 'bravo-two'?

Shell Completion

Sonse uses Click for its interface, which has optional support for shell auto-completions. I highly recommend enabling this functionality if you have a shell that supports it. (Sonse will work fine without it, but it’s nice to have.)

Commands

All commands have detailed help messages, use the -h --help option to see them. The following is a quick tour of all the available commands and their general usage:

Create a note

Create a new empty note in your archive:

Use -e/--edit to edit the note after creation:

$ sonse create alpha --edit

Edit a note

Open a note in your default text editor, according to $VISUAL or $EDITOR:

Read a note

Print an existing note to standard out:

$ sonse read alpha
This is note alpha!

List all notes

List all notes in alphabetical order:

$ sonse list
alpha
bravo
charlie

List all notes starting with a prefix:

Use -s/--sort to sort the list by name or size, and -r/--reverse to reverse the sorted order:

$ sonse list --reverse --sort=size
large-note
medium-note
small-note

Copy a note

Copy an existing note to a new name:

Move a note

Rename an existing note to a new name:

Delete a note

Delete a note, if it exists:

$ sonse delete alpha
Are you sure you want to delete 'alpha'? [y/N]: y

Use -f/--force to bypass the confirmation prompt:

$ sonse delete alpha --force

Export a note

Copy an existing note to a file on disk:

$ sonse export alpha some-file.txt

Import a note

Copy a file on disk to a new or existing note:

$ sonse import alpha ~/some-file.txt

Use -e/--edit to edit the note after importing:

$ sonse import alpha ~/some-file.txt --edit

Contribution

If you find any bugs or have any suggestions, please add them to the issue tracker with as much detail as possible. Thank you!

Read More

Related posts

© Copyright 2022, All Rights Reserved