Skip to content

Commit

Permalink
Merge pull request #941 from kit494way/config-delimiter
Browse files Browse the repository at this point in the history
Allow delimiter variable option to be set from config.yaml
  • Loading branch information
denisidoro authored Feb 13, 2025
2 parents 5515367 + dc59652 commit 72b0d14
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/config_file_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ finder:
command: fzf # equivalent to the --finder option
# overrides: --tac # equivalent to the --fzf-overrides option
# overrides_var: --tac # equivalent to the --fzf-overrides-var option
# delimiter_var: \s\s+ # equivalent to the --delimiter option that is used with --column option when you extract a column from the selected result for a variable

# cheats:
# paths:
Expand Down
4 changes: 4 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ impl Config {
.or_else(|| self.yaml.finder.overrides_var.clone())
}

pub fn delimiter_var(&self) -> Option<String> {
self.yaml.finder.delimiter_var.clone()
}

pub fn tealdeer(&self) -> bool {
self.yaml.client.tealdeer
}
Expand Down
2 changes: 2 additions & 0 deletions src/config/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct Finder {
pub command: FinderChoice,
pub overrides: Option<String>,
pub overrides_var: Option<String>,
pub delimiter_var: Option<String>,
}

fn finder_deserialize<'de, D>(deserializer: D) -> Result<FinderChoice, D::Error>
Expand Down Expand Up @@ -158,6 +159,7 @@ impl Default for Finder {
command: FinderChoice::Fzf,
overrides: None,
overrides_var: None,
delimiter_var: None,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/finder/structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl Opts {
overrides: CONFIG.fzf_overrides_var(),
suggestion_type: SuggestionType::SingleRecommendation,
prevent_select1: false,
delimiter: CONFIG.delimiter_var(),
..Default::default()
}
}
Expand Down

0 comments on commit 72b0d14

Please sign in to comment.