diff --git a/interface.go b/interface.go index e74fbe1..cacc98f 100644 --- a/interface.go +++ b/interface.go @@ -68,7 +68,8 @@ type Peco struct { filters FilterSet keymap Keymap enableSep bool // Enable parsing on separators - initialQuery string // True if --query is specified + initialFilter string // populated if --initial-filter is specified + initialQuery string // populated if --query is specified inputseq Inputseq // current key sequence (just the names) layoutType string location Location diff --git a/peco.go b/peco.go index 99ebc0f..b0b4a5d 100644 --- a/peco.go +++ b/peco.go @@ -446,6 +446,18 @@ func (p *Peco) ApplyConfig(opts CLIOptions) error { return errors.Wrap(err, "failed to populate styles") } + if len(opts.OptInitialFilter) <= 0 && len(opts.OptInitialMatcher) > 0 { + p.initialFilter = opts.OptInitialMatcher + } else if len(opts.OptInitialFilter) > 0 { + p.initialFilter = opts.OptInitialFilter + } + + if v := p.initialFilter; v != "" { + if err := p.filters.SetCurrentByName(v); err != nil { + return errors.Wrap(err, "failed to set filter") + } + } + return nil }