Author Topic: Command Line Digital Diary  (Read 453 times)

0 Members and 1 Guest are viewing this topic.

Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4766
  • Life teaches me not to want it.
    • What Now?
Command Line Digital Diary
« on: July 05, 2017, 10:08:30 am »
As a way of not using so much paper in keeping daily notes on existence as well as technical notes, I created a folder in ~/ [home directory] called notes.

Before listing the details that should be placed in .bashrc (.profile if on a Mac - see this link), I will explain its usage so you might determine whether or not you would appreciate such a simple method of keeping a digital diary.  This will not work in Microsoft Windows without "cygwin", or - better still " Linux Bash Shell on Windows 10 ".

It needs the UNIX-like bash capabilities.

I type the command, notes, at the command line.

Then I begin typing my notes.  When done I press enter a couple times for some blank lines.  Then I press Ctrl+D which takes me back to the command line prompt.

No need for an editor or word processor.   Another few tips will also allow you to search for content.  This is a very grass roots solution, which is why I like it - very minimalistic.  If you need to edit what you typed, you can open as a text file with your editor of choice (nano, emacs, or any word processor such as LibreOffice Writer).
----------------------------------------------------------------------------
OK.  Now, the basics:

In ~/.bashrc (or your .profile in Mac), you would replace /home/mwh/notes with the path on your machine.


alias notes='cd /home/mwh/notes && date +%c | cat >> `date +%F` ;
cat >> `date +%F` ; echo | tac >> `date +%F`'

[thanks Tami]
________________________________________________________________
If you want to be able to search your notes with a command, "wherein," add the following to the .bashrc (or .profile):


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
}

---------------------------------------------------------------------------

example:

wherein ~/notes "mathematics"

would print on the screen what it finds and where:

Found in: /home/mwh/notes/2017-07-02

/home/mwh/notes/2017-07-02:215:Well, another day filled with studying mathematics.  The money I invested in this extensive library symbolizes my commitment to revisiting high school and undergraduate mathematics curriculum.  It sometimes seems impossible that I will be able to continue to devote all these hours to such rigorous study over the next five to ten years, but I am doing it.

/home/mwh/notes/2017-07-02:231:I will not even attempt to plan how long that will take or how I will proceed.  My hope is also to put some attention into the advanced mathematics of writing proofs and experiment with a great deal of computational physics.

/home/mwh/notes/2017-07-02:239:I am actually very proud of myself for having the courage to re-learn high school mathematics, taking the approach of those who had taken part in "New Mathematics" - using axioms, set builder notation, formality, and rigor.

---------------------------------------------------------------------------------------

This solution allows me to ramble on and repeat things without wasting paper or wasting other peoples attention on a message board or blog.

_________________________________________________________________
Note:  If you don't want to mess around with defining "wherein()" in your .bashrc file or .profile, there is "ack" which does the same thing.

You can find the version for your operating system at BEYOND GREP. (for Micronuts Windows, you need to first install chocolately and then choco install ack

It's a cool way to search for text within files.
Like I said, it takes the same arguments at the command line as our above self-defined function, wherein(), but in different order.

ack "Schopenhauer" ~/websites/whybother

____________________________________________________________
For Windows users, you may prefer install jrnl.sh.  I tried with pip install jrnl as well as downloading source "jrnl-master" and running pyhton setup.py install in the jrnl-master directory, but it still did not run.

So, as I am sometimes in Windows to use TI-Nspire Software, I am going to try to get some kind of command line digital diary working there as well.

I will tinker around with Linux Bash Shell on Windows 10 and see what I can learn.
-------------------------------------------------------------------
For Linux Bash on Windows 10 users:
Your .bashrc is in the directory you land in after typing cd ~

It should be /root if you installed with lxrun /install /y in cmd.exe (with administrative priviledges).

Add this to .bashrc then "source .bashrc":

alias notes='cd /mnt/c/Users/YourNameHere/notes && cat >> `date +%F` && date +%c | tac >> `date +%F`'

Of course, you would want to update that folder regularly to be sure it is in sync with other operating systems.  Sorry Holden.  I know this all sounds like it is not worth the trouble, and you could just type your notes into a word processor.

I just like the idea of being able to do this.
--------------------------------------------------------------------------------------

Until then, Holden, if you are using Mac OSX, there should not be a problem with the simple method I mention at the start of this post, of placing in .profile

alias notes='cd /home/mwh/notes && date +%c | cat >> `date +%F` ;
cat >> `date +%F` ; echo | tac >> `date +%F`'


PS:  Don't think I have abandoned the horror of existence theme.  I'm just losing myself in math and computing.  That's all I can do.  I also ordered some Gingko Biloba for my brain and Tumeric for the body's little aches and pains.

Rereading this post, I see that, especially when I am trying to leave precise technical instructions, unless someone were actually interested in doing this, it must appear to be so much gibberish.   When it works, it's like magic.
« Last Edit: July 06, 2017, 04:20:13 pm by Raskolnikov »
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~

Share on Facebook Share on Twitter


Nation of One

  • { }
  • { ∅, { ∅ } }
  • Posts: 4766
  • Life teaches me not to want it.
    • What Now?
Re: Command Line Digital Diary
« Reply #1 on: September 19, 2017, 11:27:47 am »
I feel compelled to comment that this command line diary I have "created" and implemented has become an invaluable resource to me which I use on a daily basis.  It has not only saved me the burden of writing down notes as I work (in a manic manner) but I am now able to search the contents of my "notes directory" when searching for technical details.

I have been using "ack" (ack-grep) even more so than the homemade "wherein".

_      /|
\  'o.O'
=(___)=
     U    ack!


It has not only played a crucial role in my documentation of setting up a cluster of machines on a network, but continues to help me keep track of the differences in installing and setting up certain key packages in diverse environments, such as Apache, MySQL, and PHP in Windows, Gentoo, and Arch Linux.

Such tasks had me running into the fields with a bottle of booze back in 2003 when I become severely depressed after graduating from the university with honors only to be stocking shelves at the grocery store (night shift) at the mercy of blockheads and mean-spirited coworkers.  Now that I have been out of such a harness, I am able to give this stuff the kind of attention it requires. 

Yesterday I worked all day drinking espresso and smoking hand-rolled cigarettes, and did not pause to eat food until around 5PM when I ate a full bowl of blackeyed peas (with garlic and onions and peppers).  I felt like a monk or prisoner.  All I needed was those beans (and coffee and tobacco and books and computers).  I thought of Holden and his beans.  I recalled when I first discovered blackeyed peas in the county jail back in 1987.  I have had a special love for these beans ever since.

I wonder how long I will go without eating today.

PS:  In the above post I mentioned that Windows users could use choco to install ack.  You can also use Strawberry (perl) and then cpan App::Ack

This is like grep on steroids.

-------------------------------------------------------------------------
My apologies if such things are irrelavant to our philosophical themes here.  As you know, the nature of the contents of my notes have been transforming over the past couple of years.  While I love paper notebooks for working with mathematics, it makes sense to keep the notes related to computing machines in digital format which can can be searched with tools such as ack.

I only mention this here because this command line diary has become a tool I use constantly.  As I said, it helped build itself!

If you ever decide to implement this idea, I would be glad to send the related notes or even guide you through the process.

I doubt you will be interested in such a thing unless you have a need for it.

It might be useful just for keeping track of literary ideas and then searching it.

To Whom It May Concern:  Forget about eating food for a few hours.  Install ACK!
« Last Edit: September 19, 2017, 04:34:04 pm by { { } } »
Things They Will Never Tell YouArthur Schopenhauer has been the most radical and defiant of all troublemakers.

Gorticide @ Nothing that is so, is so DOT edu

~ Tabak und Kaffee Süchtigen ~