Merge branch 'denisidoro:master' into test_changes

This commit is contained in:
Emmanuel Fidelis 2026-04-06 00:58:27 +01:00 committed by GitHub
commit 0d4c573dad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 64 additions and 0 deletions

View file

@ -26,6 +26,8 @@ jobs:
target: armv7-linux-androideabi
- os: ubuntu-latest
target: aarch64-linux-android
- os: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-latest

View file

@ -231,3 +231,45 @@ finder:
You can override this configuration with the `--delimiter` instruction in the variable definition of your cheat.\
See [/docs/cheatsheet/syntax/](/docs/cheatsheet/syntax/README.md#advanced-variable-options) for more details.
## Changing shell
You can change the shell that is used inside navi.
```yaml
shell:
command: bash
finder_command: bash
```
`shell.command` is used to execute commands that generate possible values for variables.
`shell.finder_command` is used inside fzf.
For example, suppose you have the following cheat sheet.
```
# ISO 8061
date -I<iso_unit>
$ iso_unit: echo -e 'date\nhours\nminutes\nseconds\nns'
```
The command `echo -e 'date\nhours\nminutes\nseconds\nns'` is executed in the shell specified by `shell.command`.
### Use bash on Windows
On Windows, there are several bash environments available, including MSYS2's bash, Git Bash, and [w64devkit](https://github.com/skeeto/w64devkit)'s bash.
The w64devkit's bash isn't actually bash, but it can be used just like bash.
Here is an example of using Git Bash.
```yaml
shell:
command: "\"C:/Program Files/Git/bin/bash.exe\""
finder_command: "C:/Program Files/Git/bin/bash.exe"
forward_slash_path: true
```
If the path to the executable contains spaces, it must be quoted in the `shell.command`.
Unlike `shell.command`, `shell.finder_command` does not require the path to be quoted even if it contains spaces.
Additionaly, `shell.forward_slash_path` must be set to `true`.
`shell.forward_slash_path: true` can be used with bash environments that interpret paths with forward slashes (e.g., `C:/path/to/bash.exe`).
Other than Windows, setting `shell.forward_slash_path` has no effect.

View file

@ -90,6 +90,20 @@ fn exe_abs_string() -> Result<String> {
pathbuf_to_string(&exe_pathbuf()?)
}
#[cfg(target_family = "windows")]
pub fn exe_string() -> String {
exe_abs_string()
.map(|exe| {
if CONFIG.forward_slash_path() {
exe.replace("\\", "/")
} else {
exe
}
})
.unwrap_or_else(|_| "navi".to_string())
}
#[cfg(not(target_family = "windows"))]
pub fn exe_string() -> String {
exe_abs_string().unwrap_or_else(|_| "navi".to_string())
}

View file

@ -146,6 +146,10 @@ impl Config {
.unwrap_or_else(|| self.yaml.shell.command.clone())
}
pub fn forward_slash_path(&self) -> bool {
self.yaml.shell.forward_slash_path
}
pub fn tag_rules(&self) -> Option<String> {
self.clap
.tag_rules

View file

@ -77,6 +77,7 @@ pub struct Search {
pub struct Shell {
pub command: String,
pub finder_command: Option<String>,
pub forward_slash_path: bool,
}
#[derive(Deserialize, Debug)]
@ -187,6 +188,7 @@ impl Default for Shell {
Self {
command: "bash".to_string(),
finder_command: None,
forward_slash_path: false,
}
}
}