Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Clearer explanation about .cheat file paths #861

Merged
merged 24 commits into from
Dec 10, 2023
Merged

Clearer explanation about .cheat file paths #861

merged 24 commits into from
Dec 10, 2023

Conversation

tapyu
Copy link
Contributor

@tapyu tapyu commented Dec 3, 2023

closes #860

Copy link

welcome bot commented Dec 3, 2023

Thanks for opening this pull request!

@tapyu tapyu changed the title Update cheatsheet_syntax.md Clearer explanation about .cheat file paths Dec 3, 2023
@tapyu tapyu marked this pull request as draft December 4, 2023 00:42
Comment on lines -34 to -37
### 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 `%`.

Copy link
Contributor Author

@tapyu tapyu Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This information isn't about the cheat sheet syntax. Rather, it is a information about the navi cheat sheet settings. Therefore, it is lost among the cheatsheet syntax information.

I am proposing to merge this information into the former config_file.md file and rename it to navi_config.md. It should contain all navi config info, whether config file or cheat sheet config.

Comment on lines 1 to 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 this 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.,
```
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 there is no `.cheat` file paths settings there, the default `.cheat` file path 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 `%`.
Copy link
Contributor Author

@tapyu tapyu Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new file addresses both the navi config cheat sheet settings. I also tried to explain all issues commented on #860. Any correction on my understanding is welcome.

Comment on lines -1 to -39
## 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'"
```
Copy link
Contributor Author

@tapyu tapyu Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aliasing is also about the cheat sheet syntax. I honestly didn't understand why one has a separate markdown file to address it.

My proposal is to put it into docs/cheatsheet_syntax.md.

@tapyu tapyu marked this pull request as ready for review December 4, 2023 07:06
@denisidoro denisidoro merged commit eb9ad7c into denisidoro:master Dec 10, 2023
1 check passed
Copy link

welcome bot commented Dec 10, 2023

Congrats on merging your first pull request!

@denisidoro
Copy link
Owner

Closing in favor of #864 (had to fix merge conflicts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clearer information about the .cheat files and navi config paths
2 participants