tmuxinator.bash 668 B

12345678910111213141516171819202122
  1. _tmuxinator() {
  2. COMPREPLY=()
  3. local word
  4. word="${COMP_WORDS[COMP_CWORD]}"
  5. if [ "$COMP_CWORD" -eq 1 ]; then
  6. local commands="$(compgen -W "$(tmuxinator commands)" -- "$word")"
  7. local projects="$(compgen -W "$(tmuxinator completions start)" -- "$word")"
  8. COMPREPLY=( $commands $projects )
  9. elif [ "$COMP_CWORD" -eq 2 ]; then
  10. local words
  11. words=("${COMP_WORDS[@]}")
  12. unset words[0]
  13. unset words[$COMP_CWORD]
  14. local completions
  15. completions=$(tmuxinator completions "${words[@]}")
  16. COMPREPLY=( $(compgen -W "$completions" -- "$word") )
  17. fi
  18. }
  19. complete -F _tmuxinator tmuxinator