Skip to content

Commit

Permalink
Merge pull request #2 from scottashipp/feature/ngrep
Browse files Browse the repository at this point in the history
Add grep command
  • Loading branch information
scottashipp committed Oct 11, 2021
2 parents 7154c45 + 2391327 commit 956afd0
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 50 deletions.
18 changes: 13 additions & 5 deletions README.md
@@ -1,20 +1,28 @@


# noted

_Lightweight CLI for taking markdown notes in a journal-like (time-seried) fashion on macOS._

## Contents

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [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)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Features

Expand Down
9 changes: 8 additions & 1 deletion noted
Expand Up @@ -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}"
Expand Down Expand Up @@ -102,7 +106,7 @@ view() {
# END FUNCTIONS
#

VERSION="0.0.1"
VERSION="0.0.2"

#
# Default Settings
Expand Down Expand Up @@ -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=""
Expand Down
131 changes: 87 additions & 44 deletions subcommands.md
Expand Up @@ -4,70 +4,78 @@ 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

### config
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [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)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->


## 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:

```shell
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:

Expand All @@ -81,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:

Expand All @@ -107,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)]
Expand All @@ -121,7 +129,7 @@ noted edit [FILE (optional)]
noted view [FILE (optional)]
```

#### Overview
### Overview

Edit and view are interchangeable.

Expand All @@ -135,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.

Expand All @@ -159,25 +167,60 @@ Open a file named `process.md`:
noted view process
```

### version
## 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`.

#### 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:

Expand Down

0 comments on commit 956afd0

Please sign in to comment.