The only thing I missed since changing to Linux was short program which would make it possible to make quick notes and/ or diary-entries.
I discovered the magic of the command line then and…hey – I began to think LOL – it has to be solution.
So – yesterday I found quite nice even if not perfect “remedy” for my not satisfied yet needs. It’s my first trial to make something in bash – so, please, be gentle…ok? 😉 But – if you have the better or smarter solution – or you see how you can improve mine – do not hesitate to leave the comment here – it will be very appreciated – as I only start to learn bash.
So – “back to our rams” – the solution is simple: You can simply add following alias to your .bashrc file:
alias dz='cd /home/username/diary && cat >> `date +%F`&& date +%c | tac >> `date +%F`'
Steps:
1. Exchange username with your user name, of course
2. Create directory called diary in your home
3. Reload your window manager by fi. log out and log into it. You can also simply clse the terminal window and open it again (malsdad tip 🙂 ) or type in the terminal: source .bashrc (which doesn’t require from you closing existing instance of a terminal) -> your bash configuration file will be reloaded and you can start using your alias.
4. Open terminal of your choice and simply type into it: dz
The effect – everything you type after using alias dz and then: typing end and – Ctrl d (thanks to malsdad, again for a tip!) will be saved in text file under the name of current date in the directory called diary. You can also press Enter and Ctrl c 😉 to save the file…
What’s more – you can use the alias as often as you wish during the day – next entries will be added “auto-magically” 😉 to the same file with the current date and time underneath…Magic – isn’t it? he he
In the similar way you can create an alias to make notes in the terminal using for example following code:
alias dn='cd /home/username/notes && cat >> `date +%F`&& date +%c | tac >> `date +%F`'
EDIT: nicer version of the alias created by malsdad and friend (THANK YOU! 🙂 ) – this one adds date at the beginning of a note + empty line at the end.
alias notesz='cd directoryname && date +%c | cat >> `date +%F` ; cat >> `date +%F` ; echo | tac >> `date +%F`'
And – please once again – remember that it is just the first step – one can certainly create much smarter bash script or script in other language… Anyway – it was funny to find it out on my own and I hope that it will help somebody else with similar to mine “problems” or… perhaps – inspire one of the Great Coders around…? who knows…? 😉
Enjoy,
tami 🙂














6 comments
Comments feed for this article
July 27, 2007 at 10:54 pm
malsdad
Hi – Linux user, Mepis user, Fluxbox and Openbox user… have enjoyed your page here for some time… thanks for the little CLI note-taking tip, works nicely!!!
malsdad
July 28, 2007 at 12:48 pm
tamihania
@malsdad: Thank you kindly for the comment – I’m glad to be of a little help. 🙂
Wishing you nice weekend,
tami
(Linux, sid, sidux,wmii and fvwm-crystal user…lately 😉 )
August 9, 2007 at 8:52 am
MalsdadMonk
A friend and I, neither of us programming experts, used your alias to make our own, slightly revised. This one puts the date at the beginning of the note instead of at the end, and also puts a blank line at the end of the note so that there’s a little space between the notes.
alias notesz=’cd directoryname && date +%c | cat >> `date +%F` ; cat >> `date +%F` ; echo | tac >> `date +%F`’
Also we noticed that after creating the alias or making changes to it, using Konsole and bash in Mepis it was not necessary to log out — we only needed to close Konsole and then re-open it for the changes to take effect.
And after typing the note, we think it is best to press and then ctrl-D — this exits the cat >> command in the script and takes you back nicely to your prompt.
malsdad
August 9, 2007 at 11:36 am
tamihania
Hej – thank you a lot – I was “fighting ” myself with the date at the end 😉
If you do not mind I will edit my post to reflect the changes 🙂
As to Ctrl d and end – I simply type Ctrl d in an empty line – but I will add your comment, too.
As for logging out – of, course it’s unnecessary – it’s enough to type:
source .bashrc in the terminal…I will add it, too.
Thank you kindly for your interest – perhaps we could make a nice, simple script out of it with the time?
Best wishes of a beautiful coming weekend,
tami:)
PS. to make it work on my sidux I had to exchange ” ’ ” (rightsinglequotemark) with ” ‘ ” (apostrophe) – this is probably connected with website encoding… 😦 ….
August 9, 2007 at 11:47 pm
MalsdadMonk
tami –
ctrl-D on an empty line, yes that is what we meant by pressing first… we didn’t understand at first that it needed to be on an empty line!
source .bashrc in the terminal – thank you for that! so, no need to even close and re-open the terminal?
and regarding your PS, yes we found we could not copy directly from the website because of the same reason that you found.
this has been very good, I have learned some things!! thank you, and I hope you have a wonderful weekend as well!
malsdad
July 23, 2017 at 6:26 pm
xhentric
I like this idea very much and began implementing it on the 5th of July (2017).
I implemented it on a network of machines which introduced a layer of complexity in keeping the “notes directories” synchronized which forced me to finally learn about Samba! This was all inspired and motivated by the ideas you posted here.
I never thanked you yet, so, I am saying thank you for sharing this awesome idea. I love it. It will save much paper and it is easy to search.
Add to your .bashrc the following, and then issue the command:
wherein /home/name/diary “whatever text you are looking for”
———————————————————————————————-
wherein ()
{
for i in $(find “$1” -type f 2> /dev/null);
do
if grep –color=auto -i “$2” “$i” 2> /dev/null; then
echo -e “\033[0;32mFound in: $i \033[0m\n”;
grep –color=always -in “$2” “$i” {} 2>/dev/null +
fi;
done
}
—————————————————————————