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

[fish] Unescape query from commandline #4236

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

bitraid
Copy link
Contributor

@bitraid bitraid commented Feb 11, 2025

This tackles the issue discussed in #4230 (comment). It makes the query taken from command line, be similar to that of bash and zsh, without sacrificing compatibility with old fish versions. Outer open quotes are removed - more details and examples in commit message.

Now, pressing <CTRL-T>/<ALT-C> after the shell has auto-completed part of a file/dir name with special characters, works as expected:

touch /tmp/fzf-test\ \"{a,b}\"
ls /tmp/fzf-test<TAB>
ls /tmp/fzf-test\ \"<CTRL-T>

The query becomes: fzf-test "

More natural processing of the query taken from command line, by
unquoting/unescaping the token. Unescaped open quotes are removed.
Because of how `string unescape` works, if both single and double quotes
are present, with the outer quotes open, only the outer quotes are
removed.

Examples:
`'foo bar'`, `"foo bar"`, `foo\ bar` becomes `foo bar`
`"foobar`, `'foobar`, `foo"bar`, `foo'bar` becomes `foobar`
`'"foo"'`, `'"foo"` becomes `"foo"`
`"'foo'"`, `"'foo'` becomes `'foo'`
`"'foo` becomes `'foo`
`'"foo` becomes `"foo`
@junegunn junegunn merged commit 282884a into junegunn:master Feb 11, 2025
5 checks passed
@junegunn
Copy link
Owner

Works like a charm, thanks!

@bitraid bitraid deleted the fish-query-unescape branch February 11, 2025 14:35
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

Successfully merging this pull request may close these issues.

2 participants