notes
Motivation
I love taking notes. Its always good to have some place to write things down.
So I wrote a short bash function to open a new textfile with the current date as filename (or with a specified name) and open it in my $EDITOR.
I added this function to my zshrc.
And whenever I need to write something down, I just type notes into my terminal and start writing (in markdown).
Usecase
Of course, it could get really hard to find specific informations after a while. This is not a “wiki” solution or replace tools like obsidian.
I use it for different purposes, like a daily todo - or i prepare emails or other messages
The function
function notes(){
local notedir="$HOME/notes"
mkdir -p $notedir
if [ "$1" = "-y" ]; then
local filename="$(date -d "yesterday" +%Y-%m-%d).md"
elif [ -z "$1" ]; then
local filename="$(date +%Y-%m-%d).md"
else
local filename="$1.md"
fi
filename="$notedir/$filename"
if [ ! -f $filename ]; then
echo "# $(date +%Y-%m-%d)" >> $filename
fi
# Open File with $EDITOR if set
if [ -z $EDITOR ]; then
vim $filename
else
$EDITOR $filename
fi
}