Commit 05e0dc62 authored by Lennart Kolmodin's avatar Lennart Kolmodin
Browse files

Initial attempt at command line completion

parent 5096e741
# cabal command line completion
# Copyright 2007 "Lennart Kolmodin" <kolmodin@gentoo.org>
# "Duncan Coutts" <dcoutts@gentoo.org>
#
_cabal()
{
# get the word currently being completed
local cur
cur=${COMP_WORDS[$COMP_CWORD]}
# create a command line to run
local cmd
# copy all words the user has entered
cmd=( ${COMP_WORDS[@]} )
# replace the current word with --list-options
cmd[${COMP_CWORD}]="--list-options"
# TODO: add completion of packages
# we want cabal support for this to make it fast
# $ time cabal list | cut -d' ' -f1
# real 0m2.454s
# on a Intel Core 2 Duo 1.6 GHz, too slow
# the resulting completions should be put into this array
COMPREPLY=( $( compgen -W "$( ${cmd[@]} )" -- $cur ) )
}
complete -F _cabal -o default cabal
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment