This file is indexed.

/etc/bash_completion.d/vim-addon-manager is in vim-addon-manager 0.5.3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
# vim-addon-manager: completion script for vim-addons
# 
# Copyright (c) 2007, Antonio Terceiro <terceiro@softwarelivre.org>
# 
# This program is free software, you can redistribute it and/or modify it under
# the terms of the GNU General Public License version 3, or (at your option)
# any later version published by the Free Software Foundation.

_complete_vim_addons() {

  COMPREPLY=()
  cur=${COMP_WORDS[COMP_CWORD]}
  prev=${COMP_WORDS[COMP_CWORD-1]}

  commands="list status install remove disable amend files show"
  any_command=$(echo $commands | sed -e 's/\s\+/|/g')

  options="-h --help -r --registry-dir -s --source-dir -t --target-dir -v --verbose -y --system-dir -w --system-wide -q --query"
  any_option=$(echo $options | sed -e 's/\s\+/|/g')

  # complete commands
  if [[ "$prev" == 'vim-addons' ]] || [[ "$prev" == 'vim-addon-manager' ]] || [[ "$prev" == 'vam' ]]; then
    COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
    return 0
  fi

  # complete option names
  if [[ "$cur" == -* ]]; then
    COMPREPLY=( $( compgen -W "$options" -- $cur) )
    return 0
  fi

  # complete directory name for some options
  if [[ "$prev" == @(-r|--registry-dir|-s|--source-dir|-t|--target-dir|-y|--system-dir) ]]; then
    COMPREPLY=( $( compgen -o dirnames -- $cur ) )
    return 0
  fi

  command=''
  target_dir=''
  system_wide=''
  system_dir=''
  for (( i=0; i < ${#COMP_WORDS[@]}-1; i++)); do

    # check for command
    if [[ ${COMP_WORDS[i]} == @($any_command) ]]; then
      command=${COMP_WORDS[i]}
    fi

    # check for -w or --system-wide
    if [[ ${COMP_WORDS[i]} == @(-w|--system-wide) ]]; then
      system_wide="--system-wide"
    fi

    if [[ $i -gt 0 ]]; then
      # check for -t or --target-dir
      if [[ ${COMP_WORDS[i-1]} == @(-t|--target-dir) ]]; then
        target_dir="--target-dir ${COMP_WORDS[i]}"
      fi

      # check for -y or --system-dir
      if [[ ${COMP_WORDS[i-1]} == @(-y|--system-dir) ]]; then
        system_dir="--system-dir ${COMP_WORDS[i]}"
      fi
    fi

  done

  # build the query command
  query="vim-addons status --query $system_wide $system_dir $target_dir"

  # no command, cannot know how to complete
  if [[ -z "$command" ]]; then
    COMPREPLY=()
    return 0;
  fi

  case "$command" in
    # no addon names if command is 'list'
    list)
      COMPREPLY=()
      ;;

    # list only non-installed addons
    install)
      COMPREPLY=( $(  $query | grep -e "^$cur" | grep -v -e "installed$" | sed -e 's/^\(\S\+\).*/\1/' )  )
      ;;

    # list only installed addons
    remove|disable|amend)
      COMPREPLY=( $(  $query | grep -e "^$cur" | grep -e "installed$" | sed -e 's/^\(\S\+\).*/\1/' )  )
      ;;

    # complete addon names
    *)
      COMPREPLY=($(grep -h "^addon: $cur" /usr/share/vim/registry/*.yaml | sed -e 's/^addon:\s*//'))
      ;;
  esac

}
complete -F _complete_vim_addons -o default vim-addons
complete -F _complete_vim_addons -o default vim-addon-manager
complete -F _complete_vim_addons -o default vam

# vim: sw=2 expandtab ft=sh