From cee5b5599b612d69e1b7232bc548553152a1ede3 Mon Sep 17 00:00:00 2001 From: Scott Shipp Date: Wed, 6 Oct 2021 14:44:23 -0700 Subject: [PATCH 1/2] Add grep command --- README.md | 18 ++++++++--- noted | 9 +++++- subcommands.md | 87 ++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 87 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index a377ce5..2474bdc 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,28 @@ + + # noted _Lightweight CLI for taking markdown notes in a journal-like (time-seried) fashion on macOS._ ## Contents + + + - [Features](#features) - [Getting Started](#getting-started) - * [Required steps](#required-steps) - * [Optional steps](#optional-steps) + - [Required steps](#required-steps) + - [Optional steps](#optional-steps) - [Typical usage](#typical-usage) - [Subcommand reference](#subcommand-reference) - [Configuration guide](#configuration-guide) - * [Default values](#default-values) - * [Configuring custom values](#configuring-custom-values) - * [Custom template file](#custom-template-file) + - [Default values](#default-values) + - [Configuring custom values](#configuring-custom-values) + - [Custom template file](#custom-template-file) - [Recommended aliases](#recommended-aliases) +- [Usage with a static site generator](#usage-with-a-static-site-generator) + + ## Features diff --git a/noted b/noted index 7d9a9bf..4d23612 100755 --- a/noted +++ b/noted @@ -75,6 +75,10 @@ markdownFile() { markdownFile="${NOTED_MARKDOWN_HOME}/${1}.md" } +ngrep() { + grep --recursive "$@" "${NOTED_MARKDOWN_HOME}" +} + outputConfig() { echo "The following configuration is currently being used:" echo "NOTED_MARKDOWN_HOME=${NOTED_MARKDOWN_HOME}" @@ -102,7 +106,7 @@ view() { # END FUNCTIONS # -VERSION="0.0.1" +VERSION="0.0.2" # # Default Settings @@ -142,6 +146,9 @@ elif [[ "${subcommand}" == "edit" ]] || [[ "${subcommand}" == "view" ]]; then fi markdownFile "${arg}" edit "${markdownFile}" +elif [[ "${subcommand}" == "grep" ]]; then + shift + ngrep "$@" else # create / default OPTIONAL_FILE="" diff --git a/subcommands.md b/subcommands.md index b97d146..c5eedfb 100644 --- a/subcommands.md +++ b/subcommands.md @@ -4,27 +4,37 @@ All uses of `noted` require a subcommand. If one is not supplied, the default `c ## Contents -* [List of Subcommands](#list-of-subcommands) - + [config](#config) - - [Synopsis](#synopsis) - - [Overview](#overview) - - [Arguments & Flags](#arguments---flags) - - [Examples](#examples) - + [create](#create) - - [Synopsis](#synopsis-1) - - [Overview](#overview-1) - - [Arguments & Flags](#arguments---flags-1) - - [Examples](#examples-1) - + [edit / view](#edit---view) - - [Synopsis](#synopsis-2) - - [Overview](#overview-2) - - [Arguments & Flags](#arguments---flags-2) - - [Examples](#examples-2) - + [version](#version) - - [Synopsis](#synopsis-3) - - [Overview](#overview-3) - - [Arguments & Flags](#arguments---flags-3) - - [Examples](#examples-3) + + + +- [List of Subcommands](#list-of-subcommands) + - [config](#config) + - [Synopsis](#synopsis) + - [Overview](#overview) + - [Arguments & Flags](#arguments--flags) + - [Examples](#examples) + - [create](#create) + - [Synopsis](#synopsis-1) + - [Overview](#overview-1) + - [Arguments & Flags](#arguments--flags-1) + - [Examples](#examples-1) + - [edit / view](#edit--view) + - [Synopsis](#synopsis-2) + - [Overview](#overview-2) + - [Arguments & Flags](#arguments--flags-2) + - [Examples](#examples-2) + - [grep](#grep) + - [Synopsis](#synopsis-3) + - [Overview](#overview-3) + - [Arguments & Flags](#arguments--flags-3) + - [Examples](#examples-3) + - [version](#version) + - [Synopsis](#synopsis-4) + - [Overview](#overview-4) + - [Arguments & Flags](#arguments--flags-4) + - [Examples](#examples-4) + + ## List of Subcommands @@ -159,6 +169,41 @@ Open a file named `process.md`: noted view process ``` +### grep + +Shortcut for running a recursive grep in your configured notes directory. + +#### Synopsis + +```shell +noted grep [ARGUMENTS (optional)] [SEARCH_TERM (required)] +``` + +#### Overview + +Runs `grep -r [NOTED_MARKDOWN_HOME]` and also passes along any arguments you supply. + +> REMINDER: +> `$NOTED_MARKDOWN_HOME` is configured to `$HOME/Documents/notes` by default but can be overridden in the `$HOME/.notedconfig` file. See the [configuration guide](README.md#configuration-guide) for more. + +#### Arguments & Flags + +Any arguments that grep accepts can be passed. + +#### Examples + +Perform a case-insensitive search for the term "Java." + +```shell +noted grep -i java +``` + +Perform a search for "Jenkins" and show line numbers: + +```shell +noted grep Jenkins -n +``` + ### version View the current version of `noted`. From 239132743d3d2dc2ac725a5c2ccdac00bfedf065 Mon Sep 17 00:00:00 2001 From: Scott Shipp Date: Wed, 6 Oct 2021 14:48:08 -0700 Subject: [PATCH 2/2] Increase all headers by one on subcommand guide --- subcommands.md | 102 ++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/subcommands.md b/subcommands.md index c5eedfb..c4ddd39 100644 --- a/subcommands.md +++ b/subcommands.md @@ -7,59 +7,57 @@ All uses of `noted` require a subcommand. If one is not supplied, the default `c -- [List of Subcommands](#list-of-subcommands) - - [config](#config) - - [Synopsis](#synopsis) - - [Overview](#overview) - - [Arguments & Flags](#arguments--flags) - - [Examples](#examples) - - [create](#create) - - [Synopsis](#synopsis-1) - - [Overview](#overview-1) - - [Arguments & Flags](#arguments--flags-1) - - [Examples](#examples-1) - - [edit / view](#edit--view) - - [Synopsis](#synopsis-2) - - [Overview](#overview-2) - - [Arguments & Flags](#arguments--flags-2) - - [Examples](#examples-2) - - [grep](#grep) - - [Synopsis](#synopsis-3) - - [Overview](#overview-3) - - [Arguments & Flags](#arguments--flags-3) - - [Examples](#examples-3) - - [version](#version) - - [Synopsis](#synopsis-4) - - [Overview](#overview-4) - - [Arguments & Flags](#arguments--flags-4) - - [Examples](#examples-4) +- [config](#config) + - [Synopsis](#synopsis) + - [Overview](#overview) + - [Arguments & Flags](#arguments--flags) + - [Examples](#examples) +- [create](#create) + - [Synopsis](#synopsis-1) + - [Overview](#overview-1) + - [Arguments & Flags](#arguments--flags-1) + - [Examples](#examples-1) +- [edit / view](#edit--view) + - [Synopsis](#synopsis-2) + - [Overview](#overview-2) + - [Arguments & Flags](#arguments--flags-2) + - [Examples](#examples-2) +- [grep](#grep) + - [Synopsis](#synopsis-3) + - [Overview](#overview-3) + - [Arguments & Flags](#arguments--flags-3) + - [Examples](#examples-3) +- [version](#version) + - [Synopsis](#synopsis-4) + - [Overview](#overview-4) + - [Arguments & Flags](#arguments--flags-4) + - [Examples](#examples-4) -## List of Subcommands -### config +## config Lists the current configuration for _noted_. This is the combination of default values plus whatever is found in `$HOME/.notedconfig`, where values in `$HOME/.notedconfig` take precedence. -#### Synopsis +### Synopsis ```shell noted config ``` -#### Overview +### Overview The config subcommand will: - Generate a quick view of the resulting configuration after applying the values in `$HOME/.notedconfig` -#### Arguments & Flags +### Arguments & Flags N/A -#### Examples +### Examples View configuration: @@ -67,17 +65,17 @@ View configuration: noted config ``` -### create +## create Create a new note. -#### Synopsis +### Synopsis ```shell noted create [Quoted text to use (optional)] [ALTERNATE_FILE_NAME (optional)] ``` -#### Overview +### Overview The create subcommand will: @@ -91,13 +89,13 @@ The create subcommand will: > We encourage users to omit `create` and use the alternate shorthand `noted` without the create keyword. The remainder > of this documentation will use the shorthand. -#### Arguments & Flags +### Arguments & Flags Both arguments are optional. When quoted text is included the text will automatically be appended to the entry and editing of the entry will be skipped. When the `ALTERNATE_FILE_NAME` argument is supplied with a filename, then instead of using the automatic file (named with today's date), the file supplied will be used. -#### Examples +### Examples Start a new entry: @@ -117,11 +115,11 @@ Start a new entry in the file named `process.md`: noted 'Some note' process.md ``` -### edit / view +## edit / view Open a specific note file, or today's file if no file is specified, in the default editor. -#### Synopsis +### Synopsis ```shell noted edit [FILE (optional)] @@ -131,7 +129,7 @@ noted edit [FILE (optional)] noted view [FILE (optional)] ``` -#### Overview +### Overview Edit and view are interchangeable. @@ -145,11 +143,11 @@ The edit / view subcommand will: > Edit is different than create. Create will also populate a new note entry into the given file using the template. > Edit, on the other hand, will merely open the file. -#### Arguments & Flags +### Arguments & Flags The `FILE` argument is optional. You should not include the extension. The Markdown extension `.md` is assumed. -#### Examples +### Examples Open today's file in the default editor. @@ -169,28 +167,28 @@ Open a file named `process.md`: noted view process ``` -### grep +## grep Shortcut for running a recursive grep in your configured notes directory. -#### Synopsis +### Synopsis ```shell noted grep [ARGUMENTS (optional)] [SEARCH_TERM (required)] ``` -#### Overview +### Overview Runs `grep -r [NOTED_MARKDOWN_HOME]` and also passes along any arguments you supply. > REMINDER: > `$NOTED_MARKDOWN_HOME` is configured to `$HOME/Documents/notes` by default but can be overridden in the `$HOME/.notedconfig` file. See the [configuration guide](README.md#configuration-guide) for more. -#### Arguments & Flags +### Arguments & Flags Any arguments that grep accepts can be passed. -#### Examples +### Examples Perform a case-insensitive search for the term "Java." @@ -204,25 +202,25 @@ Perform a search for "Jenkins" and show line numbers: noted grep Jenkins -n ``` -### version +## version View the current version of `noted`. -#### Synopsis +### Synopsis ```shell noted version ``` -#### Overview +### Overview The version subcommand will print out the current version of `noted`. -#### Arguments & Flags +### Arguments & Flags N/A -#### Examples +### Examples View the version: