Originally posted (me: vstuart) as a comment on HackerNews

Ask HN: Coding notes – how do you do them?

[~Feb 02, 2017] For years I kept my coding notes in spiral bound A4 and A5 notebooks. Handwritten notes are quick to create, but hard to search. [ … snip … ] What new solutions are there for capturing and organizing coding notes? How do you do it?

[7 points by vstuart 219 days ago (~Feb 02, 2017)]

Here’s what I do:

  • keep my notes in a flat, plain-text “reference” file
  • key items/entries prefaced/abbreviated with leading double underscores; e.g.


My bash script (ref.sh):

    # ref.sh
    # https://stackoverflow.com/questions/7131670/make-bash-alias-that-takes-parameter

    grep  -i  -A10000  --color=always  __$1  /home/victoria/projects/shortcuts/reference  |  more

My ~/.bashrc alias:

    # search my Reference file for argument, tagged (prepended) with two
    # leading underscores (e.g.: 'ref wget' finds '__wget'):

    alias ref='/mnt/Vancouver/Programming/scripts/ref.sh'
    alias ?='/mnt/Vancouver/Programming/scripts/ref.sh'

    # "free" (unlimited) grep search of my '/mnt/Vancouver/ .reference' file
    # (e.g. 'ref rename' : i.e., not limited by double-underscore tag):

    alias refgrep='/mnt/Vancouver/Programming/scripts/refgrep.sh'

When I want to find a note quickly, I launch a terminal, search, then exit out (~/.bashrc alias qq). E.g.:

$ ref grep


Here is my refgrep.sh bash script:

    # refgrep.sh
    # https://stackoverflow.com/questions/7131670/make-bash-alias-...

    grep -i -A10 --color=always $1 /home/victoria/projects/shortcuts/reference | more

With either script  | ~/.bashrc alias,

        ref.sh | ref
    refgrep.sh | refgrep

partial strings are automatically searched.

[ I created/sometimes use my refgrep script as sometimes I can’t remember the name of a specific __<entry>. ]

For example, if you have two or more placemarkers that are similar,

  • __python ; __pythonpath), ref py will find the first one
  • simply extending the string, ref pythonp (a more specific search) will find the the second one

Similarly, refgrep <string> will find (the first occurrence) of that string, anywhere in the reference file.

I use that reference file for everything that I might want to quickly find (literally: seconds):

  • programming
  • birthdays
  • phone numbers*
  • prescriptions, doctors
  • programmatic notes
  • you name it!

Just pop open a terminal; search (ref <string>); read; quit terminal.