HTTPie accepts paths as arguments with options that include the @
sign. Unfortunately, they don't seem to work with shell completions in fish
. Instead, the option is treated as an opaque string.
To stick with the file upload example from the HTTPie documentation with a file at ~/files/data.xml
, I would expect to be able to tab complete the file name when typing:
http -f POST pie.dev/post name='John Smith' cv@~/files/da<TAB>
However, no completion is offered.
I have installed the completions for fish
from the HTTPie project and they work for short and long arguments. This file does not specify how to complete the @
arguments though.
In addition, I looked into specifying my own completions but I am not able to find a way of getting to work file completions with the arbitrary prefix.
How could I implement a completion for these path arguments for HTTPie?
I managed to get the tab completion of the path arguments working with some caveats.
This adds the completion:
With the following functions:
The caveat is that this does not expand any variables nor the tilde
~
. It essentially only works for plain paths — relative or absolute.