Version 1 (modified by jstolarek, 3 years ago) (diff)


Autocomplete GHC's command line options

GHC 7.8 adds --show-options flag that prints on standard output all supported flags. This can be used to enable autocompletion of options on the command line (in shells that support such feature).


Add this code to your ~/.bashrc file:

# Autocomplete GHC commands
    local envs=`ghc --show-options`
    # get the word currently being completed
    local cur=${COMP_WORDS[$COMP_CWORD]}
    # the resulting completions should be put into this array
    COMPREPLY=( $( compgen -W "$envs" -- $cur ) )
complete -F _ghc -o default ghc