Skip to content

Conversation

@WardBrian
Copy link

@WardBrian WardBrian commented Nov 24, 2025

Would close #6427

This updates opam env to set XDG_DATA_DIRS (from the XDG base directory specification) to include the current switch's share root, and FPATH to include %{share}%/zsh/site-functions when the shell is zsh

The former works with bash-completion, which looks in the XDG_DATA_DIRS entries for bash-completion/completions sub-directories, while the later sets up zsh's built-in completion mechanisms to look in this location.

Questions for reviewers --

  1. I currently only modify FPATH on zsh, but I think it would be safe to do it generically (the only other shell that seems to assign meaning to the FPATH variable is ksh, which opam doesn't support)
  2. Assuming we want to keep FPATH zsh-specific, is it worth threading through a shell variable all the way from the CLI to where we compute these updates, or is it fine to keep the guess_shell_compat call?

@WardBrian WardBrian changed the title Feat/6427 completion environment variables Set environment variables needed for bash, zsh completion in opam env Nov 24, 2025
@WardBrian WardBrian force-pushed the feat/6427-completion-environment-variables branch from da44a84 to 4773962 Compare November 24, 2025 17:56
@kit-ty-kate kit-ty-kate added this to the 2.6.0~alpha1 milestone Nov 24, 2025
@WardBrian WardBrian force-pushed the feat/6427-completion-environment-variables branch from 4773962 to 18a99a3 Compare November 24, 2025 18:22
@WardBrian WardBrian force-pushed the feat/6427-completion-environment-variables branch from 18a99a3 to 95d0887 Compare November 24, 2025 22:27
@WardBrian WardBrian marked this pull request as ready for review November 30, 2025 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should $(opam env) or .opam/opam-init/* setup paths for shell completion scripts ?

2 participants