config-bash/libs/note.bash

20 lines
401 B
Bash
Raw Normal View History

2014-01-26 13:01:33 +01:00
#!/bin/bash
2024-06-28 12:28:56 +02:00
note() {
2014-01-26 13:01:33 +01:00
# if file doesn't exist, create it
if [[ ! -f $HOME/.notes ]]; then
2024-06-28 12:28:56 +02:00
touch "$HOME"/.notes
2014-01-26 13:01:33 +01:00
fi
if [[ $# -eq 0 ]]; then
# no arguments, print file
2024-06-28 12:28:56 +02:00
cat "$HOME"/.notes
2014-01-26 13:01:33 +01:00
elif [[ "$1" == "-c" ]]; then
# clear file
2024-06-28 12:28:56 +02:00
echo "" >"$HOME"/.notes
2014-01-26 13:01:33 +01:00
else
# add all arguments to file
2024-06-28 12:28:56 +02:00
echo "$@" >>"$HOME"/.notes
2014-01-26 13:01:33 +01:00
fi
}