#!/bin/bash
# gwm bash completion script
# Generated by gwm completion
#
# Installation:
#   gwm completion install --shell bash
#
# Manual installation:
#   Copy this file to ~/.local/share/bash-completion/completions/gwm
#   Or add the following to your ~/.bashrc:
#   eval "$(gwm completion script --shell bash)"

_gwm_complete() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local words=("${COMP_WORDS[@]:1}")
  local cword=$((COMP_CWORD - 1))

  # gwm completion __complete を呼び出し
  local candidates
  candidates=$(gwm completion __complete --shell bash --cword "$cword" -- "${words[@]}" 2>/dev/null)

  if [[ -n "$candidates" ]]; then
    # タブ区切りの説明を除去してcompgenに渡す
    local values
    values=$(echo "$candidates" | cut -f1)
    COMPREPLY=($(compgen -W "$values" -- "$cur"))
  fi
}

complete -F _gwm_complete gwm
