mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-02 15:11:03 +01:00
fish: avoid shadowing builtin completions
The fish shell comes with builtin completions. For example, git completion supports context-aware completion of things like commit hashes, branch names, sub-commands, etc. Until fish 4.2, builtin completions were explicitly loaded from `share/fish/completions`, however that is now deprecated and disabled. In effect, this means generating manpage-based completion will shadow and disable builtin completion. Avoid that, by only generating completion when fish does not have builtin support for the command.
This commit is contained in:
parent
470d24d809
commit
23f2ba7ae0
1 changed files with 24 additions and 3 deletions
|
|
@ -628,9 +628,30 @@ in
|
|||
mkdir -p $out
|
||||
for src in $srcs; do
|
||||
if [ -d $src/share/man ]; then
|
||||
find -L $src/share/man -type f \
|
||||
-exec python ${cfg.package}/share/fish/tools/create_manpage_completions.py --directory $out {} + \
|
||||
> /dev/null
|
||||
while IFS= read -r manpage; do
|
||||
# Approximate the corresponding command for this manpage
|
||||
bin="$(basename "$manpage")"
|
||||
bin="''${bin%%.*}"
|
||||
bin="$src/bin/$bin"
|
||||
|
||||
# Check for builtin completion
|
||||
if
|
||||
[ -e "$bin" ] &&
|
||||
fish \
|
||||
--no-config \
|
||||
--command 'complete --do-complete $argv[1]' \
|
||||
-- "$bin" \
|
||||
>/dev/null 2>&1
|
||||
then
|
||||
echo "Found builtin completion for $bin (skipping)"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Generate completion based on the manpage
|
||||
python ${cfg.package}/share/fish/tools/create_manpage_completions.py \
|
||||
--directory "$out" "$manpage" > /dev/null
|
||||
|
||||
done < <(find -L "$src/share/man" -type f)
|
||||
fi
|
||||
done
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue