Mercurial > bins
view bash_completion @ 11:8b62360dc2a5 default tip
Adding notes, cloning edit-gui
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Sun, 02 Nov 2008 16:29:52 +0100 |
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