chubin / chubin/cheat.sh

Multiple search terms in context, interpolation and running

Open
#166 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
41.7k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I propose to extend the behavior of the program in the following ways:
- Feature 1: The search should also include multiple terms;
- Feature 2: When you search a phrase in the _dotfiles_ using the new context option (example: x), the search should include the comments associated;
- Feature 3: Variable interpolation in the output, if variable is passed to _curl_.
- Feature 4: Shell variable interpolation in the output if the variable is declared and a new option (example: n) is passed to the client _cht.sh_;
- Feature 5: Any entry shoud have an ID (Autoadded during the search phase), so you can execute easily the command from client _cht.sh_ using a new option (example: r).

### Example of dotfiles.
`cat tar`
```bash
# To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/

# To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
```

`cat tar_2`
```bash
# To extract an archive.
# Tag: archive, extract
tar xf ${ARCHIVE_1}

# To extract an archive, verbose output.
# Tag: archive, extract
tar xvf ${ARCHIVE_2}
```

### Example of search command
Calls cheat from curl:
`curl cheat.sh/~tar+~extract/X/ARCHIVE_1='myfile.tar'`

Or call cheat from _cht.sh_:
Set variable for shell variable interpolation.
`ARCHIVE_1='myfile.tar'`
`cht.sh -n -x tar extract`

**Expected output:**
```bash
# To extract an uncompressed archive:
# ID: 143
tar -xvf /path/to/foo.tar

# Extracts an archive.
# Tag: archive, extract
# ID: 151
tar xf myfile.tar

# Extracts an archive, verbose output.
# Tag: archive, extract
# ID: 152
tar xvf ${ARCHIVE_2}
```

Note:
- Dynamic ID appears in the output. The ID doesn't change if the search context (tag and loading path) remains the same;
- Shell variable interpolarion is performed using variable defined previously.

### Example of run command
To recall and execute a cheat:
`cht.sh -r 151`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.