From: "Mauricio Fernández" Date: 2004-10-12T21:20:31+09:00 Subject: Re: [Ann] rpa bash programable completion --opJtzjQTFsWo+cga Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Tue, Oct 12, 2004 at 09:38:58AM +0900, Brian Schr�der wrote: > I hacked together a bash completion file for rpa, and wanted to share. Thanks a lot... I'm definitely adding it to /etc/bash_completion.d: I use rpa quite often :) BTW, would it be OK to include it in the next release of rpa-base or somewhere under http://rpa-base.rubyforge.org ? > You can find it at: > > http://ruby.brian-schroeder.de/rpa-completion/ > > What it can > ----------- > > - Completion of commands, options and ports > > > What it is missing > ------------------ > - Completion of not downloaded ports. > I didn't find a rpa switch to list the known ports. > If someone has an idea, I could add it easily. I tried it with GNU bash, version 3.00.0(1)-release (i386-pc-linux-gnu) and it didn't like the 'have' magic, so I had to comment it out. Please find attached a patch to allow completion of unknown ports and discrimination between installed and available ports. -- Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch --- rpa.orig 2004-10-12 14:10:19.000000000 +0200 +++ rpa 2004-10-12 14:12:49.000000000 +0200 @@ -4,7 +4,7 @@ # See http://ruby.brian-schroeder.de/ for the latest version. # License: GNU LGPL v2 or later -have rpa && +#have rpa && _rpa() { local cur prev conns @@ -12,7 +12,8 @@ cur=${COMP_WORDS[COMP_CWORD]} RPA_SIMPLE_COMMANDS=(dist list update rollback clean help) - RPA_PORT_COMMANDS=(install remove build source query search info check) + RPA_LOCAL_PORT_COMMANDS=(remove info check) + RPA_REMOTE_PORT_COMMANDS=(install build source query search) RPA_OPTIONS=(-h --help --no-proxy --proxy -q --quiet -x --extended --verbose --debug -v --version \ -f --force -p --parallelize --no-tests -r --requires \ -c --classification -e -eval -D --eval-display) @@ -22,21 +23,29 @@ for c in ${RPA_SIMPLE_COMMANDS[*]}; do if [ ${prev} == $c ]; then - COMPREPLY=( $(compgen -W "$(RPA_OPTIONS)" ${cur}) ); + COMPREPLY=( $(compgen -W "${RPA_OPTIONS[*]}" ${cur}) ); return 0 fi done - for c in ${RPA_PORT_COMMANDS[*]}; do + for c in ${RPA_LOCAL_PORT_COMMANDS[*]}; do if [ ${prev} == $c ]; then COMPREPLY=( $(compgen -W "$(rpa list | ruby -n -e 'puts $1 if /([-\w]+)\s+[0-9]+/')" ${cur} ) ) return 0 fi done + for c in ${RPA_REMOTE_PORT_COMMANDS[*]}; do + if [ ${prev} == $c ]; then + COMPREPLY=( $(compgen -W "$(rpa query | ruby -n -e 'puts $1 if /([-\w]+)\s+[0-9]+/')" ${cur} ) ) + return 0 + fi + done + COMPREPLY=( $(compgen -W "${RPA_SIMPLE_COMMANDS[*]} ${RPA_PORT_COMMANDS[*]} ${RPA_OPTIONS[*]}" ${cur} ) ) fi return 0 } -[ "$have" ] && complete -F _rpa rpa +#[ "$have" ] && +complete -F _rpa rpa --opJtzjQTFsWo+cga--