Fix symlink for bash completions#1889
Conversation
Fix bash completion generation for alias `fdfind` in deb release, see sharkdp#1888.
|
The completions still dont work because they are generated for I can only think of changing the symlinks in ln -sf "/usr/bin/fd" "${DPKG_DIR}/usr/bin/fdfind"
"${DPKG_DIR}/usr/bin/fdfind" --gen-completions bash > autocomplete/fdfind.bash
"${DPKG_DIR}/usr/bin/fdfind" --gen-completions fish > autocomplete/fdfind.fish
"${DPKG_DIR}/usr/bin/fdfind" --gen-completions powershell > autocomplete/_fdfind.ps1
# Generate Zsh completion by substituting top row of static completion file
sed '1s/^#compdef fd/#compdef fdfind/' autocomplete/_fd > autocomplete/_fdfind
install -Dm644 autocomplete/fdfind.bash "${DPKG_DIR}/usr/share/bash-completion/completions/fdfind"
install -Dm644 autocomplete/fdfind.fish "${DPKG_DIR}/usr/share/fish/vendor_completions.d/fdfind.fish"
install -Dm644 autocomplete/_fdfind.ps1 "${DPKG_DIR}/usr/share/powershell/Modules/fdfind/_fdfind.ps1"
install -Dm644 autocomplete/_fdfind "${DPKG_DIR}/usr/share/zsh/vendor-completions/_fdfind"I am not sure if there is a better way to do this. |
|
I wonder if it would be better for the fdfind completions to call the fd completions, rather than duplicating them |
|
I agree that would be ideal. For bash the fdfind could look like: # Source fd completions
source /usr/share/bash-completion/completions/fd
# Complete with same options as fd
eval "$(complete -p fd | sed 's/ fd$/ fdfind/')"
# Or
#if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
# complete -F _fd -o nosort -o bashdefault -o default fdfind
#else
# complete -F _fd -o bashdefault -o default fdfind
#fiBash completions are evaluated lazily so a side efffect would be that the completions for similar apply to zsh #compdef fdfind
# Source completions from fd
source /usr/share/zsh/vendor-completions/_fd
# Register completions for fdfind
compdef _fd fdfindFor fish the complete -c fdfind --wraps fdThis seem to work without sourcing anything else. I am not sure about powershell. Could these completion files be generated in the Another direction could be to append the code snippets for registering the completions in the fd completion files and keeping the symlinks. |
|
That seems like a better approach to me, although I don't know how to do it for Powershell either. I think putting those in contrib/completions would be fine |
Use autoload instead of source for zsh Dont use complete command to catch options for compdef in bash
|
The current implementation looks good directionally, but there's a build gap that needs fixing before merge.
You'll need to add Makefile targets similar to: autocomplete/fdfind.bash: contrib/completion/fdfind.bash
knowledge.md $(comp_dir)
knowledge.md cp $< $@
autocomplete/fdfind.fish: contrib/completion/fdfind.fish
knowledge.md $(comp_dir)
knowledge.md cp $< $@
autocomplete/_fdfind: contrib/completion/_fdfind
knowledge.md $(comp_dir)
knowledge.md cp $< $@And add Otherwise the delegation approach (bash source + complete, zsh |
Problem
In the deb package a broken symlink is created for bash completions to the alias command
fdfind.Solution
Change the symlink target for the
fdfindbash completionChanges
fdfindincreate-debfrom./fd.bashto./fdCHANGELOG.mdwith the fix.fixes #1888