/bash_completion_lib/include/_longopt
http://github.com/brinkman83/bashrc · #! · 29 lines · 24 code · 5 blank · 0 comment · 0 complexity · 03becb8469cfbf19f57a3c4a99eee3b6 MD5 · raw file
- comp_include _filedir _get_cword
- _longopt()
- {
- local cur opt
- cur=`_get_cword`
- if [[ "$cur" == --*=* ]]; then
- opt=${cur%%=*}
- # cut backslash that gets inserted before '=' sign
- opt=${opt%\\*}
- cur=${cur#*=}
- _filedir
- COMPREPLY=( $( compgen -P "$opt=" -W '${COMPREPLY[@]}' -- $cur))
- return 0
- fi
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( $1 --help 2>&1 | sed -e '/--/!d' \
- -e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
- command grep "^$cur" | sort -u ) )
- elif [[ "$1" == @(mk|rm)dir ]]; then
- _filedir -d
- else
- _filedir
- fi
- }