Skip to content

Commit

Permalink
read custom editor from environment (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
TeFiLeDo authored Nov 2, 2023
1 parent 083a888 commit 5ab8377
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ Users can provide their own command used to open selected match using `--custom-

`--custom-command "vim +{line_number} {file_name}"`

The same argument can also be passed via the `$IGREP_CUSTOM_EDITOR` environment variable. Example:

`IGREP_CUSTOM_EDITOR="vim +{line_number} {file_name}"`

## Installation
### Prebuilt binaries
`igrep` binaries can be downloaded from [GitHub](https://github.com/konradsz/igrep/releases).
Expand Down
3 changes: 2 additions & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{
path::PathBuf,
};

pub const IGREP_CUSTOM_EDITOR_ENV: &str = "IGREP_CUSTOM_EDITOR";
pub const IGREP_EDITOR_ENV: &str = "IGREP_EDITOR";
pub const EDITOR_ENV: &str = "EDITOR";
pub const RIPGREP_CONFIG_PATH_ENV: &str = "RIPGREP_CONFIG_PATH";
Expand Down Expand Up @@ -68,7 +69,7 @@ pub struct EditorOpt {
pub editor: Option<Editor>,

/// Custom command used to open selected match. Must contain {file_name} and {line_number} tokens.
#[clap(long)]
#[clap(long, env = IGREP_CUSTOM_EDITOR_ENV)]
pub custom_command: Option<String>,
}

Expand Down

0 comments on commit 5ab8377

Please sign in to comment.