/dune-completion-scripts

Shell completion scripts for Dune

Primary LanguageShell

Dune Completion Scripts

Shell completion scripts for Dune.

Installation

The file bash.sh contains the bash completion script. Source it in your shell to add completion suggestions for Dune to your current session. The easiest way to enable this all the time is to source the file from your shell rc file.

If sourcing a large, minified bash script you found on the internet makes you nervous, there's an unminified version of the script that's more auditable.

Bash

Add the following to your ~/.bashrc:

source /path/to/dune-completion-scripts/bash.sh

Zsh

Zsh understands bash completion scripts but support must be explicitly enabled. Add the following to your ~/.zshrc:

autoload -Uz compinit bashcompinit
compinit
bashcompinit

source /path/to/dune-completion-scripts/bash.sh

How to generate

These scripts were generated by modifying Dune to parse command line arguments using the library climate - a library with similar semantics to cmdliner but with the ability to generate completion scripts. This modified version of dune lives on this branch.

Build dune from that branch and then run the following to print the bash completion script to stdout:

dune.exe internal print-completion-script-bash \
  --program-name=dune \
  --program-exe-for-reentrant-query=dune \
  --global-symbol-prefix=_dune_ \
  --no-command-hash-in-function-names \
  --minify-global-names \
  --minify-local-variables \
  --no-comments \
  --no-whitespace \
  --optimize-case-statements