mirror of
https://github.com/denisidoro/navi
synced 2024-11-22 11:33:10 +00:00
parent
5acdb2a4b2
commit
1c9ffde3ec
4 changed files with 21 additions and 6 deletions
|
@ -61,9 +61,10 @@ $ mapped: echo 'false true' | tr ' ' '\n' --- --map "grep -q t && echo 1 || echo
|
||||||
```
|
```
|
||||||
|
|
||||||
The supported parameters are:
|
The supported parameters are:
|
||||||
- `--prevent-extra` *(experimental)*: limits the user to select one of the suggestions;
|
|
||||||
- `--column <number>`: extracts a single column from the selected result;
|
- `--column <number>`: extracts a single column from the selected result;
|
||||||
- `--map <bash_code>` *(experimental)*: applies a map function to the selected variable value;
|
- `--map <bash_code>` *(experimental)*: applies a map function to the selected variable value;
|
||||||
|
- `--prevent-extra` *(experimental)*: limits the user to select one of the suggestions;
|
||||||
|
- `--fzf-overrides <arg>` *(experimental)*: applies arbitrary `fzf` overrides;
|
||||||
|
|
||||||
In addition, it's possible to forward the following parameters to `fzf`:
|
In addition, it's possible to forward the following parameters to `fzf`:
|
||||||
- `--multi`;
|
- `--multi`;
|
||||||
|
|
16
src/actor.rs
16
src/actor.rs
|
@ -30,7 +30,7 @@ fn prompt_finder(
|
||||||
|
|
||||||
let mut extra_preview = None;
|
let mut extra_preview = None;
|
||||||
|
|
||||||
let (suggestions, opts) = if let Some(s) = suggestion {
|
let (suggestions, initial_opts) = if let Some(s) = suggestion {
|
||||||
let (suggestion_command, suggestion_opts) = s;
|
let (suggestion_command, suggestion_opts) = s;
|
||||||
|
|
||||||
if let Some(sopts) = suggestion_opts {
|
if let Some(sopts) = suggestion_opts {
|
||||||
|
@ -68,8 +68,18 @@ fn prompt_finder(
|
||||||
('\n'.to_string(), &None)
|
('\n'.to_string(), &None)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let overrides = {
|
||||||
|
let mut o = config.fzf_overrides.clone();
|
||||||
|
if let Some(io) = initial_opts {
|
||||||
|
if io.overrides.is_some() {
|
||||||
|
o = io.overrides.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
o
|
||||||
|
};
|
||||||
|
|
||||||
let mut opts = FinderOpts {
|
let mut opts = FinderOpts {
|
||||||
overrides: config.fzf_overrides_var.clone(),
|
overrides,
|
||||||
preview: Some(format!(
|
preview: Some(format!(
|
||||||
r#"{prefix}navi preview-var "$(cat <<NAVIEOF
|
r#"{prefix}navi preview-var "$(cat <<NAVIEOF
|
||||||
{{+}}
|
{{+}}
|
||||||
|
@ -83,7 +93,7 @@ NAVIEOF
|
||||||
name = variable_name,
|
name = variable_name,
|
||||||
extra = extra_preview.clone().unwrap_or_default()
|
extra = extra_preview.clone().unwrap_or_default()
|
||||||
)),
|
)),
|
||||||
..opts.clone().unwrap_or_default()
|
..initial_opts.clone().unwrap_or_default()
|
||||||
};
|
};
|
||||||
|
|
||||||
opts.query = env_var::get(format!("{}__query", variable_name)).ok();
|
opts.query = env_var::get(format!("{}__query", variable_name)).ok();
|
||||||
|
|
|
@ -59,7 +59,7 @@ fn parse_opts(text: &str) -> Result<FinderOpts, Error> {
|
||||||
"--preview" => opts.preview = Some(value.to_string()),
|
"--preview" => opts.preview = Some(value.to_string()),
|
||||||
"--preview-window" => opts.preview_window = Some(value.to_string()),
|
"--preview-window" => opts.preview_window = Some(value.to_string()),
|
||||||
"--header" => opts.header = Some(value.to_string()),
|
"--header" => opts.header = Some(value.to_string()),
|
||||||
"--overrides" => opts.overrides = Some(value.to_string()),
|
"--fzf-overrides" => opts.overrides = Some(value.to_string()),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -56,11 +56,14 @@ echo description one character
|
||||||
# map can be used to expand into multiple arguments
|
# map can be used to expand into multiple arguments
|
||||||
for l in <phrases>; do echo "line: $l"; done
|
for l in <phrases>; do echo "line: $l"; done
|
||||||
|
|
||||||
|
# x
|
||||||
|
echo <with_overrides>
|
||||||
|
|
||||||
# Concatenate pdf files
|
# Concatenate pdf files
|
||||||
files=($(echo "<files>"))
|
files=($(echo "<files>"))
|
||||||
echo pdftk "${files[@]:-}" cat output <pdf_output>
|
echo pdftk "${files[@]:-}" cat output <pdf_output>
|
||||||
|
|
||||||
$ files: echo 'file1.pdf file2.pdf file3.pdf' | tr ' ' '\n' --- --multi --overrides '--tac'
|
$ files: echo 'file1.pdf file2.pdf file3.pdf' | tr ' ' '\n' --- --multi --fzf-overrides '--tac'
|
||||||
$ x: echo '1 2 3' | tr ' ' '\n'
|
$ x: echo '1 2 3' | tr ' ' '\n'
|
||||||
$ y: echo 'a b c' | tr ' ' '\n'
|
$ y: echo 'a b c' | tr ' ' '\n'
|
||||||
$ z: echo 'foo bar' | tr ' ' '\n'
|
$ z: echo 'foo bar' | tr ' ' '\n'
|
||||||
|
@ -73,6 +76,7 @@ $ examples: echo -e 'foo bar\nlorem ipsum\ndolor sit' --- --multi
|
||||||
$ multiword: echo -e 'foo bar\nlorem ipsum\ndolor sit\nbaz'i
|
$ multiword: echo -e 'foo bar\nlorem ipsum\ndolor sit\nbaz'i
|
||||||
$ file: ls . --- --preview 'cat {}' --preview-window 'right:50%'
|
$ file: ls . --- --preview 'cat {}' --preview-window 'right:50%'
|
||||||
$ phrases: echo -e "foo bar\nlorem ipsum\ndolor sit" --- --multi --map "navi fn map::expand"
|
$ phrases: echo -e "foo bar\nlorem ipsum\ndolor sit" --- --multi --map "navi fn map::expand"
|
||||||
|
$ with_overrides: echo -e "foo bar\nlorem ipsum\ndolor sit" --- --fzf-overrides "--margin=15% --bind=ctrl-u:replace-query"
|
||||||
|
|
||||||
# this should be displayed
|
# this should be displayed
|
||||||
echo hi
|
echo hi
|
||||||
|
|
Loading…
Reference in a new issue