From e1eb817d5bc69e675387152e3d9ffbe5ca40570d Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Wed, 27 Mar 2024 14:41:47 -0500 Subject: [PATCH] update completions --- home/private_dot_config/zsh/completions/_pdm | 72 +++++++++++++++++-- .../zsh/completions/_rclone | 47 ++++++++++-- .../zsh/completions/executable_update.sh | 2 +- 3 files changed, 107 insertions(+), 14 deletions(-) diff --git a/home/private_dot_config/zsh/completions/_pdm b/home/private_dot_config/zsh/completions/_pdm index 8e5a933..9b15e45 100644 --- a/home/private_dot_config/zsh/completions/_pdm +++ b/home/private_dot_config/zsh/completions/_pdm @@ -30,7 +30,10 @@ _pdm() { 'list:List packages installed in the current working set' 'lock:Resolve and lock dependencies' 'self:Manage the PDM program itself (previously known as plugin)' + 'outdated:Check for outdated packages and list the latest versions' 'publish:Build and publish the project to PyPI' + 'python:Manage installed Python interpreters' + 'py:Manage installed Python interpreters' 'remove:Remove packages from pyproject.toml' 'run:Run commands or scripts with local packages loaded' 'search:Search for PyPI packages' @@ -46,6 +49,7 @@ _pdm() { {-c,--config}'[Specify another config file path\[env var: PDM_CONFIG_FILE\]]' \ {-V,--version}'[Show the version and exit]' \ {-I,--ignore-python}'[Ignore the Python path saved in .pdm-python]' \ + '--no-cache:Disable the cache for the current command. [env var: PDM_NO_CACHE]' \ '--pep582:Print the command line to be eval by the shell:shell:(zsh bash fish tcsh csh)' \ '*:: :->_subcmds' \ && return 0 @@ -83,6 +87,7 @@ _pdm() { "--stable[Only allow stable versions to be pinned]" {-e+,--editable+}'[Specify editable packages]:packages' {-x,--fail-fast}'[Abort on first installation error]' + {-C,--config-setting}'[Pass options to the backend. options with a value must be specified after "=": "--config-setting=key(=value)" or "-Ckey(=value)"]:cs:' "--no-isolation[do not isolate the build in a clean environment]" "--dry-run[Show the difference only without modifying the lockfile content]" '*:packages:_pdm_pip_packages' @@ -95,7 +100,7 @@ _pdm() { {-d+,--dest+}'[Target directory to put artifacts]:directory:_files -/' {-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' '--no-clean[Do not clean the target directory]' - {-C,--config-setting}'[Pass options to the backend. options with a value must be specified after "=": "--config-setting=--opt(=value)" or "-C--opt(=value)"]' + {-C,--config-setting}'[Pass options to the backend. options with a value must be specified after "=": "--config-setting=key(=value)" or "-Ckey(=value)"]:cs:' "--no-isolation[do not isolate the build in a clean environment]" ) ;; @@ -156,7 +161,8 @@ _pdm() { "--editable-self[Include the project itself as an editable dependency]" {-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files' {-o+,--output+}"[Write output to the given file, or print to stdout if not given]:output file:_files" - {-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + {-G+,--group+,--with+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + "--without+[Exclude groups of optional-dependencies or dev-dependencies]:group:_pdm_groups" {-d,--dev}"[Select dev dependencies]" {--prod,--production}"[Unselect dev dependencies]" "--no-default[Don't include dependencies from the default group]" @@ -204,7 +210,8 @@ _pdm() { install) arguments+=( {-g,--global}'[Use the global project, supply the project root with `-p` option]' - {-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + {-G+,--group+,--with+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + "--without+[Exclude groups of optional-dependencies or dev-dependencies]:group:_pdm_groups" {-d,--dev}"[Select dev dependencies]" {-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files' {--prod,--production}"[Unselect dev dependencies]" @@ -214,6 +221,7 @@ _pdm() { '--no-editable[Install non-editable versions for all packages]' "--no-self[Don't install the project itself]" {-x,--fail-fast}'[Abort on first installation error]' + {-C,--config-setting}'[Pass options to the backend. options with a value must be specified after "=": "--config-setting=key(=value)" or "-Ckey(=value)"]:cs:' "--no-isolation[do not isolate the build in a clean environment]" "--dry-run[Show the difference only without modifying the lock file content]" "--check[Check if the lock file is up to date and fail otherwise]" @@ -243,11 +251,13 @@ _pdm() { arguments+=( {-g,--global}'[Use the global project, supply the project root with `-p` option]' {-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files' + {-C,--config-setting}'[Pass options to the backend. options with a value must be specified after "=": "--config-setting=key(=value)" or "-Ckey(=value)"]:cs:' "--no-isolation[Do not isolate the build in a clean environment]" {-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' - "--refresh[Don't update pinned versions, only refresh the lock file]" + "--refresh[Refresh the content hash and file hashes in the lock file]" "--check[Check if the lock file is up to date and quit]" - {-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + {-G+,--group+,--with+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + "--without+[Exclude groups of optional-dependencies or dev-dependencies]:group:_pdm_groups" {-d,--dev}"[Select dev dependencies]" {--prod,--production}"[Unselect dev dependencies]" '--update-reuse[Reuse pinned versions already present in lock file if possible]' @@ -256,9 +266,16 @@ _pdm() { "--no-static-urls[(DEPRECATED) Do not store static file URLs in the lockfile]" "--no-default[Don\'t include dependencies from the default group]" "--no-cross-platform[(DEPRECATED) Only lock packages for the current platform]" + "--exclude-newer[Exclude packages newer than the given UTC date in format YYYY-MM-DD\[THH:MM:SSZ\]]:exclude-newer:" {-S,--strategy}'[Specify lock strategy(cross_platform,static_urls,direct_minimal_versions). Add no_ prefix to disable. Support given multiple times or split by comma.]:strategy:' ) ;; + outdated) + arguments+=( + '--json[Output in JSON format]' + '*:patterns:' + ) + ;; self) _arguments -C \ $arguments \ @@ -292,6 +309,7 @@ _pdm() { list) arguments+=( '--plugins[List plugins only]' + '*:patterns:' ) ;; update) @@ -308,6 +326,40 @@ _pdm() { esac return $ret ;; + python|py) + _arguments -C \ + $arguments \ + ': :->command' \ + '*:: :->args' && ret=0 + case $state in + command) + local -a actions=( + "remove:Remove a Python interpreter installed with PDM" + "list:List all Python interpreters installed with PDM" + "install:Install a Python interpreter with PDM" + ) + _describe -t command 'pdm python actions' actions && ret=0 + ;; + args) + case $words[1] in + remove) + arguments+=( + ':python:' + ) + ;; + install) + arguments+=( + '--list[List all available Python versions]' + ':python:_files' + ) + ;; + *) + ;; + esac + ;; + esac + return $ret + ;; publish) arguments+=( {-r,--repository}'[The repository name or url to publish the package to }\[env var: PDM_PUBLISH_REPO\]]:repository:' @@ -317,6 +369,7 @@ _pdm() { {-i,--identity}'[GPG identity used to sign files.]:gpg identity:' {-k,--skip}'[Skip some tasks and/or hooks by their comma-separated names]' {-c,--comment}'[The comment to include with the distribution file.]:comment:' + {-d,--dest}'[The directory to upload the package from]:dest:_files' "--no-verify-ssl[Disable SSL verification]" "--ca-certs[The path to a PEM-encoded Certificate Authority bundle to use for publish server validation]:cacerts:_files" "--no-build[Don't build the package before publishing]" @@ -335,6 +388,7 @@ _pdm() { "--no-self[Don't install the project itself]" "--frozen-lockfile[Don't try to create or update the lockfile. \[env var: PDM_FROZEN_LOCKFILE\]]" {-x,--fail-fast}'[Abort on first installation error]' + {-C,--config-setting}'[Pass options to the backend. options with a value must be specified after "=": "--config-setting=key(=value)" or "-Ckey(=value)"]:cs:' "--no-isolation[do not isolate the build in a clean environment]" "--dry-run[Show the difference only without modifying the lockfile content]" '--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:' @@ -379,7 +433,8 @@ _pdm() { sync) arguments+=( {-g,--global}'[Use the global project, supply the project root with `-p` option]' - {-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + {-G+,--group+,--with+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + "--without+[Exclude groups of optional-dependencies or dev-dependencies]:group:_pdm_groups" {-d,--dev}"[Select dev dependencies]" {-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files' {--prod,--production}"[Unselect dev dependencies]" @@ -392,6 +447,7 @@ _pdm() { {-x,--fail-fast}'[Abort on first installation error]' '--no-editable[Install non-editable versions for all packages]' "--no-self[Don't install the project itself]" + {-C,--config-setting}'[Pass options to the backend. options with a value must be specified after "=": "--config-setting=key(=value)" or "-Ckey(=value)"]:cs:' "--no-isolation[do not isolate the build in a clean environment]" '--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:' ) @@ -399,7 +455,8 @@ _pdm() { update) arguments+=( {-g,--global}'[Use the global project, supply the project root with `-p` option]' - {-G+,--group+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + {-G+,--group+,--with+}'[Select group of optional-dependencies or dev-dependencies(with -d). Can be supplied multiple times, use ":all" to include all groups under the same species]:group:_pdm_groups' + "--without+[Exclude groups of optional-dependencies or dev-dependencies]:group:_pdm_groups" {-L,--lockfile}'[Specify another lockfile path, or use `PDM_LOCKFILE` env variable. Default: pdm.lock]:lockfile:_files' '--save-compatible[Save compatible version specifiers]' '--save-wildcard[Save wildcard version specifiers]' @@ -424,6 +481,7 @@ _pdm() { "--dry-run[Show the difference only without modifying the lockfile content]" "--outdated[Show the difference only without modifying the lockfile content]" {-x,--fail-fast}'[Abort on first installation error]' + {-C,--config-setting}'[Pass options to the backend. options with a value must be specified after "=": "--config-setting=key(=value)" or "-Ckey(=value)"]:cs:' "--no-isolation[do not isolate the build in a clean environment]" '--venv[Run the command in the virtual environment with the given key. \[env var: PDM_IN_VENV\]]:venv:' "*:packages:_pdm_packages" diff --git a/home/private_dot_config/zsh/completions/_rclone b/home/private_dot_config/zsh/completions/_rclone index 6b2579a..67b3006 100644 --- a/home/private_dot_config/zsh/completions/_rclone +++ b/home/private_dot_config/zsh/completions/_rclone @@ -1,4 +1,5 @@ -#compdef _rclone rclone +#compdef rclone +compdef _rclone rclone # zsh completion for rclone -*- shell-script -*- @@ -17,8 +18,9 @@ _rclone() local shellCompDirectiveNoFileComp=4 local shellCompDirectiveFilterFileExt=8 local shellCompDirectiveFilterDirs=16 + local shellCompDirectiveKeepOrder=32 - local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace + local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder local -a completions __rclone_debug "\n========= starting completion logic ==========" @@ -86,7 +88,24 @@ _rclone() return fi + local activeHelpMarker="_activeHelp_ " + local endIndex=${#activeHelpMarker} + local startIndex=$((${#activeHelpMarker}+1)) + local hasActiveHelp=0 while IFS='\n' read -r comp; do + # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker) + if [ "${comp[1,$endIndex]}" = "$activeHelpMarker" ];then + __rclone_debug "ActiveHelp found: $comp" + comp="${comp[$startIndex,-1]}" + if [ -n "$comp" ]; then + compadd -x "${comp}" + __rclone_debug "ActiveHelp will need delimiter" + hasActiveHelp=1 + fi + + continue + fi + if [ -n "$comp" ]; then # If requested, completions are returned with a description. # The description is preceded by a TAB character. @@ -94,7 +113,7 @@ _rclone() # We first need to escape any : as part of the completion itself. comp=${comp//:/\\:} - local tab=$(printf '\t') + local tab="$(printf '\t')" comp=${comp//$tab/:} __rclone_debug "Adding completion: ${comp}" @@ -103,11 +122,27 @@ _rclone() fi done < <(printf "%s\n" "${out[@]}") + # Add a delimiter after the activeHelp statements, but only if: + # - there are completions following the activeHelp statements, or + # - file completion will be performed (so there will be choices after the activeHelp) + if [ $hasActiveHelp -eq 1 ]; then + if [ ${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then + __rclone_debug "Adding activeHelp delimiter" + compadd -x "--" + hasActiveHelp=0 + fi + fi + if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then __rclone_debug "Activating nospace." noSpace="-S ''" fi + if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then + __rclone_debug "Activating keep order." + keepOrder="-V" + fi + if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then # File extension filtering local filteringCmd @@ -125,7 +160,7 @@ _rclone() _arguments '*:filename:'"$filteringCmd" elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then # File completion for directories only - local subDir + local subdir subdir="${completions[1]}" if [ -n "$subdir" ]; then __rclone_debug "Listing directories in $subdir" @@ -143,7 +178,7 @@ _rclone() return $result else __rclone_debug "Calling _describe" - if eval _describe "completions" completions $flagPrefix $noSpace; then + if eval _describe $keepOrder "completions" completions $flagPrefix $noSpace; then __rclone_debug "_describe found some completions" # Return the success of having called _describe @@ -173,5 +208,5 @@ _rclone() # don't run the completion function when being source-ed or eval-ed if [ "$funcstack[1]" = "_rclone" ]; then - _rclone + _rclone fi diff --git a/home/private_dot_config/zsh/completions/executable_update.sh b/home/private_dot_config/zsh/completions/executable_update.sh index 745e7b3..36a191e 100644 --- a/home/private_dot_config/zsh/completions/executable_update.sh +++ b/home/private_dot_config/zsh/completions/executable_update.sh @@ -23,4 +23,4 @@ gen chezmoi completion zsh gen rye self completion -s zsh gen gh completion -s zsh gen pixi completion -s zsh -gen rclone completion zsh +gen rclone completion zsh -