Written by m4r3k and tagged by linux, openSUSE.
In my previous blogpost, I was talking about scpm. I really like this tool, but I miss bash completion script for this. I miss bash completion script for a lot of command line programs, so I create one. This is not really smart piece of software, but it is able to suggest some basic parameters, it is mainly for my use only, but maybe someone else will appreciate it as well.
I have a plan for future development, but I am not really sure about function of all parameters (Did you ever look to scpm man page? It is example, how man page should not look. :-)) My script is attached, and installation is really simple. Just copy content into file /etc/bash_completion.d/scpm.sh.
# scpm completion v0.1 aplha 1 :-) # A gift from Marek Stopka_scpm() { SCPM_CMDLIST=() SCPM=`which scpm` local opts cur prev prevprev if test ${#SCPM_CMDLIST[*]} = 0; then for foo in $(LC_ALL=C $SCPM 2>&1 | sed -e "1,/command may be:/d" | egrep ^[a-z] | awk -F ' ' '{print $1}'); do SCPM_CMDLIST="$SCPM_CMDLIST $foo" done SCPM_CMDLIST="$SCPM_CMDLIST" fi cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if [[ ${#COMP_WORDS[@]} -ge 3 ]]; then prevprev=${COMP_WORDS[COMP_CWORD-2]} fi case "$prev" in scpm) opts=$SCPM_CMDLIST COMPREPLY=($(compgen -W "${opts}" -- ${cur})) ;; switch) opts=`$SCPM list` COMPREPLY=($(compgen -W "${opts}" -- ${cur})) ;; rename) opts=`$SCPM list` COMPREPLY=($(compgen -W "${opts}" -- ${cur})) ;; delete) opts=`$SCPM list` COMPREPLY=($(compgen -W "${opts}" -- ${cur})) ;; esac } complete -F _scpm -X -o default scpm