.bash_completion.d/pip
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 29 Mar 2023 23:42:06 +0300
changeset 1018 831e2c1bf980
parent 729 3808bb55f8bb
permissions -rw-r--r--
Completed migration from ~/devel to ~/work.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
728
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
# -*- mode: sh; sh-shell-file: bash -*-
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
_pip()
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
{
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
  local _cmds='install uninstall freeze list show search wheel help'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     6
  local _acts='switch ignore wipe backup'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     7
  local _opts='-h --help -v --verbose -V --version -q --quiet --proxy --timeout'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
  local _index_opts='-i --index-url --extra-index-url --no-index -f --find-links --allow-external --allow-all-external --allow-unverified --process-dependency-links'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
  local _install_opts='-e --editable -U --upgrade --force-reinstall -I --ignore-installed --no-deps --no-install --no-download \
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    10
--install-option --user --egg --compile --no-compile --no-use-wheel --pre --no-clean \
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
-e --editable -b --build -t --target -d --download --download-cache \
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
-r --requirement'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    13
  local _uninstall_opts='-y --yes -r --requirement'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
  local _list_opts='-o --outdated -u --uptodate -e --editable -l --local --pre'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
  local _freeze_opts='-f --find-links -l --local'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
  local _search_opts='--index'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
  local _show_opts='--index'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    18
  local _wheel_opts='--no-use-wheel --build-option --no-deps --global-option --pre --no-clean \
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    19
-w --wheel-dir --download-cache -b --build
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    20
-r, --requirement'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    21
  local cur
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
  cur=${COMP_WORDS[COMP_CWORD]}
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
  if [[ $COMP_CWORD = 1 ]]; then
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
    COMPREPLY=( $(compgen -W '$_cmds'  -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    25
    return 0
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    26
  fi
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
  local first prev
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    28
  first=${COMP_WORDS[1]}
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    29
  prev=${COMP_WORDS[COMP_CWORD-1]}
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    30
  case "$prev" in
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    31
    --cert|--log|--log-file)
729
3808bb55f8bb Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 728
diff changeset
    32
      compopt -o default; COMPREPLY=()
728
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    33
      return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    34
    --exists-action)
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    35
      COMPREPLY=( $(compgen -W  '$_acts' -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    36
      return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    37
  esac
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    38
  case $first in
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    39
    install)
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    40
      case $prev in
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    41
        -e|--editable|-b|--build|-t|--target|-d|--download|--download-cache)
729
3808bb55f8bb Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 728
diff changeset
    42
          compopt -o dirnames; COMPREPLY=()
728
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    43
          return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    44
        -r|--requirement)
729
3808bb55f8bb Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 728
diff changeset
    45
          compopt -o default; COMPREPLY=()
728
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    46
          return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    47
      esac
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    48
      COMPREPLY=( $(compgen -W '$_install_opts $_opts $_index_opts'  -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    49
      return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    50
    uninstall)
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    51
      case $prev in
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    52
        -r|--requirement)
729
3808bb55f8bb Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 728
diff changeset
    53
          compopt -o default; COMPREPLY=()
728
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    54
          return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    55
      esac
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    56
      COMPREPLY=( $(compgen -W '$_uninstall_opts $_opts'  -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    57
      return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    58
    list)
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    59
      COMPREPLY=( $(compgen -W '$_list_opts $_opts $_index_opts'  -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    60
      return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    61
    freeze)
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    62
      case $prev in
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    63
        -r|--requirement)
729
3808bb55f8bb Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 728
diff changeset
    64
          compopt -o default; COMPREPLY=()
728
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    65
          return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    66
      esac
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    67
      COMPREPLY=( $(compgen -W '$_freeze_opts $_opts'  -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    68
      return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    69
    search)
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    70
      COMPREPLY=( $(compgen -W '$_search_opts $_opts'  -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    71
      return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    72
    show)
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    73
      COMPREPLY=( $(compgen -W '$_show_opts $_opts'  -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    74
      return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    75
    wheel)
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    76
      case $prev in
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    77
        -w|--wheel-dir|--download-cache|-b|--build)
729
3808bb55f8bb Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 728
diff changeset
    78
          compopt -o dirnames; COMPREPLY=()
728
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    79
          return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    80
        -r|--requirement)
729
3808bb55f8bb Switch to built-in Readline file/directory completion capability as
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 728
diff changeset
    81
          compopt -o default; COMPREPLY=()
728
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    82
          return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    83
      esac
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    84
      COMPREPLY=( $(compgen -W '$_wheel_opts $_opts $_index_opts'  -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    85
      return 0 ;;
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    86
  esac
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    87
  COMPREPLY=( $(compgen -W '$_opts'  -- "$cur") )
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    88
  return 0
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    89
} &&
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    90
    complete -F _pip pip pip2 pip2.5 pip2.6 pip2.7 pip2.8
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    91