Mercurial > bins
view bash_completion @ 2:c44d020e5f8a 1.1.29-extended
Importing extended patched version from http://www.uli-eckhardt.de/bins/index.en.html
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Wed, 15 Oct 2008 23:31:54 +0200 |
parents | a84c32f131df |
children |
line wrap: on
line source
# bins completion for bash #-*- mode: shell-script;-*- _bins() { local cur prev tempdir COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} case "$prev" in -f) _filedir return 0 ;; -o) COMPREPLY=( $( compgen -W 'scaled copied custom' -- $cur ) ) return 0 ;; -c) conffile=$HOME/.bins/binsrc for (( i=1; i < COMP_CWORD; i++ )); do if [[ "${COMP_WORDS[i]}" == -f ]]; then conffile=${COMP_WORDS[i+1]} break fi done COMPREPLY=( \ $( awk -F'"' '/<colors style="/ {print $2}' $conffile | grep "^$cur" ) \ $( awk -F"'" "/<colors style='/ {print $2}" $conffile | grep "^$cur" ) \ ) return 0 ;; -t) _filedir -d return 0 ;; -r) COMPREPLY=( $( compgen -W 'dirs pictures dirs,pictures' -- $cur ) ) return 0 ;; -s) tempdir=/usr/share/bins for (( i=1; i < COMP_CWORD; i++ )); do if [[ "${COMP_WORDS[i]}" == -t ]]; then tempdir=${COMP_WORDS[i+1]} break fi done COMPREPLY=( $( find $tempdir -type d -maxdepth 1 -name templates.* | \ sed -e "s|$tempdir/templates.||" | grep "^$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-f -o -d -c -s -t -p -r -e -i -n -v -h' -- $cur ) ) else _filedir -d fi } complete -F _bins bins