Skip to content

Latest commit

 

History

History
36 lines (19 loc) · 805 Bytes

autocomplete-ghc-flags.md

File metadata and controls

36 lines (19 loc) · 805 Bytes

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).

Bash

Add this code to your ~/.bashrc file:

# 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

Zsh

Zsh autocompletion for GHC can be also accomplished using scripts that don't use --show-options flag. See HaskellWiki for details.