Files
conda-zsh-completion/_conda
Valentin Haenel c68c9fa8dd use zsh arrays
2015-02-10 15:34:06 +01:00

114 lines
4.1 KiB
Plaintext

#compdef conda
#description:conda package manager
local state line context
local -A opt_args
__conda_envs(){
local -a envs
envs=($( conda info -e | sed "1,2d" | cut -f1 -d' '))
_describe -t envs 'conda environments' envs
}
__conda_packages_search(){
local -a packages
packages=($(conda search --use-index-cache --json |
python -c "
import json, sys
parsed = json.load(sys.stdin)
for k in parsed.keys():
print(k)
"))
_describe -t packages 'available packages' packages
}
__conda_channels(){
local -a channels
channels=(default system)
_describe -t channels 'conda channels' channels
}
local -a opts
opts=(
'(-h --help)'{-h,--help}'[show this help message and exit]'
'(-v --version)'{-v,--version}'[show program''s version number and exit]'
)
_arguments -C $opts \
': :->command' \
'*:: :->subcmd'
case $state in
(command)
local -a package maint environment help config special
package=(
search:'Search for packages and display their information.'
install:'Install a list of packages into a specified conda environment.'
)
maint=(
update:'Update conda packages.'
clean:'Remove unused packages and caches.'
)
environment=(
info:'Display information about current conda install.'
create:'Create a new conda environment from a list of specified packages.'
list:'List linked packages in a conda environment.'
remove:'Remove a list of packages from a specified conda environment.'
)
help=(
help:'Displays a list of available conda commands and their help strings.'
)
config=(
config:'Modify configuration values in .condarc.'
)
special=(
run:'Launches an application installed with Conda.'
init:'Initialize conda into a regular environment. (DEPRECATED)'
package:'Low-level conda package utility. (EXPERIMENTAL)'
bundle:'Create or extract a "bundle package" (EXPERIMENTAL)'
)
_describe -t package_commands "package commands" package
_describe -t maint_commands "maint commands" maint
_describe -t environment_commands "environment commands" environment
_describe -t help_commands "help commands" help
_describe -t config_commands "config commands" config
_describe -t special_commands "special commands" special
;;
(subcmd)
case ${line[1]} in
(install)
_arguments '(-n --name=)'{-n,--name=}'[install into given conda environment]:environment:__conda_envs' \
'(-h --help)'{-h,--help}'[show the help message and exit]' \
'--revision[revert to the specified revision]:revision' \
'(-y --yes)'{-y,--yes}'[do not ask for confirmation]' \
'--dry-run[only display what would have been done]' \
'--file[read package versions from file]:file:_path_files' \
'--unknown[use index metadata from the local package cache]' \
'--no-deps[do not install dependencies]' \
'(-m --mkdir)'{-m,--mkdir}'[create prefix directory if necessary]' \
'--use-index-cache[use cache of channel index files]' \
'--use-local[use locally built packages]' \
'--offline[offline mode, don''t connect to internet]' \
'--no-pin[ignore pinned file]' \
'(-c --channel)'{-c,--channel}'[additional channel to search for packages]:channel:__conda_channels'\
'--override-channels [do not search default or .condarc channels]' \
'(-p --prefix)'{-p,--prefix}'[full path to environment prefix]:path:_path_files' \
'(-q --quiet)'{-q,--quiet}'[do not display progress bar]'\
'--copy[Install all packages using copies instead of hard- or soft-linking]' \
'--alt-hint[Use an alternate algorithm to generate an unsatisfiable hint]' \
'--json[report all output as json.]' \
'*:packages:__conda_packages_search' \
;;
(*)
#_arguments -C $opts
_path_files
;;
esac
;;
esac