├── zsh-pip-completion.plugin.zsh ├── README.md ├── LICENSE └── _pip /zsh-pip-completion.plugin.zsh: -------------------------------------------------------------------------------- 1 | # Empty file 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Advanced pip completion for zsh 2 | =============================== 3 | 4 | Simple completion function that can complete PyPI package names. 5 | 6 | Installation 7 | ============ 8 | 9 | ### Manual Installation 10 | 1. Copy `_pip` file into `~/.zshfuncs` folder. 11 | 2. Add this folder to your functions path before loading completion in your `~/.zshrc`. 12 | 13 | Example: 14 | 15 | # completion 16 | fpath=(~/.zshfuncs $fpath) 17 | autoload -U compinit 18 | compinit 19 | 20 | ### Antigen 21 | 1. Just run the following command 22 | 23 | ```shell 24 | antigen bundle srijanshetty/zsh-pip-completion 25 | ``` 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Srijan R Shetty 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | * this software and associated documentation files (the "Software"), to deal in 6 | * the Software without restriction, including without limitation the rights to 7 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | * the Software, and to permit persons to whom the Software is furnished to do so, 9 | * subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in all 12 | * copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | 23 | -------------------------------------------------------------------------------- /_pip: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014 Srijan R Shetty 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | # this software and associated documentation files (the "Software"), to deal in 5 | # the Software without restriction, including without limitation the rights to 6 | # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | # the Software, and to permit persons to whom the Software is furnished to do so, 8 | # subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | #compdef pip 21 | 22 | local subcmds 23 | 24 | _arguments -C '*::command:->command' && return 0 25 | 26 | case $state in 27 | command) 28 | if [[ $CURRENT != 1 && $words[$CURRENT] != -* && $words[$CURRENT-1] != "-r" ]]; then 29 | state=packages 30 | elif [[ $words[$CURRENT-1] == "-r" ]]; then 31 | state=files 32 | else 33 | state=subcommands 34 | fi 35 | ;; 36 | esac 37 | 38 | case $state in 39 | subcommands) 40 | reply=($( COMP_WORDS="$service $words[*]" \ 41 | COMP_CWORD=0 \ 42 | PIP_AUTO_COMPLETE=1 $service )) 43 | _describe -t commands 'pip commands' reply 44 | ;; 45 | packages) 46 | if [[ -n $words[CURRENT] ]]; then 47 | packages=($( pip search "$words[CURRENT]" | \ 48 | grep -i "^$words[CURRENT]" | \ 49 | cut -d ' ' -f 1 | tr '[A-Z]' '[a-z]' )) 50 | _describe -t commands 'packages' packages 51 | fi 52 | ;; 53 | files) 54 | _arguments -C '*:input file:_files' && return 0 55 | esac 56 | --------------------------------------------------------------------------------