peter-notes
- manage your notes from the terminal
notes
[FILE-GLOB]
notes
-s
|--search
REGEX
notes
-f
|--find
FILE-GLOB
notes
-l
|--list
[PATH]
Manage your notes from the console.
If you're like me, you spend most of your computing time in a terminal, you have a text-editor set up just to your liking, and you wish you could use it for everything. Naturally, when it comes time to ditch your paper note-pad, you refuse to to use the more popular gui-driven apps and want to find a way to use your editor instead.
But when you start looking for a terminal-based notes framework (or plugin for your editor) you're blinded by crazy features and unwilling to learn a new tool. You've also already started keeping your notes in some text files and don't want to have to start over.
Anyway, I went through the same thing and made this this lightweight tool (originally from some aliases in my bashrc) to do what I wanted it to do, which isn't a lot. But, like ruby, it has a nice interface, and it'll stay out of the way. That means you can choose where you keep your notes, how you organize them, how you track them (if you do), and what editor you use to write them. So if you already have your own notes, you can just point peter-notes
at them and start using worlds simplest (and coolest) notes-manager.
These options provide some extra utility beyond simply opening notes for editing.
-f
, --find FILE-GLOB
Seach for notes that match the specified FILE-GLOB
. This one's running find -- find YOUR-NOTES-DIR -name FILE-GLOB
. It's a little more than that though, this will be fuzzy in that you can add some path info to your glob. For example, if you ran notes --find "projects/*"
(or notes --find "pro/*"
), you'd get back both projects/python/jarbs.txt
and projects/ruby/peter_notes.txt
. So it's better than just find. A little.
-l
, --list [PATH]
List all notes or, if a PATH
is specified, list notes within the specified path. Bet you thought this was running ls -R
, well it's actually running tree because it's much cooler -- tree YOUR-NOTES-DIR/PATH
.
-n
, --new PATH
Create a new note at the specified PATH
, making any directories in-between, and open it. If you don't give a file-type extension, peter-notes
will use the extension
value from your preferences (below), ex: notes --new path/to/my_note
will make ~/Notes/path/to/my_note.txt
(with default preferences). If you do specify a file-type extension, you'll create a note with that extension -- they don't all have to be the same! :astonished:
-s
, --search REGEX
Search within notes for text matching the specified REGEX
, ex: notes --search ".*TODO.*"
. This isn't magic, it's just grep. Specifically, it's running grep -r YOUR-NOTES-DIR -e REGEX
.
notes
. Yeah.
But you can do more!
Lets assume you have the following notes:
/Users/peter/Notes/
|-- projects
| |-- python
| | +-- jarbs.txt
| +-- ruby
| +-- peter_notes.txt
+-- other
+-- motorcycle.txt
Most of the time you just want to open them. To do that, type notes
. You can specify your text editor and where your notes are in ~/peter-notes.yaml
(see PREFERENCES below). This will basically cd
into your notes and open them all with YOUR-EDITOR ./
. Some editors don't super work when you open a directory, but I use vim with NerdTree and I'm sure other editors have similar plugins.
If you want to open a specific note, you can pass in a file-glob
to specify which one. If you think a file glob is what happens when you spill coffee on your computer, just check this out this description (hint, you use it in bash a lot, like, when you ls *.rb
).
Lets say you want to open other/motorcycle.txt
. You could run notes "other/motorcycle.txt"
, but that's kind of lame, so you could also type notes "motorcycle"
, or even notes "moto*"
. If you're feeling extra crazy, you could get away with m*
here. Basically if you pass a glob in, peter-notes
will just take the first match from --find
(see OPTIONS above) and open that. If you wanted to open all notes under projects/
you could also use this same idea and run notes "projects"
.
The close observer will have noticed that I'm leaving out .txt
in most of my commands. That's not because peter-notes
requires .txt
files. In fact, you can use markdown or whatever kind of files you want, but peter-notes
will totally ignore file extensions unless you provide one. If you plan on keeping most of your notes in some file-extension other than .txt
, just add a line to your preferences file (below), but it really only effects --new
.
Thats like what 90% of what youll ever need and no crazy macros or flags to memorize. Not bad right? Well not all flags are bad, in fact, you also get some super-helpful optional ones for the other 10%, just look above at the OPTIONS section.
Oh yeah, make sure your terminal has grep
, find
, and tree
. It should, but depends on how crazy your 'gear' is.
Preferences are saved in '~/.peter-notes.yml'. There are just 2 options that you can set:
editor:
The editor of your choice. This value will get passed to bash so
make sure you use the exact name your terminal will understand.
Possible Values: [vim, subl, atom, emacs, nano, ...]
(more?) I haven't tested others but I know
they're out there.
Default Value: vim
notes_dir:
The home of your notes. This is where `peter-notes` will look
for them.
Possible Values: any valid + existing dorectory path. I use
~/GoogleDrive/Notes because I track mine in
google drive (OverGrive for linux).
Default Value: ~/Notes
extension:
The default file-type extension for your notes.
Possible Values: [txt, md, yml, json, html, rb, ...]
anything your editor can understand that's a
valid file extension.
Default Value: txt
That's yaml so it should look like this:
editor: vim
notes_dir: ~/Notes
extension: txt
Peter Fonseca peter.nfonseca@gmail.com
This tool runs on top of a few very useful bash utilities and relies on terminal-accessible text-editors. It was also written in a fantastic language called ruby.
bash(1), grep(1), find(1), tree(1), vim(1), ruby(1)