Skip to content

Fix symlink for bash completions - #1889

Merged
tmccombs merged 1 commit into
sharkdp:masterfrom
skane-lukas:issue-1888-fix-symlink-bash-completion
Apr 24, 2026
Merged

tmccombs merged 1 commit into
sharkdp:masterfrom
skane-lukas:issue-1888-fix-symlink-bash-completion

Conversation

@skane-lukas

@skane-lukas skane-lukas commented Feb 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

In the deb package a broken symlink is created for bash completions to the alias command fdfind.

Solution

Create static completion files that sources fd completions for fdfind for bash, zsh and fish
Install the completions in Makefile and create-deb.sh

Changes

  • Create static completion files in contrib/completion that sources fd completions for fdfind for bash, zsh and fish
  • Changed symlink target for completion fdfind in create-deb from ./fd.bash to ./fd
  • Update Makefile and create-deb.sh to install the new static completions.
  • Updated CHANGELOG.md with the fix.

fixes #1888

@skane-lukas

skane-lukas commented Feb 20, 2026 •

Copy link
Copy Markdown
Contributor Author

The completions still dont work because they are generated for fd and not fdfind.

I can only think of changing the symlinks in create-deb.sh to something like:

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.

@tmccombs

Copy link
Copy Markdown
Collaborator

I wonder if it would be better for the fdfind completions to call the fd completions, rather than duplicating them

@skane-lukas

skane-lukas commented Feb 24, 2026 •

Copy link
Copy Markdown
Contributor Author

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
#fi

Bash completions are evaluated lazily so a side efffect would be that the completions for fd would be registered when completions for fdfind are triggered in the terminal.

similar apply to zsh

#compdef fdfind

# Source completions from fd
source /usr/share/zsh/vendor-completions/_fd

# Register completions for fdfind
compdef _fd fdfind

For fish the --wraps flag could be used and a completion file could look like:

complete -c fdfind --wraps fd

This seem to work without sourcing anything else.

I am not sure about powershell.
Is this a better approach?

Could these completion files be generated in the create-deb.sh script or should they be static files in contrib/completions?

Another direction could be to append the code snippets for registering the completions in the fd completion files and keeping the symlinks.

@tmccombs

Copy link
Copy Markdown
Collaborator

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

@villarroelgj

Copy link
Copy Markdown

The current implementation looks good directionally, but there's a build gap that needs fixing before merge.

create-deb.sh now installs from autocomplete/fdfind.bash, autocomplete/fdfind.fish, and autocomplete/_fdfind, but the Makefile was not updated to generate those files. The autocomplete/ directory is built by make it is not checked into the repo.completions

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 autocomplete/fdfind.bash autocomplete/fdfind.fish autocomplete/_fdfind as dependencies of the completions target. Without this, the deb build will fail with "no such file."

Otherwise the delegation approach (bash source + complete, zsh _fd "$@", fish --wraps) looks clean. Once this is fixed, could @tmccombs do a formal review?

@skane-lukas
skane-lukas force-pushed the issue-1888-fix-symlink-bash-completion branch from 55a63b3 to 247a517 Compare March 3, 2026 07:39
@skane-lukas

Copy link
Copy Markdown
Contributor Author

I updated the Makefile and tried to "mirror" the cicd to create and install the deb package successfully. I am not sure how to test the proper cicd.

@tmccombs
tmccombs merged commit a7a67e4 into sharkdp:master Apr 24, 2026
18 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
fd 10.5.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## Features
- Add `--ignore-parent` option to override `--no-ignore-parent`, see #1958 (@tmchow)
- Add `--exact` option to match the entire filename exactly (literal, non-substring).

## Bugfixes
- Sanitize control characters and bidirectional override characters in filenames
  when output goes to a terminal, to prevent terminal escape-sequence injection.
  Also reject a placeholder as the executable for `--exec-batch`, while still
  allowing it for `--exec`.
- Handle invalid working directories gracefully when using `--full-path`, see #1900 (@Xavrir).
- Fire the "search pattern contains a path separator" diagnostic for any pattern containing `/`, not just patterns that happen to name an existing directory. Preserves the legacy Windows behaviour that also flags native `\` separators when the pattern resolves to a real directory. See #1873.
- Also fire the "search pattern contains a path separator" diagnostic for `--and` patterns, not only the primary positional pattern. `--and` patterns are matched against the file name just like the primary pattern, so a path separator in them silently returned zero results. See #1873.
- Fix bug where passing "-" as a directory argument didn't actually search that directory, see #849 (@Sean-Kenneth-Doherty).
- Fix panic when `--changed-before`/`--changed-within` is given an out-of-range `@` Unix timestamp; the value is now rejected gracefully, see #2081 (@nikolauspschuetz).


## New Contributors
* @liruiluo made their first contribution in sharkdp/fd#1924
* @Xavrir made their first contribution in sharkdp/fd#1917
* @rexkirshner made their first contribution in sharkdp/fd#1921
* @Rohan5commit made their first contribution in sharkdp/fd#1934
* @tmchow made their first contribution in sharkdp/fd#1959
* @YoshKoz made their first contribution in sharkdp/fd#1979
* @SAY-5 made their first contribution in sharkdp/fd#1975
* @skane-lukas made their first contribution in sharkdp/fd#1889
* @Sean-Kenneth-Doherty made their first contribution in sharkdp/fd#2006
* @stevenwalton made their first contribution in sharkdp/fd#2011
* @DeflateAwning made their first contribution in sharkdp/fd#1983
* @wyf027 made their first contribution in sharkdp/fd#2001
* @bonanza127 made their first contribution in sharkdp/fd#2040
* @mahirhir made their first contribution in sharkdp/fd#2036
* @parneetsingh022 made their first contribution in sharkdp/fd#2037
* @curious-rabbit made their first contribution in sharkdp/fd#1976
* @WilliamLeony made their first contribution in sharkdp/fd#2064
* @kobihikri made their first contribution in sharkdp/fd#2063
* @cmelaro made their first contribution in sharkdp/fd#2075
* @nikolauspschuetz made their first contribution in sharkdp/fd#2082

**Full Changelog**: https://github.com/sharkdp/fd/compare/v10.4.2...v10.5.0</pre>
  <p>View the full release notes at <a href="https://github.com/sharkdp/fd/releases/tag/v10.5.0">https://github.com/sharkdp/fd/releases/tag/v10.5.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!17790
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Bash completions do not work for alias fdfind in deb release

3 participants