script passed through shellcheck linter
[bash-notes.git] / README.md
CommitLineData
0ade724f 1# bash notes
2
6c152f7e 3## a simple note taking script written in bash
0ade724f 4
6c152f7e 5I'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.
0ade724f 6
7It's a simple (enough) bash script, the only dependance (yet) is [jq](https://stedolan.github.io/jq/).
8
6c152f7e 9here's all the functions that are now available:
0ade724f 10
11```bash
12-h | --help : This help text
13-p | --plain : Output is in plain text (without this option the output is colored)
14-l | --list : List existing notes
026502da 15-a | --add "<title>" : Add new note
e4b35b4f 16-e | --edit <note> : Modify note
026502da 17-d | --delete [<note> | all] : Delete note
0ade724f 18-v | --version : Print version
19--userconf : Export User config file
20```
21
6c152f7e 22All 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.
23
24### Settings
25
26When you first run it, notes.sh will create all the files it needs to operate.
27By default the directory will be populated in `~/.local/share/bash-notes`.
28
29If you want to modify the predefined settings, you can export a user configuration file by running
30
31```notes.sh --userconf```
32
33And you'll have all your settings in `~/.config/bash-notes.rc`. This file will be sourced everytime you run the script.
34
35You can change all these settings:
36
04781825 37```bash
6c152f7e 38# Binaries to use
39JQ=/usr/bin/jq
40EDITOR=/usr/bin/vim
41TERMINAL=/usr/bin/alacritty
42# add options for your terminal. Remember to add the last option to execute
43# your editor program, otherwise the script will fail.
44# see example in the addnote function
45TERM_OPTS="--class notes --title notes -e "
46
cb8fcb2f 47# set this to true to have output in plain text
48# or use the -p option on the command line before every other option
49PLAIN=false
6c152f7e 50# base directory for program files
51BASEDIR=~/.local/share/bash-notes
52# notes database in json format
53DB=${BASEDIR}/db.json
54# directory containing the actual notes
55NOTESDIR=${BASEDIR}/notes
56```
57
58Most 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.
59
60Special attention is needed when specifying the options, in my case, using [alacritty](https://github.com/alacritty/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.
61
62### Functionalities
63
64bash-notes can:
fe606f6a 65
6c152f7e 66 * write a new note `--add "Your note title"` or in short `-a "Your note title"`
67 * modify an existing note `--edit [note ID]`, short version `-e [note ID]`
68 * delete a note `--delete [note ID]`, or `-d [note ID]`
69 * delete all notes `--delete all`, or `-d all`
70 * list existing notes `--list` or `-l` in short
71
72The *note id* is assigned when the note is created, and that's how you refer to the note in the program.
73
74The `--plain` or `-p` option in short, dictates how the output from the script is formatted, here's a sample listing of all the notes:
75
04781825 76```bash
6c152f7e 77notes.sh -l
78listing all notes
79
80[ID] [TITLE] [CREATED]
81[1] ciao nota 25/03/2023 18:53 +0100CET
82[2] hello there 25/03/2023 19:02 +0100CET
83```
84
85And here's the same listing with the plain option:
86
04781825 87```bash
6c152f7e 88notes.sh -pl
891 - ciao nota - 25/03/2023 18:53 +0100CET
902 - hello there - 25/03/2023 19:02 +0100CET
91```
92
93It'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.
94The plain option must precede all other options or it won't work. I'll try and fix this behaviour in the future.
95
96I'd love to implement some kind of searching functionality, but I'll have to look into that.
97
034ff3eb 98### Installing
99
100Simply copy the script in your $PATH and make it executable, something like this should work:
101
04781825 102```bash
034ff3eb 103mv notes.sh ~/bin/
104chmod 755 ~/bin/notes.sh
105```
106
107Adapt to your needs as you see fit.
108
cb8fcb2f 109### Debugging
110
111If the script doesn't work for you for some reasons, you can turn on debugging by running the script like this:
112
113```bash
114DEBUG=true notes.sh [options]
115```
116
117And then you'll be able to check all that happened in the log file at `/tmp/debug_bash-notes.log`
118
6c152f7e 119### Vision
120
121Ok, maybe vision is a bit of a stretch, but I've written this script to use it in my daily workflow with [rofi](https://github.com/davatorium/rofi) and [i3wm](https://github.com/i3/i3). I'll adapt the way it works to better suit this need of mine.
122
123There 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.
124
125### TO DO
126
127 * add a way to search the notes
128 * add a way to display a note without running vim
129 * markdown?
130 - maybe implement an export feature that builds the html file from the note
034ff3eb 131 * write a bash completion script to enable autocomplete in the shell
6c152f7e 132 * other ideas may come [...]
133
134### Contributing
135
136It'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.
137
abf04f28 138### ChangeLog
139
140 * v0.2 - debugging implemented
141 - you can now generate a debug log in case something doesn't work
142 * v0.1 - first public upload
143 - all major functionalities are present and working
144
6c152f7e 145### Mantainer
146
147 * [danix](https://danix.xyz) - it's just me, really...
148
149### LICENSE
150
151> bash-notes © 2023 by danix is licensed under CC BY-NC 4.0. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/