Skip to content

Filter/Choose: Set starting position of indicator by value #337

@sadamczyk

Description

@sadamczyk

Is your feature request related to a problem? Please describe.
When using gum choose or gum filter, it might be that one of the available options will be most commonly chosen,
or makes the most sense based on the current environment, current working directory etc.

Describe the solution you'd like
I'd like the option to set the intial position of the indicator to a specific value.
This would allow a fast and convenient choice of the most common options, by just hitting Enter repeatedly.
An additional flag like f.e. --indicator-value="my_value". There is probably a better name.

Describe alternatives you've considered
For filter I could set the --value flag, choose has --selected.
The problem with this is, that it

  1. hides all the other options, and/or
  2. forces me to first delete the current filter/selection, in case I do want to pick another option after all.

Setting the indicator would have the best of both worlds:

  1. Quick selection of the default option.
  2. If I don't want the default option, I can immediately start typing to filter the results, without having to clear the filter first.

Additional context
It might make sense to also allow setting the starting position by index, instead of the value.
Something like --indicator-index=3? For my personal use case this wouldn't be very useful though.

Adding an additional flag also allows combining these flags together for even finer control.
Using --selected and --indicator-value together allows listing all the "default" options first pre-selected, and then starting the indicator after all the default options, so one doesn't have to move through all the default options first.

Using --value and --indicator-value together allows pre-filtering to reduce a large amount of options, and then having the indicator set on the most probable choice of those pre-filtered options.
Problem: What if --value filters out the option, that was supposed to be used by --indicator-value?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions