-
Notifications
You must be signed in to change notification settings - Fork 0
noteSearch
holzkohlengrill edited this page Dec 15, 2023
·
2 revisions
You took a ton of notes and you want to find something very quickly. This function(s) provides you a list with the results + surrounding lines to keep track of the context you searched for.
We assume to have a folder structure like:
$ tree /meeting/notes
/meeting/notes
├── meeting-notes-2017.md
├── meeting-notes-2018.md
└── meeting-notes.md
Copy the function(s) into your ~/.bashrc
file and source
them (source ~/.bashrc
).
meetingNotesPath='/meeting/notes'
mSearch() {
# Search for current meeting-notes (meeting-notes.md)
# All arguments are optional
# Arg1: keyword to search for
# Arg2: Surrounding lines of matches
numPadLines=7
# "${2-${numPadLines}} ---> Use numPadLines if 2nd argument is unset
tac "${meetingNotesPath}/meeting-notes-${3-2018}.md" | grep -nC "${2-${numPadLines}}" -i "$1" --color=auto --group-separator=***********************************************************
printf "\n---\n\n++++++++++ Info: Text reversed (read: bottom > top) ++++++++++\n"
}
mSearchOld() {
# Search for older meeting-notes (meeting-notes-<year>.md)
# All arguments are optional
# Arg1: keyword to search for
# Arg2: Surrounding lines of matches
# Arg3: Use notes for year yyyy
numPadLines=7
tac "${meetingNotesPath}/meeting-notes-${3-2018}.md" | grep -nC "${2-${numPadLines}}" -i "$1" --color=auto --group-separator=***********************************************************
printf "\n---\n\n++++++++++ Info: Text reversed (read: bottom > top) ++++++++++\n"
}
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License *.
Code (snippets) are licensed under a MIT License *.
* Unless stated otherwise