argcomplete
argcomplete copied to clipboard
fish-shell: function name is broken for local files (./script.py)
When Using argcomplete under Fish-Shell, the generated Code contains the literal Path to the Script as part of a function-name:
~/C/makefile-style-python register-python-argcomplete --shell fish ./foo/bar/baz
function __fish_./foo/bar/baz_complete
set -x _ARGCOMPLETE 1
set -x _ARGCOMPLETE_DFS \t
set -x _ARGCOMPLETE_IFS \n
set -x _ARGCOMPLETE_SUPPRESS_SPACE 1
set -x _ARGCOMPLETE_SHELL fish
set -x COMP_LINE (commandline -p)
set -x COMP_POINT (string length (commandline -cp))
set -x COMP_TYPE
if set -q _ARC_DEBUG
./foo/bar/baz 8>&1 9>&2 1>/dev/null 2>&1
else
./foo/bar/baz 8>&1 9>&2 1>&9 2>&1
end
end
complete -c ./foo/bar/baz -f -a '(__fish_./foo/bar/baz_complete)'
__fish_./foo/bar/baz_complete
is not a valid function name in Fish and thus | source
ing the generated Snippet results in an Error:
~/C/makefile-style-python register-python-argcomplete --shell fish ./foo/bar/baz | source
- (line 2): function: Illegal function name '__fish_./foo/bar/baz_complete'
function __fish_./foo/bar/baz_complete
^
from sourcing file -
Removing the offending Characters only leaving [a-zA-Z0-9]
or a similar restrictive character-set would result in a workable Fish script.
Does completion works after function name fix?
For me (fish 3.1.2) it doesn't.
After changing complete -c ./foo/bar/baz -f -a '(__fish_foo_bar_baz_complete)'
to complete -c baz -f -a '(__fish_foo_bar_baz_complete)'
completion starts working as expected.
Can't find examples of fish complete with local files.
After changing complete -c ./foo/bar/baz -f -a '(__fish_foo_bar_baz_complete)' to complete -c baz -f -a '(__fish_foo_bar_baz_complete)' completion starts working as expected.
https://github.com/fish-shell/fish-shell/issues/6001, fixed in fish 3.3.0.
fixed in fish 3.3.0.
Nice!
Relative paths should be also supported in generated script body - running completion from different directory would fail now.
Probably it's better to use single completion function for fish, like for bash. Disabling completions descriptions should be also changed with this approach because it's done by modifying script.
After fish-shell/fish-shell#6001 completion registered via complete -p /home/auser/myscript ...
work for /home/user/myscript
and ./myscript
but not for ~/myscript
.
@faho is this expected or it should be reported?
There is workaround: if I register command via complete -c myscript ...
all three cases works, but also completion is invoked for any other script with same name.
UPD: reported as fish-shell/fish-shell#8442