fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
4a12d5771
master
1# Fish shell completions for conda, the package management system 2# https://conda.io/docs 3# Based on `conda help` as per version 4.4.11 4# Advanced completions: 5# - completion of already defined keys for `conda config` 6# - completion of already created environment where possible 7# 8# Note: conda ships with a completion for fish, automatically generated 9# from `conda -h` but it is far cruder than the completions in this file, 10# and it is by nature far too tricky to tweak to get the desired richness. 11# Hence this effort. 12 13# First, as part of conda's configuration, some complete would have been defined 14# Let's erase them, so that we start from a blank state 15complete -c conda -e 16 17function __fish_conda_subcommand 18# This function does triple-duty: 19# If called without arguments, it will print the first subcommand. 20# If one exists, it returns false. 21# If it doesn't, it returns true. 22# 23# If called with arguments, it will check that those match the given subcommands, 24# and that there are no additional subcommands. 25set -l subcmds$argv 26set -q subcmds[ 1 ] 27set -l have_sub$status 28 29# get the commandline args without the "conda" 30set -l toks( commandline -xpc)[ 2..-1] 31 32# if we had options with arguments, 33# they'd need to be listed here to be removed. 34argparse -u --$toks 2> /dev/null 35# Return false if it fails - this shouldn't really happen, 36# so all bets are off 37or return 2 38 39# Remove all matching subcommands 40while set -q subcmds[ 1 ] 41# If the subcommand matches, or we have an option, go on. 42# (if the option took an argument we wouldn't know, 43# so it needs to be argparse'd out above!) 44if test " $subcmds [ 1 ] " = " $argv [ 1 ] " 45set -e argv[ 1 ] 46set -e subcmds[ 1 ] 47else 48return 1 49end 50end 51 52# If we have no subcommand 53# we either matched all given subcommands or we need one. 54if not set -q argv[ 1 ] 55return $have_sub 56end 57 58echo --$argv [ 1 ] 59 60# If we didn't have subcommands to check, return true 61# If we did, this is an additional command and so we return false. 62not test $have_sub -eq 0 63end 64 65function __fish_conda -a cmd 66complete -c conda -n"contains -- (__fish_conda_subcommand) $cmd " $argv [ 2 .. -1 ] 67end 68 69# Complete for the first argument only 70function __fish_conda_top 71complete -c conda -n'not __fish_conda_subcommand' $argv 72end 73 74function __fish_conda_config_keys 75conda config --show| string match -r'^\w+(?=:)' 76end 77 78function __fish_conda_environments 79conda env list| string match -rv'^#' | string match -r'^\S+' 80end 81 82# common options 83complete -c conda -f 84complete -c conda -s h -l help -d"Show help and exit" 85 86# top-level options 87__fish_conda_top -s V -l version -d"Show the conda version number and exit" 88 89# top-level commands 90__fish_conda_top -a clean -d"Remove unused packages and caches" 91__fish_conda_top -a config -d"Modify configuration values in .condarc" 92__fish_conda_top -a create -d"Create a new conda environment from a list of specified packages" 93__fish_conda_top -a help -d"Displays a list of available conda commands and their help strings" 94__fish_conda_top -a info -d"Display information about current conda install" 95__fish_conda_top -a install -d"Installs a list of packages into a specified conda environment" 96__fish_conda_top -a list -d"List linked packages in a conda environment" 97__fish_conda_top -a package -d"Low-level conda package utility (EXPERIMENTAL)" 98__fish_conda_top -a remove -d"Remove a list of packages from a specified conda environment" 99__fish_conda_top -a uninstall -d"Alias for conda remove" 100__fish_conda_top -a search -d"Search for packages and display associated information" 101__fish_conda_top -a update -d"Updates conda packages to the latest compatible version" 102__fish_conda_top -a upgrade -d"Alias for conda update" 103 104# command added by sourcing ~/miniconda3/etc/fish/conf.d/conda.fish, 105# which is the recommended way to use conda with fish 106__fish_conda_top -a activate -d"Activate the given environment" 107__fish_conda activate -x -a"(__fish_conda_environments)" 108__fish_conda_top -a deactivate -d"Deactivate current environment, reactivating the previous one" 109 110# common to all top-level commands 111 112set -l __fish_conda_commands clean config create help info install list package remove uninstall search update upgrade 113for cmdin $__fish_conda_commands 114__fish_conda $cmd -l json -d"Report all output as json" 115__fish_conda $cmd -l debug -d"Show debug output" 116__fish_conda $cmd -l verbose -s v -d"Use once for info, twice for debug, three times for trace" 117end 118 119# 'clean' command 120__fish_conda clean -s y -l yes -d"Do not ask for confirmation" 121__fish_conda clean -l dry-run -d"Only display what would have been done" 122__fish_conda clean -s q -l quiet -d"Do not display progress bar" 123__fish_conda clean -s a -l all -d"Remove all: same as -iltps" 124__fish_conda clean -s i -l index-cache -d"Remove index cache" 125__fish_conda clean -s l -l lock -d"Remove all conda lock files" 126__fish_conda clean -s t -l tarballs -d"Remove cached package tarballs" 127__fish_conda clean -s p -l packages -d"Remove unused cached packages (no check for symlinks)" 128__fish_conda clean -s s -l source-cache -d"Remove files from the source cache of conda build" 129 130# 'config' command 131 132__fish_conda config -l system -d"Write to the system .condarc file" 133__fish_conda config -l env -d"Write to the active conda environment .condarc file" 134__fish_conda config -l file -d"Write to the given file" -F 135__fish_conda config -l show -x -a"(__fish_conda_config_keys)" -d"Display configuration values" 136__fish_conda config -l show-sources -d"Display all identified configuration sources" 137__fish_conda config -l validate -d"Validate all configuration sources" 138__fish_conda config -l describe -x -a"(__fish_conda_config_keys)" -d"Describe configuration parameters" 139__fish_conda config -l write-default -d"Write the default configuration to a file" 140__fish_conda config -l get -x -a"(__fish_conda_config_keys)" -d"Get a configuration value" 141__fish_conda config -l append -d"Add one configuration value to the end of a list key" 142__fish_conda config -l prepend -d"Add one configuration value to the beginning of a list key" 143__fish_conda config -l add -d"Alias for --prepend" 144__fish_conda config -l set -x -a"(__fish_conda_config_keys)" -d"Set a boolean or string key" 145__fish_conda config -l remove -x -a"(__fish_conda_config_keys)" -d"Remove a configuration value from a list key" 146__fish_conda config -l remove-key -x -a"(__fish_conda_config_keys)" -d"Remove a configuration key (and all its values)" 147__fish_conda config -l stdin -d"Apply configuration given in yaml format from stdin" 148 149# 'help' command 150__fish_conda help -d"Displays a list of available conda commands and their help strings" 151__fish_conda help -x -a" $__fish_conda_commands " 152 153# 'info' command 154__fish_conda info -l offline -d"Offline mode, don't connect to the Internet." 155__fish_conda info -s a -l all -d"Show all information, (environments, license, and system information)" 156__fish_conda info -s e -l envs -d"List all known conda environments" 157__fish_conda info -s l -l license -d"Display information about the local conda licenses list" 158__fish_conda info -s s -l system -d"List environment variables" 159__fish_conda info -l base -d"Display base environment path" 160__fish_conda info -l unsafe-channels -d"Display list of channels with tokens exposed" 161 162# The remaining commands share many options, so the definitions are written the other way around: 163# the outer loop is on the options 164 165# Option channel 166for cmdin create install remove search update 167__fish_conda $cmd -s c -l channel -d'Additional channel to search for packages' 168end 169 170# Option channel-priority 171for cmdin create install update 172__fish_conda $cmd -l channel-priority -d'Channel priority takes precedence over package version' 173end 174 175# Option clobber 176for cmdin create install update 177__fish_conda $cmd -l clobber -d'Allow clobbering of overlapping file paths (no warnings)' 178end 179 180# Option clone 181__fish_conda create -l clone -x -a"(__fish_conda_environments)" -d"Path to (or name of) existing local environment" 182 183# Option copy 184for cmdin create install update 185__fish_conda $cmd -l copy -d'Install all packages using copies instead of hard- or soft-linking' 186end 187 188# Option download-only 189for cmdin create install update 190__fish_conda $cmd -l download-only -d'Solve an environment: populate caches but no linking/unlinking into prefix' 191end 192 193# Option dry-run 194for cmdin create install remove update 195__fish_conda $cmd -l dry-run -d'Only display what would have been done' 196end 197 198# Option file 199for cmdin create install update 200__fish_conda $cmd -l file -d'Read package versions from the given file' -F 201end 202 203# Option force 204for cmdin create install remove update 205__fish_conda $cmd -l force -d'Force install (even when package already installed)' 206end 207 208# Option insecure 209for cmdin create install remove search update 210__fish_conda $cmd -l insecure -d'Allow conda to perform "insecure" SSL connections and transfers' 211end 212 213# Option mkdir 214for cmdin create install update 215__fish_conda $cmd -l mkdir -d'Create the environment directory if necessary' 216end 217 218# Option name 219__fish_conda create -s n -l name -d"Name of new environment" 220for cmdin install list remove search update 221__fish_conda $cmd -s n -l name -x -a"(__fish_conda_environments)" -d"Name of existing environment" 222end 223 224# Option no-channel-priority 225for cmdin create install update 226__fish_conda $cmd -l no-channel-priority -l no-channel-pri -l no-chan-pri -d'Package version takes precedence over channel priority' 227end 228 229# Option no-default-packages 230__fish_conda create -l no-default-packages -d'Ignore create_default_packages in the .condarc file' 231 232# Option no-deps 233for cmdin create install update 234__fish_conda $cmd -l no-deps -d'Do not install, update, remove, or change dependencies' 235end 236 237# Option no-pin 238for cmdin create install remove update 239__fish_conda $cmd -l no-pin -d'Ignore pinned file' 240end 241 242# Option no-show-channel-urls 243for cmdin create install list update 244__fish_conda $cmd -l no-show-channel-urls -d"Don't show channel urls" 245end 246 247# Option no-update-dependencies 248for cmdin create install update 249__fish_conda $cmd -l no-update-dependencies -l no-update-deps -d"Don't update dependencies" 250end 251 252# Option offline 253for cmdin create install remove search update 254__fish_conda $cmd -l offline -d"Offline mode, don't connect to the Internet" 255end 256 257# Option only-deps 258for cmdin create install update 259__fish_conda $cmd -l only-deps -d"Only install dependencies" 260end 261 262# Option override-channels 263for cmdin create install remove search update 264__fish_conda $cmd -l override-channels -d"Do not search default or .condarc channels" 265end 266 267# Option prefix 268for cmdin create install list remove search update 269__fish_conda $cmd -s p -l prefix -d"Full path to environment prefix" 270end 271 272# Option quiet 273for cmdin create install remove update 274__fish_conda $cmd -s q -l quiet -d"Do not display progress bar" 275end 276 277# Option show-channel-urls 278for cmdin create install list update 279__fish_conda $cmd -l show-channel-urls -d"Show channel urls" 280end 281 282# Option update-dependencies 283for cmdin create install update 284__fish_conda $cmd -l update-dependencies -l update-deps -d"Update dependencies" 285end 286 287# Option use-index-cache 288for cmdin create install remove search update 289__fish_conda $cmd -s C -l use-index-cache -d"Use cache of channel index files, even if it has expired" 290end 291 292# Option use-local 293for cmdin create install remove search update 294__fish_conda $cmd -l use-local -d"Use locally built packages" 295end 296 297# Option yes 298for cmdin create install remove update 299__fish_conda $cmd -s y -l yes -d"Do not ask for confirmation" 300end 301 302# Option revision 303__fish_conda install -l revision -d"Revert to the specified REVISION" 304 305# Option canonical 306__fish_conda list -s c -l canonical -d"Output canonical names of packages only. Implies --no-pip" 307 308# Option explicit 309__fish_conda list -l explicit -d"List explicitly all installed conda with URL (output usable by conda create --file)" 310 311# Option export 312__fish_conda list -s e -l export -d"Output requirement string only (output usable by conda create --file)" 313 314# Option full-name 315__fish_conda list -s f -l full-name -d"Only search for full names, i.e., ^<regex>\$" 316 317# Option md5 318__fish_conda list -l md5 -d"Add MD5 hashsum when using --explicit" 319 320# Option no-pip 321__fish_conda list -s c -l canonical -d"Output canonical names of packages only. Implies --no-pip" 322 323# Option revisions 324__fish_conda list -s r -l revisions -d"List the revision history and exit" 325 326# Option all 327__fish_conda remove -l all -d"Remove all packages, i.e., the entire environment" 328__fish_conda update -l all -d"Update all installed packages in the environment" 329 330# Option features 331__fish_conda remove -l features -d"Remove features (instead of packages)" 332 333# Option info 334__fish_conda search -s i -l info -d"Provide detailed information about each package" 335 336# Option platform 337set -l __fish_conda_platforms{ osx, linux, win} -{ 32 , 64 } 338__fish_conda search -l platform -x -a" $__fish_conda_platforms " -d"Search the given platform" 339 340# Option reverse-dependency 341__fish_conda search -l reverse-dependency -d"Perform a reverse dependency search" 342 343__fish_conda_top -a env -d"Conda options for environments" 344complete -c conda -n"__fish_conda_subcommand env" -a create -d"Create a new environment" 345complete -c conda -n"__fish_conda_subcommand env" -a list -d"List all conda environments" 346complete -c conda -n"__fish_conda_subcommand env create" -s f -l file -rF -d"Create environment from yaml file"