Created
October 19, 2016 08:08
-
-
Save kke/f9149402b89d09d0e23b7fabdbf906a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| _foo_complete() { | |
| COMPREPLY=() | |
| if [ "$ZSH_VERSION" == "" ]; then | |
| local src="${BASH_SOURCE[0]}" | |
| else | |
| local src="${(%):-%x}" | |
| fi | |
| local dir=$( cd "$( dirname "$src" )" && pwd ) | |
| local completions="$(${dir}/complete ${COMP_CWORD} ${COMP_WORDS[*]})" | |
| local word="${COMP_WORDS[COMP_CWORD]}" | |
| COMPREPLY=( $(compgen -W "$completions" -- "$word") ) | |
| } | |
| if [ "$ZSH_VERSION" != "" ]; then | |
| autoload -U +X compinit && compinit | |
| autoload -U +X bashcompinit && bashcompinit | |
| fi | |
| complete -F _foo_complete foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment