| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
if [ -n "$ZSH_NAME" ]; then |
| 4 |
# zsh sets $ZSH_NAME variable so it can be used to detect zsh |
| 5 |
# following enables using bash-completion under zsh |
| 6 |
autoload bashcompinit |
| 7 |
bashcompinit |
| 8 |
fi |
| 9 |
|
| 10 |
_minify_complete() { |
| 11 |
local cur prev flags types |
| 12 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 13 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 14 |
flags="-a --all --bundle --exclude --ext -i --include --inplace -l --list --match -o --output -p --preserve -q --quiet -r --recursive --type --url -v --verbose --version -w --watch --css-precision --css-version --html-keep-comments --html-keep-special-comments --html-keep-default-attrvals --html-keep-document-tags --html-keep-end-tags --html-keep-quotes --html-keep-whitespace --js-precision --js-keep-var-names --js-version --json-precision --json-keep-numbers --svg-keep-comments --svg-keep-namespaces --svg-precision -s --sync --xml-keep-whitespace" |
| 15 |
types="asp css ejs gohtml handlebars html js json mustache php rss svg tmpl webmanifest xhtml xml text/asp text/css text/x-ejs-template text/x-go-template text/x-handlebars-template text/html text/javascript application/javascript application/json text/x-mustache-template application/x-httpd-php application/rss+xml image/svg+xml text/x-template application/manifest+json application/xhtml+xml text/xml application/xml" |
| 16 |
if echo "${cur}" | grep -Eq '^-'; then |
| 17 |
COMPREPLY=($(compgen -W "${flags}" -- "${cur}")) |
| 18 |
elif echo "${prev}" | grep -Eq '^--type$'; then |
| 19 |
COMPREPLY=($(compgen -W "${types}" -- "${cur}")) |
| 20 |
elif echo "${prev}" | grep -Eq '^--(css-precision|css-version|ext|js-precision|js-version|json-precision|preserve|svg-keep-namespaces|svg-precision|url)$'; then |
| 21 |
compopt +o default |
| 22 |
COMPREPLY=() |
| 23 |
else |
| 24 |
compopt -o default |
| 25 |
COMPREPLY=() |
| 26 |
fi |
| 27 |
return 0 |
| 28 |
} |
| 29 |
|
| 30 |
complete -F _minify_complete minify |