Skip to content

Instantly share code, notes, and snippets.

@kke
Created October 19, 2016 08:08
Show Gist options
  • Select an option

  • Save kke/f9149402b89d09d0e23b7fabdbf906a0 to your computer and use it in GitHub Desktop.

Select an option

Save kke/f9149402b89d09d0e23b7fabdbf906a0 to your computer and use it in GitHub Desktop.
#!/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