Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Clearer explanation about .cheat file paths #864

Merged
merged 40 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6ab04ce
Update cheatsheet_syntax.md
tapyu Dec 3, 2023
2ae23b8
Update README.md
tapyu Dec 3, 2023
eb5c126
Update README.md
tapyu Dec 3, 2023
ec1eb7e
Update README.md
tapyu Dec 3, 2023
e011114
Update cheatsheet_syntax.md
tapyu Dec 3, 2023
df16803
Update cheatsheet_syntax.md
tapyu Dec 3, 2023
96ff6fe
Update cheatsheet_syntax.md
tapyu Dec 3, 2023
6689cfd
Update cheatsheet_syntax.md
tapyu Dec 3, 2023
dbd0774
Update cheatsheet_syntax.md
tapyu Dec 3, 2023
0f41e07
Update cheatsheet_syntax.md
tapyu Dec 3, 2023
7accaa4
Rename cheatsheet_syntax.md to cheatsheet_settings.md
tapyu Dec 4, 2023
18c549b
Rename cheatsheet_settings.md to cheatsheet_syntax.md
tapyu Dec 4, 2023
2af6571
Rename config_file.md to navi_config.md
tapyu Dec 4, 2023
924ffb8
Update cheatsheet_syntax.md
tapyu Dec 4, 2023
fdc5603
Update navi_config.md
tapyu Dec 4, 2023
ef1521f
Update cheatsheet_syntax.md
tapyu Dec 4, 2023
4e1aada
Update cheatsheet_syntax.md
tapyu Dec 4, 2023
3b7f5b9
Delete docs/aliases.md
tapyu Dec 4, 2023
ddf6e9c
Update navi_config.md
tapyu Dec 4, 2023
6118a85
Update navi_config.md
tapyu Dec 4, 2023
1180e8c
Update navi_config.md
tapyu Dec 4, 2023
6f16237
Update navi_config.md
tapyu Dec 4, 2023
1119164
Update navi_config.md
tapyu Dec 4, 2023
eb9ad7c
Update navi_config.md
tapyu Dec 4, 2023
196872b
introduce use env_logger
zjp-CN May 12, 2023
e2c4b2b
rm env_logger; use tracing instead
zjp-CN May 12, 2023
4d077ba
mv navi.log under config dir; debug folders on Windows
zjp-CN May 12, 2023
13318c4
Fix multiple paths: define the platform-specific join separator
zjp-CN May 13, 2023
2026b70
eprintln init_logger failure (may need redir if it's flushed away)
zjp-CN May 13, 2023
6822f1d
update config_file_example: add a cheats path example on Windows
zjp-CN May 13, 2023
2933740
If config path doesn't exist, navi won't log.
zjp-CN May 13, 2023
2f175e6
config_file_example: shell command should be `cmd.exe` on Windows
zjp-CN May 13, 2023
6a0accf
debug log
zjp-CN May 13, 2023
aeb9cd4
Fix preview: handle Windows NT UNC paths (`\\?\C:\foo`)
zjp-CN May 13, 2023
422d37f
documentation on paths and environment vars
tjex Nov 4, 2023
cac329e
doc: typo
tjex Nov 4, 2023
449141a
docs: clarity
tjex Nov 4, 2023
be8326d
docs: extra clarity
tjex Nov 4, 2023
00d5e9d
doc: file rename
tjex Nov 4, 2023
74ce5ad
Merge branch 'master' into tapyu-patch-1
denisidoro Dec 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ In particular, check [these instructions](https://github.com/denisidoro/navi/iss

## Cheatsheet repositories

Running **navi** for the first time will help you download and manage cheatsheets.
Running **navi** for the first time will help you download and manage cheatsheets. By default, they are soted at `~/.local/share/navi/cheats/`.

You can also:

Expand Down
39 changes: 0 additions & 39 deletions docs/aliases.md

This file was deleted.

44 changes: 40 additions & 4 deletions docs/cheatsheet_syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Variable dependency](#variable-dependency)
- [Multiline snippets](#multiline-snippets)
- [Variable as multiple arguments](#variable-as-multiple-arguments)
- [Aliases](#aliases)

### Syntax overview

Expand All @@ -31,10 +32,6 @@ Lines starting with:

All the other non-empty lines are considered as executable commands.

### Folder structure

It's irrelevant how many files are used to store cheatsheets. They can be all in a single file if you wish, as long as you split them accordingly with lines starting with `%`.

### Variables

The interface prompts for variable names inside brackets (eg `<branch>`).
Expand Down Expand Up @@ -146,3 +143,42 @@ cat <jsons>

$ jsons: find . -iname '*.json' -type f -print --- --multi --expand
```
### Aliases

**navi** doesn't have support for aliases as first-class citizens at the moment.

However, it is trivial to create aliases using **navi** + a few conventions.

For example, suppose you decide to end some of your commands with `:: <some_alias>`:

```bash
% aliases

# This is one command :: el
echo lorem ipsum

# This is another command :: ef
echo foo bar
```

Then, if you use **navi** as a [shell scripting tool](shell_scripting.md), you could add something similar to this in your `.bashrc`-like file:

```bash
navialias() {
navi --query ":: $1" --best-match
}

alias el="navialias el"
alias ef="navialias ef"
```

If you don't want to use these conventions, you can even add full comments in your aliases:

```bash
navibestmatch() {
navi --query "$1" --best-match
}

alias el="navibestmatch 'This is one command'"
alias ef="navibestmatch 'This is another command'"
```
32 changes: 32 additions & 0 deletions docs/navi_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Config file path

The default config file path is set by the `$NAVI_CONFIG` environment variable. If it is not set, it fallbacks to `~/.config/navi/config.yaml`. The command
```sh
navi info config-path
```
prints which config file path is being used. You can get an config file example by running
```sh
navi info config-example
```
or by clicking [here](./config_file_example.yaml). To turn this example your config file, run

```sh
navi info config-example > "$(navi info config-path)"
```
## Cheat sheet paths

The default `.cheat` files paths are defined in the `$NAVI_PATH` environment variable in a colon-separated list, e.g.,
```sh
export NAVI_PATH='/path/to/a/dir:/path/to/another/dir:/yet/another/dir'
```
If this environment variable is unset or if all directories do not exist, `navi` uses that paths defined in its config files. Finally, if there is no config file or if the `.cheat` file paths was not set, the default `.cheat` file paths fallbacks to `~/.local/share/navi/cheats/`. The command
```sh
navi info cheats-path
```
prints to you all paths used to search for `.cheat` files.

You can also add other paths at runtime by running `navi` with the `--path` option and a colon-separed paths list, e.g.,
```sh
navi --path '/some/dir:/other/dir'
```
It's irrelevant the directory structure within each path. They can even be all in a single file if you wish, as long as you split them accordingly with lines starting with `%`.
Loading