fish-shell / fish-shell

The user-friendly command line shell.

Home Page:https://fishshell.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

curl file completion doesn't work for @

tyilo opened this issue · comments

Given the following prompt

$ ls
foo.txt
$ curl https://example.org/ -d@f<TAB>

I would expect fish to autocomplete the prompt to curl https://example.org/ -d@foo.txt.

Same thing for curl https://example.org/ --data-binary @f<TAB>, etc.

$ fish --version
fish, version 3.7.1
$ echo $version
3.7.1

Can you change the first line of /usr/share/fish/completions/curl.fish as follows and see if it works?

diff --git a/share/completions/curl.fish b/share/completions/curl.fish
index 13dc10e1f..7352cfc94 100644
--- a/share/completions/curl.fish
+++ b/share/completions/curl.fish
@@ -1,4 +1,4 @@
-complete -c curl -n 'string match -qr "^@" -- (commandline -ct)' -k -xa "(printf '%s\n' -- @(__fish_complete_suffix --complete=(commandline -ct | string replace -r '^@' '') ''))"
+complete -c curl -n 'string match -qr "@" -- (commandline -ct)' -kxa "(printf '%s\n' -- (string match -r '^.*@' -- (commandline -ct))(__fish_complete_suffix --complete=(commandline -ct | string replace -r '.*@' '') ''))"
 
 # These based on the autogenerated completions.
 complete -c curl -l abstract-unix-socket -d '(HTTP) Connect through an abstract Unix domain socket'

It works, however I had to add it to /usr/share/fish/vendor_completions.d/curl.fish instead.

Thus the commit will not really fix this (at least for Arch users) :/

But thanks for the fix ❤️