diff --git a/cmd/minify/README.md b/cmd/minify/README.md index d322e68f30..f042fe3e0f 100644 --- a/cmd/minify/README.md +++ b/cmd/minify/README.md @@ -13,6 +13,10 @@ Run the following command and the `minify` command will be in your `$GOPATH/bin`. +You can enable bash tab completion by using + + source minify_bash_tab_completion + ## Usage Usage: minify [options] [input] diff --git a/cmd/minify/minify-bash-completion.bash b/cmd/minify/minify-bash-completion.bash deleted file mode 100644 index 83f50c9a56..0000000000 --- a/cmd/minify/minify-bash-completion.bash +++ /dev/null @@ -1,16 +0,0 @@ -_minify_complete() -{ - local cur_work flags - - cur_word="${COMP_WORDS[COMP_CWORD]}" - flags="-a --all -l --list --match --mime -o --output -r --recursive --type --url -v --verbose --version -w --watch --css-decimals --html-keep-conditional-comments --html-keep-default-attrvals --html-keep-document-tags --html-keep-end-tags --html-keep-whitespace --svg-decimals --xml-keep-whitespace" - - if [[ ${cur_word} == -* ]] ; then - COMPREPLY=( $(compgen -W "${flags}" -- ${cur_word}) ) - else - COMPREPLY=() - fi - return 0 -} - -complete -F _minify_complete minify diff --git a/cmd/minify/minify_bash_tab_completion b/cmd/minify/minify_bash_tab_completion new file mode 100644 index 0000000000..ca6391a867 --- /dev/null +++ b/cmd/minify/minify_bash_tab_completion @@ -0,0 +1,29 @@ +#!/bin/bash + +_minify_complete() +{ + local cur_word prev_word flags mimes types + + cur_word="${COMP_WORDS[COMP_CWORD]}" + prev_word="${COMP_WORDS[COMP_CWORD-1]}" + flags="-a --all -l --list --match --mime -o --output -r --recursive --type --url -v --verbose --version -w --watch --css-decimals --html-keep-conditional-comments --html-keep-default-attrvals --html-keep-document-tags --html-keep-end-tags --html-keep-whitespace --svg-decimals --xml-keep-whitespace" + mimes="text/css text/html text/javascript application/json image/svg+xml text/xml" + types="css html js json svg xml" + + if [[ ${cur_word} == -* ]] ; then + COMPREPLY=( $(compgen -W "${flags}" -- ${cur_word}) ) + elif [[ ${prev_word} =~ ^--mime$ ]] ; then + COMPREPLY=( $(compgen -W "${mimes}" -- ${cur_word}) ) + elif [[ ${prev_word} =~ ^--type$ ]] ; then + COMPREPLY=( $(compgen -W "${types}" -- ${cur_word}) ) + elif [[ ${prev_word} =~ ^--(match|url|css-decimals|svg-decimals)$ ]] ; then + compopt +o default + COMPREPLY=() + else + compopt -o default + COMPREPLY=() + fi + return 0 +} + +complete -F _minify_complete minify