hello,
I have been trying for a couple days to figure this out to no avail. I am converting some csh code to bash. I have converted everything except the completion code.
#bashrc (I set this alias in my bashrc)
alias test='source ${PATH}/test.sh'
#${PATH}/test.sh (returns some aliases and env variables to the current shell)
ARGS="$@"
eval "`/usr/bin/python ${BPATH}/test $ARGS`"
#${PATH}/test.py (has options -h "help" -c "config" -p "packages")
#${PATH}/configurationsandpackages.py
# returns available configurations and packages
# so if I run /usr/bin/python ${PATH}/configurationsandpackages.py in a shell it returns a list of configurations and
# if I run /usr/bin/python ${PATH}/configurationsandpackages.py 1 it returns a list of packages
so my problem is that for -c and -p I want to set up completion to give me that list of configs or packages, ie:
localhost:~ medwards$ test -c<TAB>
default development etc
localhost:~ medwards$ test -c
localhost:~ medwards$ test -p<TAB>
environment defaults etc
localhost:~ medwards$ test -p
so in my bashrc after create the alias test='source ${PATH}/test.sh'
I want to create completion code to accomplish the above stated.
this works in csh.
complete test 'n@-c@`/usr/bin/python '${PATH}'/configurationsandpackages.py `@' 'n@-p@`/usr/bin/python '${PATH}'/configurationsandpackages.py 1`@'
I appreciate any insight, I have never programmed completion before and can find very little useful info from google.
regards, mark