[commit: Cabal] master: Initial attempt at command line completion (05e0dc6)
Ian Lynagh
igloo at earth.li
Fri Jun 24 01:48:59 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/05e0dc6260b79d13f00a8db63d3b2edcc21cbbdd
>---------------------------------------------------------------
commit 05e0dc6260b79d13f00a8db63d3b2edcc21cbbdd
Author: Lennart Kolmodin <kolmodin at gentoo.org>
Date: Wed Dec 19 21:57:47 2007 +0000
Initial attempt at command line completion
>---------------------------------------------------------------
cabal-install/bash-completion/cabal | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/cabal-install/bash-completion/cabal b/cabal-install/bash-completion/cabal
new file mode 100644
index 0000000..0beccee
--- /dev/null
+++ b/cabal-install/bash-completion/cabal
@@ -0,0 +1,30 @@
+# cabal command line completion
+# Copyright 2007 "Lennart Kolmodin" <kolmodin at gentoo.org>
+# "Duncan Coutts" <dcoutts at 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
More information about the Cvs-libraries
mailing list