The way that Notational Velocity allows to manage your notes is genious, but only available to macOS users. That software presents a list of your notes next to the editable preview of a the selected note and a powerful full-text search filters the list of notes. As all the notes are stored as plain text files they can easily synchronized. This article presents an alternative note managing tool that works for major operating systems, is free and open source.
The setup combines ranger and ones' favourite terminal based editor. We assume that both are set up and describe some configuration tweaks that makes this combination come closer to nvAlt or Notational Velocity.
Make sure the editor variable is set in the shells configuration file, e.g.
~/.bashrc
. This is the editor that will be used to modify the text. For
example export EDITOR="nano"
.
Lets assume that all the notes are located as text files in the folder notes
in the users directory. For the listing of files ranger allows that certain
preferences apply for certain folders, e.g. whenever the folder ~/notes
is
shown the listing shall be sorted in a certain way. We show and explain parts
of the ranger configuration file rc.conf
.
The listing is sorted by last modification time for the most recently changed or added note to appear on top.
setlocal path=~/notes$ sort mtime
setlocal path=~/notes$ sort_reverse false
At the time one wants to see only the notes directory with the listing next to the preview of the text file.
setlocal path=~/notes$ preview_files true
setlocal path=~/notes$ column_ratios 1,1
setlocal path=~/notes$ viewmode miller
By default the list of notes can be cluttered with each notes size, a line
number, and the file extension (here txt
). All these are hidden.
setlocal path=~/notes$ display_size_in_main_column false
setlocal path=~/notes$ display_size_in_status_bar false
setlocal path=~/notes$ line_numbers false
default_linemode filename
default_linemode path=/.*?/.*?/notes/.*\.txt notes_linemode
The python function notes_linemode
strips off the extension. It should be put
in the file plugins/notes_linemode.py
inside the ranger configuration
directory.
import ranger.api
import ranger.core.linemode
import os.path
@ranger.api.register_linemode
class MyLinemode(ranger.core.linemode.LinemodeBase):
name = "notes_linemode"
uses_metadata = False
def filetitle(self, file, metadata):
return os.path.splitext(file.relative_path)[0]
- Search
With the configurationalias n scout -aeit
one can write:n
followed by any search term, which will focus on the first match. One can move on to the next match with the<tab>
key. - Editing notes
When the focus is on the note that we want to edit pressing either<return>
,l
or<right>
opens the note in the$EDITOR
. - Creating new notes
Commands that are not mapped to a key combination can be send to ranger in the command mode (which is started by colon:
). Writing:touch Some Name.txt
creates the new note with the nameSome Name.txt
. In the argument to the touch command automatically sanitized and there is no need to escape the space character. - Bookmark to notes
If ranger is used for other purposes than notes managment we suggest to set a bookmark. With the default configurationm n
will mark the present directory to be remembered by lettern
. The keys'n
will return to the bookmark from any other folder. - Flat directories
If the notes are organized in a hierarchical directory structure theflat
setting, as below, shows all files regardless whether they are in a subfolder inside thenotes
folder.setlocal path=~/notes$ flat 2
- Reveal a file
Show the presently highlighted file in another file manager with the%
key, for example on macOS with the following setting the file is shown in Finder:map % shell open -R %s
.
The flexibility of ranger allows for more simple usage and for further magical adjustments, e.g. git integration, highlighting code in notes or showing pictures inline.
- ranger documentation
- Notational Velocity -- the original.
- nvAlt -- a maintained and improved version of the original.
- nvTerm -- a command line version written in python
A configuration which is extracted from this article is joined below.
~/.config/ranger
├── plugins
│ └── notes_linemode.py
└── rc.conf
Assuming you saved this configuration, try it out:
$ git clone https://github.com/hendricius/the-bread-code ~/notes
$ EDITOR=nano ranger --debug --clean --cachedir=/tmp --datadir=/tmp --confdir=~/.configdir/ranger/ ~/notes