Hi all,

GHC 7.8 adds --show-options flag that prints all supported command line flags 
on standard output. 
This can be used to enable autocompletion of command line options for ghc in 
shells that support 
autocompletion. If you're using bash add this snippet to your ~/.bashrc file:

<<<<<<<<<<<<< START

# Autocomplete GHC commands
_ghc()
{
    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

<<<<<<<<<<<< END

Enjoy.

Janek

PS. I also added a wiki page: 
https://ghc.haskell.org/trac/ghc/wiki/AutocompleteGHCFlags
Feel free to add instructions for other shells.
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to