Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autocomplete prompt action #657

Open
dg-pb opened this issue Dec 6, 2024 · 2 comments
Open

autocomplete prompt action #657

dg-pb opened this issue Dec 6, 2024 · 2 comments

Comments

@dg-pb
Copy link

dg-pb commented Dec 6, 2024

I have looked for this functionality, but could not find it.

What I would like is to be able to press "tab" which would replace prompt text with contents of highlighted line from the search list.

E.g.

  1. In prompt I type: >lib.*/lib.*
  2. I find /library/library path
  3. I press tab and my prompt becomes >/library/library

Thanks.

@LoricAndre
Copy link
Contributor

This could be interesting for some use-cases, we'll look into it.
This will have to wait probably a few weeks though, unless you or someone else feels like opening a PR, as I have my hands very full atm with ratatui

@dg-pb
Copy link
Author

dg-pb commented Dec 11, 2024

I think what could be a general extension is "replace prompt" with 2 variables:

sk --bind="ctrl+i:prompt_mod[${prompt} {}]"
# ${prompt} - current prompt contents
# {} - current highlighted item

Examples of applications:
a) Functionality I have indicated above
b) Binding a shortcut to toggle regex flags (and similar)

E.g. b):

function toggle_flag() {
    # parses input with flags and toggles desired one
}

sk --bind="ctrl+i:prompt_mod[toggle_flag ${prompt} i]"

So that:

  1. prompt: >(?s)regex input
  2. CTRL+I
  3. prompt: >(?si)regex input

So these are just 2 examples, but this would allow a high degree of customisation.


To it seems like this could be 2 extensions:

  1. prompt_mod action
  2. ${prompt} (in whatever form is best) variable for all actions

As this variable could be useful for other actions as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants