Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This for-loop is broken in a number of ways:
ls
can take optionsls *
is duplicating work - we already know that the given files exist once the glob matchesprintf '%s\n' *.ko
But mostly, this is duplicating
__fish_complete_suffix .ko
. Just use that, remove the entire function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi faho, thanks for your quick reply.
IMO "/lib/modules/foo/" can be left for modprobe, insmod is more commonly used to insert a ko in the local directory. Including /lib/modules for insmod seems somewhat overhead(at least to me).
Thanks for your tip! But I encounter an issue:
complete -c insmod -a "(__fish_complete_suffix .ko)" -f
This doesn't work somehow and TAB still lists all files, could you please provide some insights? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no reason to not support directories.
__fish_complete_suffix
will complete all files, but leave matching ones at the top.This is because the suffix is not actually authoritative - you can name files whatever you want.
This is a very common problem when people try to complete e.g. ".txt" files, and then notice that they have a lot of text files with another or no suffix. For modules specifically, you may find ".ko" files, but they can also be compressed - ".ko.gz".
What you want is
where the "-k" tells "complete" to not sort the completions but keep the order they're in.