Bash Notes
bash notes
a simple note taking script written in bash
I’ve found myself in need of a simple way to take notes, and since the other solutions available didn’t meet my needs, I’ve decided to write my own script.
It’s a simple (enough) bash script, the only dependence (yet) is jq.
here’s all the functions that are now available:
|
|
All the basic functionalities are present and working, it probably needs some polishing and some testing, so if you want to give it a try, let me know what you think.
Settings
When you first run it, notes.sh will create all the files it needs to operate.
By default the directory will be populated in ~/.local/share/bash-notes.
If you want to modify the predefined settings, you can export a user configuration file by running
|
|
And you’ll have all your settings in ~/.config/bash-notes.rc. This file will be sourced every time you run the script.
You can change all these settings by editing the file:
|
|
Most are pretty self explanatory, the only one that might need clarification is TERM_OPTS which is used to set the terminal window that will run the editor while writing the note.
Special attention is needed when specifying the options, in my case, using alacritty, the option that allows to run some software in the newly created window is -e, so I need to specify this as the last option.
Functionalities
bash-notes can:
-
write a new note
--add="Your note title"or in short-a"Your note title" -
modify an existing note
--edit=[note ID], short version-e[note ID] -
delete a note
--delete=[note ID], or-d[note ID] -
delete all notes
--delete=all, or-dall -
list existing notes
--listor-lin short -
display a note
--show=[note ID], or-s[note ID].It’s also possible to simply pass [note ID] as an argument to the script and the corresponding note will be displayed.
bash1notes.sh 1
The note id is assigned when the note is created, and that’s how you refer to the note in the program.
Plain listing vs “colorful”
The --plain or -p option in short, dictates how the output from the script is formatted, here’s a sample listing of all the notes:
|
|
And here’s the same listing with the plain option:
|
|
It’s just a proof of concept at the moment, but the idea is to use a more interesting output maybe using markup, and strip it down in plain mode. After all is still a work in progress. The plain option must precede all other options or it won’t work. I’ll try and fix this behavior in the future.
I’d love to implement some kind of searching functionality, but I’ll have to look into that.
Backups
Since version 0.3, this script can also handle backups of all your notes, you can specify a backup folder with
|
|
and the script will create the directory if it doesn’t exists and backup all your data, including the rc file if you made one.
If you want to restore a backup you can do so with
|
|
And the script will take care of putting everything back where it belongs.
Installing
Simply copy the script in your $PATH and make it executable, something like this should work:
|
|
Adapt to your needs as you see fit.
The first time you run the script it will take care of creating all the files and folders it needs in the standard directories.
Debugging
If the script doesn’t work for you for some reasons, you can turn on debugging by running the script like this:
|
|
And then you’ll be able to check all that happened in the log file at /tmp/debug_bash-notes.log
Vision
Ok, maybe vision is a bit of a stretch, but I’ve written this script to use it in my daily workflow with rofi and i3wm. I’ll adapt the way it works to better suit this need of mine.
There are of course things I’d love to add, but my main goal is for it to work the way I planned to use it.
TO DO
- add a way to search the notes
add a way to display a note without running vim(done in version 0.3)- markdown support?
- maybe implement an export feature that builds the html or pdf file from the note (pandoc??)
- write a bash completion script to enable autocomplete in the shell
- other ideas may come […]
Contributing
It’d mean so much to receive some feedback, patches if you feel like contributing, I’m not expecting much as this is a personal project, but feel free to interact as much as you want.
ChangeLog
-
v0.3 - backups management. Some UX improvements
- create and restore backups of all your notes and settings.
- display notes using predefined PAGER variable or define your own program to use.
-
v0.2 - debugging implemented
- you can now generate a debug log in case something doesn’t work
-
v0.1 - first public upload
- all major functionalities are present and working
Mantainer
- danix - it’s just me, really…