I’ve been working on a simple library to automatically generate shell completion files from spec for the Arg
module.
I’ve been having trouble figuring out how to properly install these completions script in an opam package once they are built.
I can have install completion script somewhere in $OPAM_SWITCH_PREFIX/share/<pkg_name>/...
but they wouldn’t be sourced by the user’s shell.
The only package I could find implementing any kind of shell completion is opam itself, and they are doing it by directly sourcing the completion file from opam-init/init.sh
. I don’t think I should be modifying any opam file as my package is installed.
The only way I thought that could resolve this problem is by doing an executable similar to opam-user-setup
that would modify the user .bashrc
or .zshrc
and add a line to source a custom script that would in turn source all completion script for the current opam switch. It seems like a complicated way of solving an issue like this, but relying on the user to manually source every single completion file also doesn’t feel quite right.
Would there be any cleaner way to implement this? Does any opam package implement shell completion in a clean way?
8 posts - 4 participants