Autocomplete command line options with GHC 7.8
Jan Stolarek
jan.stolarek at p.lodz.pl
Wed Apr 16 15:19:30 UTC 2014
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.
More information about the Glasgow-haskell-users
mailing list