diff options
Diffstat (limited to 'plugins')
62 files changed, 1222 insertions, 1291 deletions
diff --git a/plugins/1password/1password.plugin.zsh b/plugins/1password/1password.plugin.zsh new file mode 100644 index 000000000..9398b02b4 --- /dev/null +++ b/plugins/1password/1password.plugin.zsh @@ -0,0 +1,46 @@ +if (( ${+commands[op]} )); then + eval "$(op completion zsh)" + compdef _op op +fi + +# opswd puts the password of the named service into the clipboard. If there's a +# one time password, it will be copied into the clipboard after 10 seconds. The +# clipboard is cleared after another 20 seconds. +function opswd() { + if [[ $# -lt 1 ]]; then + echo "Usage: opswd <service>" + return 1 + fi + + local service=$1 + + # If not logged in, print error and return + op list users > /dev/null || return + + local password + # Copy the password to the clipboard + if ! password=$(op get item "$service" --fields password 2>/dev/null); then + echo "error: could not obtain password for $service" + return 1 + fi + + echo -n "$password" | clipcopy + echo "✔ password for $service copied to clipboard" + + # If there's a one time password, copy it to the clipboard after 5 seconds + local totp + if totp=$(op get totp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then + sleep 10 && echo -n "$totp" | clipcopy + echo "✔ TOTP for $service copied to clipboard" + fi + + (sleep 20 && clipcopy </dev/null 2>/dev/null) &! +} + +function _opswd() { + local -a services + services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}") + [[ -z "$services" ]] || compadd -a -- services +} + +compdef _opswd opswd diff --git a/plugins/1password/README.md b/plugins/1password/README.md new file mode 100644 index 000000000..f6790ca8a --- /dev/null +++ b/plugins/1password/README.md @@ -0,0 +1,35 @@ +# 1Password + +This plugin adds 1Password functionality to oh-my-zsh. + +To use, add `1password` to the list of plugins in your `.zshrc` file: + +```zsh +plugins=(... 1password) +``` + +Then, you can use the command `opswd` to copy passwords for services into your +clipboard. + +## `opswd` + +The `opswd` command is a wrapper around the `op` command. It takes a service +name as an argument and copies the password for that service to the clipboard. + +If the service also contains a TOTP, it is copied to the clipboard after 10 seconds. +Finally, after 20 seconds, the clipboard is cleared. + +The function has completion support, so you can use tab completion to select +which service you want to get. + +For example, `opswd github.com` will put your GitHub password into your clipboard, and if +a TOTP is available, it will be copied to the clipboard after 10 seconds. + +> NOTE: you need to be logged in for `opswd` to work. See: +> +> - [Sign in or out](https://support.1password.com/command-line/#sign-in-or-out) +> - [Session management](https://support.1password.com/command-line/#appendix-session-management) + +## Requirements + +- [1Password's command line utility](https://1password.com/downloads/command-line/). diff --git a/plugins/aws/README.md b/plugins/aws/README.md index 24c6429dd..d6f4f4600 100644 --- a/plugins/aws/README.md +++ b/plugins/aws/README.md @@ -16,10 +16,10 @@ plugins=(... aws) Run `asp` without arguments to clear the profile. * `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection. -* `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by - assuming the role specified in the `<profile>` configuration. It supports MFA and sets - `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It - requires the roles to be configured as per the +* `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes + the profile by assuming the role specified in the `<profile>` configuration. It supports + MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if + obtained. It requires the roles to be configured as per the [official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html). Run `acp` without arguments to clear the profile. diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 3a3a111b4..920a7139d 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -45,6 +45,7 @@ function acp() { fi local profile="$1" + local mfa_token="$2" # Get fallback credentials for if the aws command fails or no command is run local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)" @@ -58,9 +59,10 @@ function acp() { if [[ -n "$mfa_serial" ]]; then local -a mfa_opt - local mfa_token - echo -n "Please enter your MFA token for $mfa_serial: " - read -r mfa_token + if [[ -z "$mfa_token" ]]; then + echo -n "Please enter your MFA token for $mfa_serial: " + read -r mfa_token + fi if [[ -z "$sess_duration" ]]; then echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): " read -r sess_duration @@ -155,8 +157,8 @@ compctl -K _aws_profiles asp acp aws_change_access_key # AWS prompt function aws_prompt_info() { - [[ -z $AWS_PROFILE ]] && return - echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}" + [[ -n "$AWS_PROFILE" ]] || return + echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX:=>}" } if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh index 087ddce97..981992d88 100644 --- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh +++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh @@ -22,7 +22,7 @@ less_termcap[ue]="${reset_color}" 0="${${(M)0:#/*}:-$PWD/$0}" # Absolute path to this file's directory. -typeset __colored_man_pages_dir="${0:A:h}" +typeset -g __colored_man_pages_dir="${0:A:h}" function colored() { local -a environment diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh index 77c2125d2..6c12bae13 100644 --- a/plugins/deno/deno.plugin.zsh +++ b/plugins/deno/deno.plugin.zsh @@ -32,7 +32,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `deno`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _deno _comps[deno]=_deno fi diff --git a/plugins/django/README.md b/plugins/django/README.md deleted file mode 100644 index cfab43980..000000000 --- a/plugins/django/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Django plugin - -This plugin adds completion for the [Django Project](https://www.djangoproject.com/) commands -(`manage.py`, `django-admin`, ...). - -## Deprecation (2021-09-22) - -The plugin used to provide completion for `./manage.py` and `django-admin`, but Zsh already provides -a better, more extensive completion for those, so this plugin is no longer needed. - -Right now a warning message is shown, but in the near future the plugin will stop working altogether. -So you can remove it from your plugins and you'll automatically start using Zsh's django completion. diff --git a/plugins/django/django.plugin.zsh b/plugins/django/django.plugin.zsh deleted file mode 100644 index a07a30889..000000000 --- a/plugins/django/django.plugin.zsh +++ /dev/null @@ -1,407 +0,0 @@ -#compdef manage.py - -typeset -ga nul_args -nul_args=( - '--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))' - '--settings=-[the Python path to a settings module.]:file:_files' - '--pythonpath=-[a directory to add to the Python path.]:directory:_directories' - '--traceback[print traceback on exception.]' - "--no-color[Don't colorize the command output.]" - "--version[show program's version number and exit.]" - {-h,--help}'[show this help message and exit.]' -) - -typeset -ga start_args -start_args=( - '--template=-[The path or URL to load the template from.]:directory:_directories' - '--extension=-[The file extension(s) to render (default: "py").]' - '--name=-[The file name(s) to render.]:file:_files' -) - -typeset -ga db_args -db_args=( - '--database=-[Nominates a database. Defaults to the "default" database.]' -) - -typeset -ga noinput_args -noinput_args=( - '--noinput[tells Django to NOT prompt the user for input of any kind.]' -) - -typeset -ga no_init_data_args -no_init_data_args=( - '--no-initial-data[Tells Django not to load any initial data after database synchronization.]' -) - -typeset -ga tag_args -tag_args=( - '--tag=-[Run only checks labeled with given tag.]' - '--list-tags[List available tags.]' -) - -_managepy-check(){ - _arguments -s : \ - $tag_args \ - $nul_args && ret=0 -} - -_managepy-changepassword(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-createcachetable(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-createsuperuser(){ - _arguments -s : \ - '--username=-[Specifies the login for the superuser.]' \ - '--email=-[Specifies the email for the superuser.]' \ - $noinput_args \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-collectstatic(){ - _arguments -s : \ - '--link[Create a symbolic link to each file instead of copying.]' \ - '--no-post-process[Do NOT post process collected files.]' \ - '--ignore=-[Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.]' \ - '--dry-run[Do everything except modify the filesystem.]' \ - '--clear[Clear the existing files using the storage before trying to copy or link the original file.]' \ - '--link[Create a symbolic link to each file instead of copying.]' \ - '--no-default-ignore[Do not ignore the common private glob-style patterns "CVS", ".*" and "*~".]' \ - $noinput_args \ - $nul_args && ret=0 -} - -_managepy-dbshell(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-diffsettings(){ - _arguments -s : \ - "--all[Display all settings, regardless of their value.]" - $nul_args && ret=0 -} - -_managepy-dumpdata(){ - _arguments -s : \ - '--format=-[Specifies the output serialization format for fixtures.]:format:(json yaml xml)' \ - '--indent=-[Specifies the indent level to use when pretty-printing output.]' \ - '--exclude=-[An app_label or app_label.ModelName to exclude (use multiple --exclude to exclude multiple apps/models).]' \ - '--natural-foreign[Use natural foreign keys if they are available.]' \ - '--natural-primary[Use natural primary keys if they are available.]' \ - "--all[Use Django's base manager to dump all models stored in the database.]" \ - '--pks=-[Only dump objects with given primary keys.]' \ - $db_args \ - $nul_args \ - '*::appname:_applist' && ret=0 -} - -_managepy-flush(){ - _arguments -s : \ - $no_init_data_args \ - $db_args \ - $noinput_args \ - $nul_args && ret=0 -} - -_managepy-help(){ - _arguments -s : \ - '*:command:_managepy_cmds' \ - $nul_args && ret=0 -} - -_managepy_cmds(){ - local line - local -a cmd - _call_program help-command ./manage.py help \ - |& sed -n '/^ /s/[(), ]/ /gp' \ - | while read -A line; do cmd=($line $cmd) done - _describe -t managepy-command 'manage.py command' cmd -} - -_managepy-inspectdb(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-loaddata(){ - _arguments -s : \ - '--ignorenonexistent[Ignores entries in the serialized data for fields that do not currently exist on the model.]' \ - '--app=-[Only look for fixtures in the specified app.]:appname:_applist' \ - '*::file:_files' \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-makemessages(){ - _arguments -s : \ - '--locale=-[Creates or updates the message files for the given locale(s) (e.g. pt_BR).]' \ - '--domain=-[The domain of the message files (default: "django").]' \ - '--all[Updates the message files for all existing locales.]' \ - '--extension=-[The file extension(s) to examine (default: "html,txt", or "js" if the domain is "djangojs").]' \ - '--symlinks[Follows symlinks to directories when examining source code and templates for translation strings.]' \ - '--ignore=-[Ignore files or directories matching this glob-style pattern.]' \ - "--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \ - "--no-wrap[Don't break long message lines into several lines.]" \ - "--no-location[Don't write '#: filename:line' lines.]" \ - '--no-obsolete[Remove obsolete message strings.]' \ - '--keep-pot[Keep .pot file after making messages.]' \ - $nul_args && ret=0 -} -_managepy-makemigrations(){ - _arguments -s : \ - '--dry-run[Just show what migrations would be made]' \ - '--merge[Enable fixing of migration conflicts.]' \ - '--empty[Create an empty migration.]' \ - $noinput_args \ - $nul_args && ret=0 -} -_managepy-migrate(){ - _arguments -s : \ - '--fake[Mark migrations as run without actually running them]' \ - '--list[Show a list of all known migrations and which are applied]' \ - $no_init_data_args \ - $noinput_args \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-runfcgi(){ - local state - - local fcgi_opts - fcgi_opts=( - 'protocol[fcgi, scgi, ajp, ... (default fcgi)]:protocol:(fcgi scgi ajp)' - 'host[hostname to listen on..]:' - 'port[port to listen on.]:' - 'socket[UNIX socket to listen on.]:file:_files' - 'method[prefork or threaded (default prefork)]:method:(prefork threaded)' - 'maxrequests[number of requests a child handles before it is killed and a new child is forked (0 = no limit).]:' - 'maxspare[max number of spare processes / threads.]:' - 'minspare[min number of spare processes / threads.]:' - 'maxchildren[hard limit number of processes / threads.]:' - 'daemonize[whether to detach from terminal.]:boolean:(False True)' - 'pidfile[write the spawned process-id to this file.]:file:_files' - 'workdir[change to this directory when daemonizing.]:directory:_files' - 'outlog[write stdout to this file.]:file:_files' - 'errlog[write stderr to this file.]:file:_files' - ) - - _arguments -s : \ - $nul_args \ - '*: :_values "FCGI Setting" $fcgi_opts' && ret=0 -} - -_managepy-runserver(){ - _arguments -s : \ - '--ipv6[Tells Django to use an IPv6 address.]' \ - '--nothreading[Tells Django to NOT use threading.]' \ - '--noreload[Tells Django to NOT use the auto-reloader.]' \ - '--nostatic[Tells Django to NOT automatically serve static files at STATIC_URL.]' \ - '--insecure[Allows serving static files even if DEBUG is False.]' \ - $nul_args && ret=0 -} - -_managepy-shell(){ - _arguments -s : \ - '--plain[Tells Django to use plain Python, not IPython.]' \ - '--no-startup[When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.]' \ - '--interface=-[Specify an interactive interpreter interface.]:INTERFACE:((ipython bpython))' \ - $nul_args && ret=0 -} - -_managepy-sql(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-sqlall(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-sqlclear(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-sqlcustom(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-dropindexes(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-sqlflush(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-sqlindexes(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-sqlinitialdata(){ - _arguments -s : \ - $nul_args && ret=0 -} - -_managepy-sqlsequencereset(){ - _arguments -s : \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-squashmigrations(){ - _arguments -s : \ - '--no-optimize[Do not try to optimize the squashed operations.]' \ - $noinput_args \ - $nul_args && ret=0 -} - -_managepy-startapp(){ - _arguments -s : \ - $start_args \ - $nul_args && ret=0 -} -_managepy-startproject(){ - _arguments -s : \ - $start_args \ - $nul_args && ret=0 -} - -_managepy-syncdb() { - _arguments -s : \ - $noinput_args \ - $no_init_data_args \ - $db_args \ - $nul_args && ret=0 -} - -_managepy-test() { - _arguments -s : \ - '--failfast[Tells Django to stop running the test suite after first failed test.]' \ - '--testrunner=-[Tells Django to use specified test runner class instead of the one specified by the TEST_RUNNER setting.]' \ - '--liveserver=-[Overrides the default address where the live server (used with LiveServerTestCase) is expected to run from. The default value is localhost:8081.]' \ - '--top-level-directory=-[Top level of project for unittest discovery.]' \ - '--pattern=-[The test matching pattern. Defaults to test*.py.]:' \ - $noinput_args \ - '*::appname:_applist' \ - $nul_args && ret=0 -} - -_managepy-testserver() { - _arguments -s : \ - '--addrport=-[port number or ipaddr:port to run the server on.]' \ - '--ipv6[Tells Django to use an IPv6 address.]' \ - $noinput_args \ - '*::fixture:_files' \ - $nul_args && ret=0 -} - -_managepy-validate() { - _arguments -s : \ - $tag_args \ - $nul_args && ret=0 -} - -_managepy-commands() { - local -a commands - - commands=( - "changepassword:Change a user's password for django.contrib.auth." - 'check:Checks the entire Django project for potential problems.' - 'compilemessages:Compiles .po files to .mo files for use with builtin gettext support.' - 'createcachetable:Creates the table needed to use the SQL cache backend.' - 'createsuperuser:Used to create a superuser.' - 'collectstatic:Collect static files in a single location.' - 'dbshell:Runs the command-line client for the current DATABASE_ENGINE.' - "diffsettings:Displays differences between the current settings.py and Django's default settings." - 'dumpdata:Output the contents of the database as a fixture of the given format.' - 'flush:Executes ``sqlflush`` on the current database.' - 'help:manage.py help.' - 'inspectdb:Introspects the database tables in the given database and outputs a Django model module.' - 'loaddata:Installs the named fixture(s) in the database.' - 'makemessages:Runs over the entire source tree of the current directory and pulls out all strings marked for translation.' - 'makemigrations:Creates new migration(s) for apps.' - 'migrate:Updates database schema. Manages both apps with migrations and those without.' - 'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,' - 'runserver:Starts a lightweight Web server for development.' - 'shell:Runs a Python interactive interpreter.' - 'showmigrations:Shows all available migrations for the current project.' - 'sql:Prints the CREATE TABLE SQL statements for the given app name(s).' - 'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).' - 'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).' - 'sqlcustom:Prints the custom table modifying SQL statements for the given app name(s).' - 'sqldropindexes:Prints the DROP INDEX SQL statements for the given model module name(s).' - 'sqlflush:Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.' - 'sqlindexes:Prints the CREATE INDEX SQL statements for the given model module name(s).' - "sqlinitialdata:RENAMED: see 'sqlcustom'" - 'sqlsequencereset:Prints the SQL statements for resetting sequences for the given app name(s).' - 'squashmigrations:Squashes an existing set of migrations (from first until specified) into a single new one.' - "startapp:Creates a Django app directory structure for the given app name in this project's directory." - "startproject:Creates a Django project directory structure for the given project name in this current directory." - "syncdb:Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." - 'test:Runs the test suite for the specified applications, or the entire site if no apps are specified.' - 'testserver:Runs a development server with data from the given fixture(s).' - 'validate:Validates all installed models.' - ) - - _describe -t commands 'manage.py command' commands && ret=0 -} - -_applist() { - local line - local -a apps - _call_program help-command "python -c \"import sys; del sys.path[0];\\ - import os.path as op, re, django.conf;\\ - bn=op.basename(op.abspath(op.curdir));[sys\\ - .stdout.write(str(re.sub(r'^%s\.(.*?)$' % - bn, r'\1', i)) + '\n') for i in django.conf.settings.\\ - INSTALLED_APPS if re.match(r'^%s' % bn, i)]\"" \ - | while read -A line; do apps=($line $apps) done - _values 'Application' $apps && ret=0 -} - -_managepy() { - local curcontext=$curcontext ret=1 - - if ((CURRENT == 2)); then - _managepy-commands - else - shift words - (( CURRENT -- )) - curcontext="${curcontext%:*:*}:managepy-$words[1]:" - _call_function ret _managepy-$words[1] - fi -} - -compdef _managepy manage.py -compdef _managepy django -compdef _managepy django-admin -compdef _managepy django-admin.py -compdef _managepy django-manage - -print -P "%F{yellow}The django plugin is deprecated in favor of Zsh's Django completion. -%BPlease remove it from your plugins to stop using it.%b%f" diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 40ec5c46f..46cd4b10a 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -23,12 +23,12 @@ source_env() { touch "$ZSH_DOTENV_DISALLOWED_LIST" # early return if disallowed - if command grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then + if command grep -Fx -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then return fi # check if current directory's .env file is allowed or ask for confirmation - if ! command grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then + if ! command grep -Fx -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then # get cursor column and print new line before prompt if not at line beginning local column echo -ne "\e[6n" > /dev/tty @@ -52,7 +52,10 @@ source_env() { fi # test .env syntax - zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 + zsh -fn $ZSH_DOTENV_FILE || { + echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 + return 1 + } setopt localoptions allexport source $ZSH_DOTENV_FILE diff --git a/plugins/fd/README.md b/plugins/fd/README.md index cf9f7815d..f3341612f 100644 --- a/plugins/fd/README.md +++ b/plugins/fd/README.md @@ -7,7 +7,3 @@ To use it, add `fd` to the plugins array in your zshrc file: ```zsh plugins=(... fd) ``` - -Completion is taken from the fd release [`8.2.1`](https://github.com/sharkdp/fd/releases/tag/v8.2.1). - -Updated on April 1st, 2021. diff --git a/plugins/fd/_fd b/plugins/fd/_fd index f5d9e01d2..45b8ca477 100644 --- a/plugins/fd/_fd +++ b/plugins/fd/_fd @@ -1,4 +1,4 @@ -#compdef fd fdfind +#compdef fd ## # zsh completion function for fd @@ -57,6 +57,7 @@ _fd() { + no-ignore-partial # some ignore files "(no-ignore-full --no-ignore-vcs)--no-ignore-vcs[don't respect .gitignore files]" "!(no-ignore-full --no-global-ignore-file)--no-global-ignore-file[don't respect the global ignore file]" + $no'(no-ignore-full --no-ignore-parent)--no-ignore-parent[]' + '(case)' # case-sensitivity {-s,--case-sensitive}'[perform a case-sensitive search]' @@ -138,6 +139,7 @@ _fd() { + '(exec-cmds)' # execute command '(long-listing max-results)'{-x+,--exec=}'[execute command for each search result]:command: _command_names -e:*\;::program arguments: _normal' '(long-listing max-results)'{-X+,--exec-batch=}'[execute command for all search results at once]:command: _command_names -e:*\;::program arguments: _normal' + '(long-listing max-results)--batch-size=[max number of args for each -X call]:size' + other '!(--max-buffer-time)--max-buffer-time=[set amount of time to buffer before showing output]:time (ms)' @@ -153,6 +155,9 @@ _fd() { $no'(--base-directory)--base-directory=[change the current working directory to the given path]:directory:_files -/' $no'(*)*--search-path=[set search path (instead of positional <path> arguments)]:directory:_files -/' + + strip-cwd-prefix + $no'(strip-cwd-prefix exec-cmds)--strip-cwd-prefix[Strip ./ prefix when output is redirected]' + + args # positional arguments '1: :_guard "^-*" pattern' '(--search-path)*:directory:_files -/' @@ -220,7 +225,7 @@ _fd() { _fd "$@" # ------------------------------------------------------------------------------ -# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# Copyright (c) 2011 GitHub zsh-users - http://github.com/zsh-users # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/plugins/fig/README.md b/plugins/fig/README.md new file mode 100644 index 000000000..3861958d6 --- /dev/null +++ b/plugins/fig/README.md @@ -0,0 +1,9 @@ +# Fig plugin + +This plugin sets up completion for [Fig](https://fig.io/). + +To use it, add `fig` to the plugins array in your zshrc file: + +```zsh +plugins=(... fig) +``` diff --git a/plugins/fig/fig.plugin.zsh b/plugins/fig/fig.plugin.zsh new file mode 100644 index 000000000..cddb6c7c0 --- /dev/null +++ b/plugins/fig/fig.plugin.zsh @@ -0,0 +1,13 @@ +if ! (( $+commands[fig] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `fig`. Otherwise, compinit will have already done that +if [[ ! -f "$ZSH_CACHE_DIR/completions/_fig" ]]; then + autoload -Uz _fig + typeset -g -A _comps + _comps[fig]=_fig +fi + +fig completion zsh >| "$ZSH_CACHE_DIR/completions/_fig" &| diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh index e22588792..044e16a04 100644 --- a/plugins/fnm/fnm.plugin.zsh +++ b/plugins/fnm/fnm.plugin.zsh @@ -18,7 +18,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `fnm`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _fnm _comps[fnm]=_fnm fi diff --git a/plugins/fossil/fossil.plugin.zsh b/plugins/fossil/fossil.plugin.zsh index dfad73d36..a2123f415 100644 --- a/plugins/fossil/fossil.plugin.zsh +++ b/plugins/fossil/fossil.plugin.zsh @@ -13,23 +13,25 @@ ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖" ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔" function fossil_prompt_info() { - local _OUTPUT=`fossil branch 2>&1` - local _STATUS=`echo $_OUTPUT | grep "use --repo"` - if [ "$_STATUS" = "" ]; then - local _EDITED=`fossil changes` - local _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_CLEAN" - local _BRANCH=`echo $_OUTPUT | grep "* " | sed 's/* //g'` - - if [ "$_EDITED" != "" ]; then - _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_DIRTY" - fi + local info=$(fossil branch 2>&1) + + # if we're not in a fossil repo, don't show anything + ! command grep -q "use --repo" <<< "$info" || return - echo "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \ - "$_BRANCH" \ - "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \ - "$_EDITED_SYM"\ - "%{$reset_color%}" + local branch=$(echo $info | grep "* " | sed 's/* //g') + local changes=$(fossil changes) + local dirty="$ZSH_THEME_FOSSIL_PROMPT_CLEAN" + + if [[ -n "$changes" ]]; then + dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY" fi + + printf '%s %s %s %s %s' \ + "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \ + "${branch:gs/%/%%}" \ + "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \ + "$dirty" \ + "%{$reset_color%}" } function _fossil_prompt () { diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 437e477b9..7f8d5c90c 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -39,7 +39,7 @@ function frontend() { emulate -L zsh # define search context URLS - typeset -A urls + local -A urls urls=( angular 'https://angular.io/?search=' angularjs $(_frontend_fallback 'angularjs.org') @@ -73,25 +73,23 @@ function frontend() { ) # show help for command list - if [[ $# -lt 2 ]] - then - print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])" - print -P "" - print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website," - print -P "and %Ucontext%u is one of the following:" - print -P "" - print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia" - print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash," - print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" - print -P "" - print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." - print -P "" - return 1 + if [[ $# -lt 2 ]]; then + print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])" + print -P "" + print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website," + print -P "and %Ucontext%u is one of the following:" + print -P "" + print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia" + print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash," + print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" + print -P "" + print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." + print -P "" + return 1 fi # check whether the search context is supported - if [[ -z "$urls[$1]" ]] - then + if [[ -z "$urls[$1]" ]]; then echo "Search context \"$1\" currently not supported." echo "" echo "Valid contexts are:" diff --git a/plugins/gh/gh.plugin.zsh b/plugins/gh/gh.plugin.zsh index 17995e1cf..9263220ca 100644 --- a/plugins/gh/gh.plugin.zsh +++ b/plugins/gh/gh.plugin.zsh @@ -19,7 +19,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `gh`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _gh _comps[gh]=_gh fi diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 648fa0a33..8f7e623ec 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -24,9 +24,7 @@ compdef _git _git_log_prettily=git-log # Warn if the current branch is a WIP function work_in_progress() { - if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then - echo "WIP!!" - fi + command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!" } # Check if main exists and use instead of master diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git index 988f5b1c6..31bf88c1c 100644 --- a/plugins/gitfast/_git +++ b/plugins/gitfast/_git @@ -33,8 +33,9 @@ if [ -z "$script" ]; then bash_completion='/usr/share/bash-completion/completions/' locations=( - "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash + "${${funcsourcetrace[1]%:*}:A:h}"/git-completion.bash "$HOME/.local/share/bash-completion/completions/git" + '/usr/local/share/bash-completion/completions/git' "$bash_completion/git" '/etc/bash_completion.d/git' # old debian ) @@ -51,13 +52,20 @@ functions[complete]="$old_complete" __gitcompadd () { - compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0 + compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0 } __gitcomp () { emulate -L zsh + IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }" +} + +__gitcomp_opts () +{ + emulate -L zsh + local cur_="${3-$cur}" [[ "$cur_" == *= ]] && return @@ -70,7 +78,7 @@ __gitcomp () break fi - if [[ -z "${4-}" ]]; then + if [[ -z "${4+set}" ]]; then case $c in *=) c="${c%=}"; sfx="=" ;; *.) sfx="" ;; @@ -79,7 +87,7 @@ __gitcomp () else sfx="$4" fi - __gitcompadd "$c" "${2-}" "$sfx" -q + __gitcompadd "$c" "${2-}" "$sfx" done } @@ -87,7 +95,10 @@ __gitcomp_nl () { emulate -L zsh - IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }" + # words that don't end up in space + compadd -p "${2-}" -S "${4- }" -q -- ${${(f)1}:#*\ } && _ret=0 + # words that end in space + compadd -p "${2-}" -S " ${4- }" -q -- ${${(M)${(f)1}:#*\ }% } && _ret=0 } __gitcomp_file () @@ -107,21 +118,6 @@ __gitcomp_file_direct () __gitcomp_file "$1" "" } -__gitcomp_nl_append () -{ - __gitcomp_nl "$@" -} - -__gitcomp_direct_append () -{ - __gitcomp_direct "$@" -} - -_git_zsh () -{ - __gitcomp "v1.2" -} - __git_complete_command () { emulate -L zsh @@ -206,9 +202,7 @@ __git_zsh_main () { local curcontext="$curcontext" state state_descr line typeset -A opt_args - local -a orig_words __git_C_args - - orig_words=( ${words[@]} ) + local -a __git_C_args _arguments -C \ '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ @@ -245,7 +239,7 @@ __git_zsh_main () emulate ksh -c __git_complete_config_variable_name_and_value ;; (arg) - local command="${words[1]}" __git_dir + local command="${words[1]}" __git_dir __git_cmd_idx=1 if (( $+opt_args[--bare] )); then __git_dir='.' @@ -259,7 +253,7 @@ __git_zsh_main () (( $+opt_args[--help] )) && command='help' - words=( ${orig_words[@]} ) + words=( git ${words[@]} ) __git_zsh_bash_func $command ;; @@ -269,7 +263,7 @@ __git_zsh_main () _git () { local _ret=1 - local cur cword prev + local cur cword prev __git_cmd_idx=0 cur=${words[CURRENT]} prev=${words[CURRENT-1]} diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash index f7b09b2c1..2603ba7bb 100644 --- a/plugins/gitfast/git-completion.bash +++ b/plugins/gitfast/git-completion.bash @@ -29,6 +29,15 @@ # tell the completion to use commit completion. This also works with aliases # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". # +# If you have a command that is not part of git, but you would still +# like completion, you can use __git_complete: +# +# __git_complete gl git_log +# +# Or if it's a main command (i.e. git or gitk): +# +# __git_complete gk gitk +# # Compatible with bash 3.2.57. # # You can set the following environment variables to influence the behavior of @@ -45,6 +54,145 @@ # When set to "1" suggest all options, including options which are # typically hidden (e.g. '--allow-empty' for 'git commit'). +# The following functions are meant to modify COMPREPLY, which should not be +# modified directly. The purpose is to localize the modifications so it's +# easier to emulate it in Zsh. Every time a new __gitcomp* function is added, +# the corresponding function should be added to Zsh. + +__gitcompadd () +{ + local x i=${#COMPREPLY[@]} + for x in $1; do + if [[ "$x" == "$3"* ]]; then + COMPREPLY[i++]="$2$x$4" + fi + done +} + +# Creates completion replies. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp () +{ + local IFS=$' \t\n' + __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Generates completion reply from newline-separated possible completion words +# by appending a space to all of them. The result is appended to COMPREPLY. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words, separated by a single newline. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word instead of +# the default space (optional). If specified but empty, nothing is +# appended. +__gitcomp_nl () +{ + local IFS=$'\n' + __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Appends prefiltered words to COMPREPLY without any additional processing. +# Callers must take care of providing only words that match the current word +# to be completed and adding any prefix and/or suffix (trailing space!), if +# necessary. +# 1: List of newline-separated matching completion words, complete with +# prefix and suffix. +__gitcomp_direct () +{ + local IFS=$'\n' + + COMPREPLY+=($1) +} + +# Generates completion reply with compgen from newline-separated possible +# completion filenames. +# It accepts 1 to 3 arguments: +# 1: List of possible completion filenames, separated by a single newline. +# 2: A directory prefix to be added to each possible completion filename +# (optional). +# 3: Generate possible completion matches for this word (optional). +__gitcomp_file () +{ + local IFS=$'\n' + + # XXX does not work when the directory prefix contains a tilde, + # since tilde expansion is not applied. + # This means that COMPREPLY will be empty and Bash default + # completion will be used. + __gitcompadd "$1" "${2-}" "${3-$cur}" "" + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ >/dev/null || + true +} + +# Fills the COMPREPLY array with prefiltered paths without any additional +# processing. +# Callers must take care of providing only paths that match the current path +# to be completed and adding any prefix path components, if necessary. +# 1: List of newline-separated matching paths, complete with all prefix +# path components. +__gitcomp_file_direct () +{ + local IFS=$'\n' + + COMPREPLY+=($1) + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ >/dev/null || + true +} + +# Creates completion replies, reorganizing options and adding suffixes as needed. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp_opts () +{ + local cur_="${3-$cur}" + + if [[ "$cur_" == *= ]]; then + return + fi + + local c i=0 IFS=$' \t\n' sfx + for c in $1; do + if [[ $c == "--" ]]; then + if [[ "$cur_" == --no-* ]]; then + continue + fi + + if [[ --no == "$cur_"* ]]; then + COMPREPLY[i++]="--no-... " + fi + break + fi + if [[ $c == "$cur_"* ]]; then + if [[ -z "${4+set}" ]]; then + case $c in + *=|*.) sfx="" ;; + *) sfx=" " ;; + esac + else + sfx="$4" + fi + COMPREPLY[i++]="${2-}$c$sfx" + fi + done +} + +# __gitcomp functions end here +# ============================================================================== + # Discovers the path to the git repository taking any '--git-dir=<path>' and # '-C <path>' options into account and stores it in the $__git_repo_path # variable. @@ -63,7 +211,7 @@ __git_find_repo_path () test -d "$__git_dir" && __git_repo_path="$__git_dir" elif [ -n "${GIT_DIR-}" ]; then - test -d "${GIT_DIR-}" && + test -d "$GIT_DIR" && __git_repo_path="$GIT_DIR" elif [ -d .git ]; then __git_repo_path=.git @@ -159,230 +307,6 @@ __git_dequote () done } -# The following function is based on code from: -# -# bash_completion - programmable completion functions for bash 3.2+ -# -# Copyright © 2006-2008, Ian Macdonald <ian@caliban.org> -# © 2009-2010, Bash Completion Maintainers -# <bash-completion-devel@lists.alioth.debian.org> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see <http://www.gnu.org/licenses/>. -# -# The latest version of this software can be obtained here: -# -# http://bash-completion.alioth.debian.org/ -# -# RELEASE: 2.x - -# This function can be used to access a tokenized list of words -# on the command line: -# -# __git_reassemble_comp_words_by_ref '=:' -# if test "${words_[cword_-1]}" = -w -# then -# ... -# fi -# -# The argument should be a collection of characters from the list of -# word completion separators (COMP_WORDBREAKS) to treat as ordinary -# characters. -# -# This is roughly equivalent to going back in time and setting -# COMP_WORDBREAKS to exclude those characters. The intent is to -# make option types like --date=<type> and <rev>:<path> easy to -# recognize by treating each shell word as a single token. -# -# It is best not to set COMP_WORDBREAKS directly because the value is -# shared with other completion scripts. By the time the completion -# function gets called, COMP_WORDS has already been populated so local -# changes to COMP_WORDBREAKS have no effect. -# -# Output: words_, cword_, cur_. - -__git_reassemble_comp_words_by_ref() -{ - local exclude i j first - # Which word separators to exclude? - exclude="${1//[^$COMP_WORDBREAKS]}" - cword_=$COMP_CWORD - if [ -z "$exclude" ]; then - words_=("${COMP_WORDS[@]}") - return - fi - # List of word completion separators has shrunk; - # re-assemble words to complete. - for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do - # Append each nonempty word consisting of just - # word separator characters to the current word. - first=t - while - [ $i -gt 0 ] && - [ -n "${COMP_WORDS[$i]}" ] && - # word consists of excluded word separators - [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] - do - # Attach to the previous token, - # unless the previous token is the command name. - if [ $j -ge 2 ] && [ -n "$first" ]; then - ((j--)) - fi - first= - words_[$j]=${words_[j]}${COMP_WORDS[i]} - if [ $i = $COMP_CWORD ]; then - cword_=$j - fi - if (($i < ${#COMP_WORDS[@]} - 1)); then - ((i++)) - else - # Done. - return - fi - done - words_[$j]=${words_[j]}${COMP_WORDS[i]} - if [ $i = $COMP_CWORD ]; then - cword_=$j - fi - done -} - -if ! type _get_comp_words_by_ref >/dev/null 2>&1; then -_get_comp_words_by_ref () -{ - local exclude cur_ words_ cword_ - if [ "$1" = "-n" ]; then - exclude=$2 - shift 2 - fi - __git_reassemble_comp_words_by_ref "$exclude" - cur_=${words_[cword_]} - while [ $# -gt 0 ]; do - case "$1" in - cur) - cur=$cur_ - ;; - prev) - prev=${words_[$cword_-1]} - ;; - words) - words=("${words_[@]}") - ;; - cword) - cword=$cword_ - ;; - esac - shift - done -} -fi - -# Fills the COMPREPLY array with prefiltered words without any additional -# processing. -# Callers must take care of providing only words that match the current word -# to be completed and adding any prefix and/or suffix (trailing space!), if -# necessary. -# 1: List of newline-separated matching completion words, complete with -# prefix and suffix. -__gitcomp_direct () -{ - local IFS=$'\n' - - COMPREPLY=($1) -} - -# Similar to __gitcomp_direct, but appends to COMPREPLY instead. -# Callers must take care of providing only words that match the current word -# to be completed and adding any prefix and/or suffix (trailing space!), if -# necessary. -# 1: List of newline-separated matching completion words, complete with -# prefix and suffix. -__gitcomp_direct_append () -{ - local IFS=$'\n' - - COMPREPLY+=($1) -} - -__gitcompappend () -{ - local x i=${#COMPREPLY[@]} - for x in $1; do - if [[ "$x" == "$3"* ]]; then - COMPREPLY[i++]="$2$x$4" - fi - done -} - -__gitcompadd () -{ - COMPREPLY=() - __gitcompappend "$@" -} - -# Generates completion reply, appending a space to possible completion words, -# if necessary. -# It accepts 1 to 4 arguments: -# 1: List of possible completion words. -# 2: A prefix to be added to each possible completion word (optional). -# 3: Generate possible completion matches for this word (optional). -# 4: A suffix to be appended to each possible completion word (optional). -__gitcomp () -{ - local cur_="${3-$cur}" - - case "$cur_" in - *=) - ;; - --no-*) - local c i=0 IFS=$' \t\n' - for c in $1; do - if [[ $c == "--" ]]; then - continue - fi - c="$c${4-}" - if [[ $c == "$cur_"* ]]; then - case $c in - --*=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" - fi - done - ;; - *) - local c i=0 IFS=$' \t\n' - for c in $1; do - if [[ $c == "--" ]]; then - c="--no-...${4-}" - if [[ $c == "$cur_"* ]]; then - COMPREPLY[i++]="${2-}$c " - fi - break - fi - c="$c${4-}" - if [[ $c == "$cur_"* ]]; then - case $c in - *=|*.) ;; - *) c="$c " ;; - esac - COMPREPLY[i++]="${2-}$c" - fi - done - ;; - esac -} - # Clear the variables caching builtins' options when (re-)sourcing # the completion script. if [[ -n ${ZSH_VERSION-} ]]; then @@ -391,107 +315,108 @@ else unset $(compgen -v __gitcomp_builtin_) fi -__gitcomp_builtin_add_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul" -__gitcomp_builtin_am_default=" --interactive --3way --quiet --signoff --utf8 --keep --keep-non-patch --message-id --keep-cr --no-keep-cr --scissors --whitespace= --ignore-space-change --ignore-whitespace --directory= --exclude= --include= --patch-format= --reject --resolvemsg= --continue --resolved --skip --abort --quit --show-current-patch --committer-date-is-author-date --ignore-date --rerere-autoupdate --gpg-sign -- --no-interactive --no-3way --no-quiet --no-signoff --no-utf8 --no-keep --no-keep-non-patch --no-message-id --no-scissors --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-directory --no-exclude --no-include --no-patch-format --no-reject --no-resolvemsg --no-committer-date-is-author-date --no-ignore-date --no-rerere-autoupdate --no-gpg-sign" -__gitcomp_builtin_apply_default=" --exclude= --include= --no-add --stat --numstat --summary --check --index --intent-to-add --cached --apply --3way --build-fake-ancestor= --whitespace= --ignore-space-change --ignore-whitespace --reverse --unidiff-zero --reject --allow-overlap --verbose --inaccurate-eof --recount --directory= --add -- --no-stat --no-numstat --no-summary --no-check --no-index --no-intent-to-add --no-cached --no-apply --no-3way --no-build-fake-ancestor --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-reverse --no-unidiff-zero --no-reject --no-allow-overlap --no-verbose --no-inaccurate-eof --no-recount --no-directory" +__gitcomp_builtin_add_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --sparse --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-sparse --no-chmod --no-pathspec-from-file --no-pathspec-file-nul" +__gitcomp_builtin_am_default=" --interactive --3way --quiet --signoff --utf8 --keep --keep-non-patch --message-id --keep-cr --no-keep-cr --scissors --quoted-cr= --whitespace= --ignore-space-change --ignore-whitespace --directory= --exclude= --include= --patch-format= --reject --resolvemsg= --continue --resolved --skip --abort --quit --show-current-patch --allow-empty --committer-date-is-author-date --ignore-date --rerere-autoupdate --gpg-sign --empty= -- --no-interactive --no-3way --no-quiet --no-signoff --no-utf8 --no-keep --no-keep-non-patch --no-message-id --no-scissors --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-directory --no-exclude --no-include --no-patch-format --no-reject --no-resolvemsg --no-committer-date-is-author-date --no-ignore-date --no-rerere-autoupdate --no-gpg-sign" +__gitcomp_builtin_apply_default=" --exclude= --include= --no-add --stat --numstat --summary --check --index --intent-to-add --cached --apply --3way --build-fake-ancestor= --whitespace= --ignore-space-change --ignore-whitespace --reverse --unidiff-zero --reject --allow-overlap --verbose --quiet --inaccurate-eof --recount --directory= --allow-empty --add -- --no-stat --no-numstat --no-summary --no-check --no-index --no-intent-to-add --no-cached --no-apply --no-3way --no-build-fake-ancestor --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-reverse --no-unidiff-zero --no-reject --no-allow-overlap --no-verbose --no-quiet --no-inaccurate-eof --no-recount --no-directory --no-allow-empty" __gitcomp_builtin_archive_default=" --output= --remote= --exec= --no-output -- --no-remote --no-exec" -__gitcomp_builtin_bisect__helper_default=" --next-all --write-terms --bisect-clean-state --check-expected-revs --bisect-reset --bisect-write --check-and-set-terms --bisect-next-check --bisect-terms --bisect-start --bisect-next --bisect-auto-next --bisect-autostart --no-log --log" +__gitcomp_builtin_bisect__helper_default=" --bisect-reset --bisect-next-check --bisect-terms --bisect-start --bisect-next --bisect-state --bisect-log --bisect-replay --bisect-skip --bisect-visualize --bisect-run --no-log --log" __gitcomp_builtin_blame_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev" -__gitcomp_builtin_branch_default=" --verbose --quiet --track --set-upstream-to= --unset-upstream --color --remotes --contains --no-contains --abbrev --all --delete --move --copy --list --show-current --create-reflog --edit-description --merged --no-merged --column --sort= --points-at= --ignore-case --format= -- --no-verbose --no-quiet --no-track --no-set-upstream-to --no-unset-upstream --no-color --no-remotes --no-abbrev --no-all --no-delete --no-move --no-copy --no-list --no-show-current --no-create-reflog --no-edit-description --no-column --no-points-at --no-ignore-case --no-format" +__gitcomp_builtin_branch_default=" --verbose --quiet --track --set-upstream-to= --unset-upstream --color --remotes --contains --no-contains --abbrev --all --delete --move --copy --list --show-current --create-reflog --edit-description --merged --no-merged --column --sort= --points-at= --ignore-case --format= -- --no-verbose --no-quiet --no-track --no-set-upstream-to --no-unset-upstream --no-color --no-remotes --no-abbrev --no-all --no-delete --no-move --no-copy --no-list --no-show-current --no-create-reflog --no-edit-description --no-column --no-sort --no-points-at --no-ignore-case --no-format" __gitcomp_builtin_bugreport_default=" --output-directory= --suffix= --no-output-directory -- --no-suffix" __gitcomp_builtin_cat_file_default=" --textconv --filters --path= --allow-unknown-type --buffer --batch --batch-check --follow-symlinks --batch-all-objects --unordered --no-path -- --no-allow-unknown-type --no-buffer --no-follow-symlinks --no-batch-all-objects --no-unordered" __gitcomp_builtin_check_attr_default=" --all --cached --stdin --no-all -- --no-cached --no-stdin" __gitcomp_builtin_check_ignore_default=" --quiet --verbose --stdin --non-matching --no-index --index -- --no-quiet --no-verbose --no-stdin --no-non-matching" __gitcomp_builtin_check_mailmap_default=" --stdin --no-stdin" __gitcomp_builtin_checkout_default=" --guess --overlay --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-guess -- --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul" +__gitcomp_builtin_checkout__worker_default=" --prefix= --no-prefix" __gitcomp_builtin_checkout_index_default=" --all --force --quiet --no-create --index --stdin --temp --prefix= --stage= --create -- --no-all --no-force --no-quiet --no-index --no-stdin --no-temp --no-prefix" __gitcomp_builtin_cherry_default=" --abbrev --verbose --no-abbrev -- --no-verbose" __gitcomp_builtin_cherry_pick_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --ff --allow-empty --allow-empty-message --keep-redundant-commits --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign --no-ff --no-allow-empty --no-allow-empty-message --no-keep-redundant-commits" __gitcomp_builtin_clean_default=" --quiet --dry-run --interactive --exclude= --no-quiet -- --no-dry-run --no-interactive" -__gitcomp_builtin_clone_default=" --verbose --quiet --progress --no-checkout --bare --mirror --local --no-hardlinks --shared --recurse-submodules --recursive --jobs= --template= --reference= --reference-if-able= --dissociate --origin= --branch= --upload-pack= --depth= --shallow-since= --shallow-exclude= --single-branch --no-tags --shallow-submodules --separate-git-dir= --config= --server-option= --ipv4 --ipv6 --filter= --remote-submodules --sparse --checkout --hardlinks --tags -- --no-verbose --no-quiet --no-progress --no-bare --no-mirror --no-local --no-shared --no-recurse-submodules --no-recursive --no-jobs --no-template --no-reference --no-reference-if-able --no-dissociate --no-origin --no-branch --no-upload-pack --no-depth --no-shallow-since --no-shallow-exclude --no-single-branch --no-shallow-submodules --no-separate-git-dir --no-config --no-server-option --no-ipv4 --no-ipv6 --no-filter --no-remote-submodules --no-sparse" +__gitcomp_builtin_clone_default=" --verbose --quiet --progress --reject-shallow --no-checkout --bare --mirror --local --no-hardlinks --shared --recurse-submodules --jobs= --template= --reference= --reference-if-able= --dissociate --origin= --branch= --upload-pack= --depth= --shallow-since= --shallow-exclude= --single-branch --no-tags --shallow-submodules --separate-git-dir= --config= --server-option= --ipv4 --ipv6 --filter= --remote-submodules --sparse --checkout --hardlinks --tags -- --no-verbose --no-quiet --no-progress --no-reject-shallow --no-bare --no-mirror --no-local --no-shared --no-recurse-submodules --no-recursive --no-jobs --no-template --no-reference --no-reference-if-able --no-dissociate --no-origin --no-branch --no-upload-pack --no-depth --no-shallow-since --no-shallow-exclude --no-single-branch --no-shallow-submodules --no-separate-git-dir --no-config --no-server-option --no-ipv4 --no-ipv6 --no-filter --no-remote-submodules --no-sparse" __gitcomp_builtin_column_default=" --command= --mode --raw-mode= --width= --indent= --nl= --padding= --no-command -- --no-mode --no-raw-mode --no-width --no-indent --no-nl --no-padding" -__gitcomp_builtin_commit_default=" --quiet --verbose --file= --author= --date= --message= --reedit-message= --reuse-message= --fixup= --squash= --reset-author --signoff --template= --edit --cleanup= --status --gpg-sign --all --include --interactive --patch --only --no-verify --dry-run --short --branch --ahead-behind --porcelain --long --null --amend --no-post-rewrite --untracked-files --pathspec-from-file= --pathspec-file-nul --verify --post-rewrite -- --no-quiet --no-verbose --no-file --no-author --no-date --no-message --no-reedit-message --no-reuse-message --no-fixup --no-squash --no-reset-author --no-signoff --no-template --no-edit --no-cleanup --no-status --no-gpg-sign --no-all --no-include --no-interactive --no-patch --no-only --no-dry-run --no-short --no-branch --no-ahead-behind --no-porcelain --no-long --no-null --no-amend --no-untracked-files --no-pathspec-from-file --no-pathspec-file-nul" +__gitcomp_builtin_commit_default=" --quiet --verbose --file= --author= --date= --message= --reedit-message= --reuse-message= --fixup= --squash= --reset-author --trailer= --signoff --template= --edit --cleanup= --status --gpg-sign --all --include --interactive --patch --only --no-verify --dry-run --short --branch --ahead-behind --porcelain --long --null --amend --no-post-rewrite --untracked-files --pathspec-from-file= --pathspec-file-nul --verify --post-rewrite -- --no-quiet --no-verbose --no-file --no-author --no-date --no-message --no-reedit-message --no-reuse-message --no-fixup --no-squash --no-reset-author --no-signoff --no-template --no-edit --no-cleanup --no-status --no-gpg-sign --no-all --no-include --no-interactive --no-patch --no-only --no-dry-run --no-short --no-branch --no-ahead-behind --no-porcelain --no-long --no-null --no-amend --no-untracked-files --no-pathspec-from-file --no-pathspec-file-nul" __gitcomp_builtin_commit_graph_default=" --object-dir= --no-object-dir" -__gitcomp_builtin_config_default=" --global --system --local --worktree --file= --blob= --get --get-all --get-regexp --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section --list --edit --get-color --get-colorbool --type= --bool --int --bool-or-int --bool-or-str --path --expiry-date --null --name-only --includes --show-origin --show-scope --default= --no-global -- --no-system --no-local --no-worktree --no-file --no-blob --no-get --no-get-all --no-get-regexp --no-get-urlmatch --no-replace-all --no-add --no-unset --no-unset-all --no-rename-section --no-remove-section --no-list --no-edit --no-get-color --no-get-colorbool --no-type --no-null --no-name-only --no-includes --no-show-origin --no-show-scope --no-default" +__gitcomp_builtin_config_default=" --global --system --local --worktree --file= --blob= --get --get-all --get-regexp --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section --list --fixed-value --edit --get-color --get-colorbool --type= --bool --int --bool-or-int --bool-or-str --path --expiry-date --null --name-only --includes --show-origin --show-scope --default= --no-global -- --no-system --no-local --no-worktree --no-file --no-blob --no-get --no-get-all --no-get-regexp --no-get-urlmatch --no-replace-all --no-add --no-unset --no-unset-all --no-rename-section --no-remove-section --no-list --no-fixed-value --no-edit --no-get-color --no-get-colorbool --no-type --no-null --no-name-only --no-includes --no-show-origin --no-show-scope --no-default" __gitcomp_builtin_count_objects_default=" --verbose --human-readable --no-verbose -- --no-human-readable" __gitcomp_builtin_credential_cache_default=" --timeout= --socket= --no-timeout -- --no-socket" __gitcomp_builtin_credential_cache__daemon_default=" --debug --no-debug" __gitcomp_builtin_credential_store_default=" --file= --no-file" __gitcomp_builtin_describe_default=" --contains --debug --all --tags --long --first-parent --abbrev --exact-match --candidates= --match= --exclude= --always --dirty --broken --no-contains -- --no-debug --no-all --no-tags --no-long --no-first-parent --no-abbrev --no-exact-match --no-candidates --no-match --no-exclude --no-always --no-dirty --no-broken" -__gitcomp_builtin_difftool_default=" --gui --dir-diff --no-prompt --symlinks --tool= --tool-help --trust-exit-code --extcmd= --no-index -- --no-gui --no-dir-diff --no-symlinks --no-tool --no-tool-help --no-trust-exit-code --no-extcmd" +__gitcomp_builtin_difftool_default=" --gui --dir-diff --no-prompt --symlinks --tool= --tool-help --trust-exit-code --extcmd= --no-index --index -- --no-gui --no-dir-diff --no-symlinks --no-tool --no-tool-help --no-trust-exit-code --no-extcmd" __gitcomp_builtin_env__helper_default=" --type= --default= --exit-code --no-default -- --no-exit-code" __gitcomp_builtin_fast_export_default=" --progress= --signed-tags= --tag-of-filtered-object= --reencode= --export-marks= --import-marks= --import-marks-if-exists= --fake-missing-tagger --full-tree --use-done-feature --no-data --refspec= --anonymize --anonymize-map= --reference-excluded-parents --show-original-ids --mark-tags --data -- --no-progress --no-signed-tags --no-tag-of-filtered-object --no-reencode --no-export-marks --no-import-marks --no-import-marks-if-exists --no-fake-missing-tagger --no-full-tree --no-use-done-feature --no-refspec --no-anonymize --no-reference-excluded-parents --no-show-original-ids --no-mark-tags" -__gitcomp_builtin_fetch_default=" --verbose --quiet --all --set-upstream --append --upload-pack= --force --multiple --tags --jobs= --prune --prune-tags --recurse-submodules --dry-run --write-fetch-head --keep --update-head-ok --progress --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --filter= --auto-maintenance --auto-gc --show-forced-updates --write-commit-graph --stdin --no-verbose -- --no-quiet --no-all --no-set-upstream --no-append --no-upload-pack --no-force --no-multiple --no-tags --no-jobs --no-prune --no-prune-tags --no-recurse-submodules --no-dry-run --no-write-fetch-head --no-keep --no-update-head-ok --no-progress --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-filter --no-auto-maintenance --no-auto-gc --no-show-forced-updates --no-write-commit-graph --no-stdin" -__gitcomp_builtin_fmt_merge_msg_default=" --log --message= --file= --no-log -- --no-message --no-file" -__gitcomp_builtin_for_each_ref_default=" --shell --perl --python --tcl --count= --format= --color --sort= --points-at= --merged --no-merged --contains --no-contains --ignore-case -- --no-shell --no-perl --no-python --no-tcl --no-count --no-format --no-color --no-points-at --no-ignore-case" -__gitcomp_builtin_format_patch_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor" +__gitcomp_builtin_fetch_default=" --verbose --quiet --all --set-upstream --append --atomic --upload-pack= --force --multiple --tags --jobs= --prefetch --prune --prune-tags --recurse-submodules --dry-run --write-fetch-head --keep --update-head-ok --progress --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --negotiate-only --filter= --auto-maintenance --auto-gc --show-forced-updates --write-commit-graph --stdin --no-verbose -- --no-quiet --no-all --no-set-upstream --no-append --no-atomic --no-upload-pack --no-force --no-multiple --no-tags --no-jobs --no-prefetch --no-prune --no-prune-tags --no-recurse-submodules --no-dry-run --no-write-fetch-head --no-keep --no-update-head-ok --no-progress --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-negotiate-only --no-filter --no-auto-maintenance --no-auto-gc --no-show-forced-updates --no-write-commit-graph --no-stdin" +__gitcomp_builtin_fmt_merge_msg_default=" --log --message= --into-name= --file= --no-log -- --no-message --no-into-name --no-file" +__gitcomp_builtin_for_each_ref_default=" --shell --perl --python --tcl --count= --format= --color --sort= --points-at= --merged --no-merged --contains --no-contains --ignore-case -- --no-shell --no-perl --no-python --no-tcl --no-count --no-format --no-color --no-sort --no-points-at --no-ignore-case" +__gitcomp_builtin_for_each_repo_default=" --config= --no-config" +__gitcomp_builtin_format_patch_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --filename-max-length= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-filename-max-length --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor" __gitcomp_builtin_fsck_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects" __gitcomp_builtin_fsck_objects_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects" __gitcomp_builtin_gc_default=" --quiet --prune --aggressive --keep-largest-pack --no-quiet -- --no-prune --no-aggressive --no-keep-largest-pack" __gitcomp_builtin_grep_default=" --cached --no-index --untracked --exclude-standard --recurse-submodules --invert-match --ignore-case --word-regexp --text --textconv --recursive --max-depth= --extended-regexp --basic-regexp --fixed-strings --perl-regexp --line-number --column --full-name --files-with-matches --name-only --files-without-match --only-matching --count --color --break --heading --context= --before-context= --after-context= --threads= --show-function --function-context --and --or --not --quiet --all-match --index -- --no-cached --no-untracked --no-exclude-standard --no-recurse-submodules --no-invert-match --no-ignore-case --no-word-regexp --no-text --no-textconv --no-recursive --no-extended-regexp --no-basic-regexp --no-fixed-strings --no-perl-regexp --no-line-number --no-column --no-full-name --no-files-with-matches --no-name-only --no-files-without-match --no-only-matching --no-count --no-color --no-break --no-heading --no-context --no-before-context --no-after-context --no-threads --no-show-function --no-function-context --no-or --no-quiet --no-all-match" __gitcomp_builtin_hash_object_default=" --stdin --stdin-paths --no-filters --literally --path= --filters -- --no-stdin --no-stdin-paths --no-literally --no-path" -__gitcomp_builtin_help_default=" --all --guides --config --man --web --info --verbose --no-all -- --no-guides --no-config --no-man --no-web --no-info --no-verbose" +__gitcomp_builtin_help_default=" --all --man --web --info --verbose --guides --config --no-man -- --no-web --no-info --no-verbose" __gitcomp_builtin_init_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format" __gitcomp_builtin_init_db_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format" __gitcomp_builtin_interpret_trailers_default=" --in-place --trim-empty --where= --if-exists= --if-missing= --only-trailers --only-input --unfold --parse --no-divider --trailer= --divider -- --no-in-place --no-trim-empty --no-where --no-if-exists --no-if-missing --no-only-trailers --no-only-input --no-unfold --no-trailer" -__gitcomp_builtin_log_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate" -__gitcomp_builtin_ls_files_default=" --cached --deleted --modified --others --ignored --stage --killed --directory --eol --empty-directory --unmerged --resolve-undo --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --full-name --recurse-submodules --error-unmatch --with-tree= --abbrev --debug --no-cached -- --no-deleted --no-modified --no-others --no-ignored --no-stage --no-killed --no-directory --no-eol --no-empty-directory --no-unmerged --no-resolve-undo --no-exclude-per-directory --no-recurse-submodules --no-error-unmatch --no-with-tree --no-abbrev --no-debug" -__gitcomp_builtin_ls_remote_default=" --quiet --upload-pack= --tags --heads --refs --get-url --sort= --symref --server-option= --no-quiet -- --no-upload-pack --no-tags --no-heads --no-refs --no-get-url --no-symref --no-server-option" +__gitcomp_builtin_log_default=" --quiet --source --use-mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate" +__gitcomp_builtin_ls_files_default=" --cached --deleted --modified --others --ignored --stage --killed --directory --eol --empty-directory --unmerged --resolve-undo --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --full-name --recurse-submodules --error-unmatch --with-tree= --abbrev --debug --deduplicate --sparse --no-cached -- --no-deleted --no-modified --no-others --no-ignored --no-stage --no-killed --no-directory --no-eol --no-empty-directory --no-unmerged --no-resolve-undo --no-exclude-per-directory --no-recurse-submodules --no-error-unmatch --no-with-tree --no-abbrev --no-debug --no-deduplicate --no-sparse" +__gitcomp_builtin_ls_remote_default=" --quiet --upload-pack= --tags --heads --refs --get-url --sort= --symref --server-option= --no-quiet -- --no-upload-pack --no-tags --no-heads --no-refs --no-get-url --no-sort --no-symref --no-server-option" __gitcomp_builtin_ls_tree_default=" --long --name-only --name-status --full-name --full-tree --abbrev --no-long -- --no-name-only --no-name-status --no-full-name --no-full-tree --no-abbrev" -__gitcomp_builtin_merge_default=" --stat --summary --log --squash --commit --edit --cleanup= --ff --ff-only --rerere-autoupdate --verify-signatures --strategy= --strategy-option= --message= --file --verbose --quiet --abort --quit --continue --allow-unrelated-histories --progress --gpg-sign --autostash --overwrite-ignore --signoff --no-verify --verify -- --no-stat --no-summary --no-log --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-rerere-autoupdate --no-verify-signatures --no-strategy --no-strategy-option --no-message --no-verbose --no-quiet --no-abort --no-quit --no-continue --no-allow-unrelated-histories --no-progress --no-gpg-sign --no-autostash --no-overwrite-ignore --no-signoff" +__gitcomp_builtin_merge_default=" --stat --summary --log --squash --commit --edit --cleanup= --ff --ff-only --rerere-autoupdate --verify-signatures --strategy= --strategy-option= --message= --file --into-name= --verbose --quiet --abort --quit --continue --allow-unrelated-histories --progress --gpg-sign --autostash --overwrite-ignore --signoff --no-verify --verify -- --no-stat --no-summary --no-log --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-rerere-autoupdate --no-verify-signatures --no-strategy --no-strategy-option --no-message --no-into-name --no-verbose --no-quiet --no-abort --no-quit --no-continue --no-allow-unrelated-histories --no-progress --no-gpg-sign --no-autostash --no-overwrite-ignore --no-signoff" __gitcomp_builtin_merge_base_default=" --all --octopus --independent --is-ancestor --fork-point --no-all" -__gitcomp_builtin_merge_file_default=" --stdout --diff3 --ours --theirs --union --marker-size= --quiet --no-stdout -- --no-diff3 --no-ours --no-theirs --no-union --no-marker-size --no-quiet" +__gitcomp_builtin_merge_file_default=" --stdout --diff3 --zdiff3 --ours --theirs --union --marker-size= --quiet --no-stdout -- --no-diff3 --no-zdiff3 --no-ours --no-theirs --no-union --no-marker-size --no-quiet" __gitcomp_builtin_mktree_default=" --missing --batch --no-missing -- --no-batch" -__gitcomp_builtin_multi_pack_index_default=" --object-dir= --progress --batch-size= --no-object-dir -- --no-progress" -__gitcomp_builtin_mv_default=" --verbose --dry-run --no-verbose -- --no-dry-run" +__gitcomp_builtin_multi_pack_index_default=" --object-dir= --no-object-dir" +__gitcomp_builtin_mv_default=" --verbose --dry-run --sparse --no-verbose -- --no-dry-run --no-sparse" __gitcomp_builtin_name_rev_default=" --name-only --tags --refs= --exclude= --all --stdin --undefined --always --no-name-only -- --no-tags --no-refs --no-exclude --no-all --no-stdin --no-undefined --no-always" __gitcomp_builtin_notes_default=" --ref= --no-ref" -__gitcomp_builtin_pack_objects_default=" --quiet --progress --all-progress --all-progress-implied --index-version= --max-pack-size= --local --incremental --window= --window-memory= --depth= --reuse-delta --reuse-object --delta-base-offset --threads= --non-empty --revs --unpacked --all --reflog --indexed-objects --stdout --include-tag --keep-unreachable --pack-loose-unreachable --unpack-unreachable --sparse --thin --shallow --honor-pack-keep --keep-pack= --compression= --keep-true-parents --use-bitmap-index --write-bitmap-index --filter= --missing= --exclude-promisor-objects --delta-islands --uri-protocol= --no-quiet -- --no-progress --no-all-progress --no-all-progress-implied --no-local --no-incremental --no-window --no-depth --no-reuse-delta --no-reuse-object --no-delta-base-offset --no-threads --no-non-empty --no-revs --no-stdout --no-include-tag --no-keep-unreachable --no-pack-loose-unreachable --no-unpack-unreachable --no-sparse --no-thin --no-shallow --no-honor-pack-keep --no-keep-pack --no-compression --no-keep-true-parents --no-use-bitmap-index --no-write-bitmap-index --no-filter --no-exclude-promisor-objects --no-delta-islands --no-uri-protocol" +__gitcomp_builtin_pack_objects_default=" --quiet --progress --all-progress --all-progress-implied --index-version= --max-pack-size= --local --incremental --window= --window-memory= --depth= --reuse-delta --reuse-object --delta-base-offset --threads= --non-empty --revs --unpacked --all --reflog --indexed-objects --stdin-packs --stdout --include-tag --keep-unreachable --pack-loose-unreachable --unpack-unreachable --sparse --thin --shallow --honor-pack-keep --keep-pack= --compression= --keep-true-parents --use-bitmap-index --write-bitmap-index --filter= --missing= --exclude-promisor-objects --delta-islands --uri-protocol= --no-quiet -- --no-progress --no-all-progress --no-all-progress-implied --no-local --no-incremental --no-window --no-depth --no-reuse-delta --no-reuse-object --no-delta-base-offset --no-threads --no-non-empty --no-revs --no-stdin-packs --no-stdout --no-include-tag --no-keep-unreachable --no-pack-loose-unreachable --no-unpack-unreachable --no-sparse --no-thin --no-shallow --no-honor-pack-keep --no-keep-pack --no-compression --no-keep-true-parents --no-use-bitmap-index --no-write-bitmap-index --no-filter --no-exclude-promisor-objects --no-delta-islands --no-uri-protocol" __gitcomp_builtin_pack_refs_default=" --all --prune --no-all -- --no-prune" __gitcomp_builtin_pickaxe_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev" __gitcomp_builtin_prune_default=" --dry-run --verbose --progress --expire= --exclude-promisor-objects --no-dry-run -- --no-verbose --no-progress --no-expire --no-exclude-promisor-objects" __gitcomp_builtin_prune_packed_default=" --dry-run --quiet --no-dry-run -- --no-quiet" -__gitcomp_builtin_pull_default=" --verbose --quiet --progress --recurse-submodules --rebase --stat --log --signoff --squash --commit --edit --cleanup= --ff --ff-only --verify-signatures --autostash --strategy= --strategy-option= --gpg-sign --allow-unrelated-histories --all --append --upload-pack= --force --tags --prune --jobs --dry-run --keep --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --show-forced-updates --set-upstream --no-verbose -- --no-quiet --no-progress --no-recurse-submodules --no-rebase --no-stat --no-log --no-signoff --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-verify-signatures --no-autostash --no-strategy --no-strategy-option --no-gpg-sign --no-allow-unrelated-histories --no-all --no-append --no-upload-pack --no-force --no-tags --no-prune --no-jobs --no-dry-run --no-keep --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-show-forced-updates --no-set-upstream" -__gitcomp_builtin_push_default=" --verbose --quiet --repo= --all --mirror --delete --tags --dry-run --porcelain --force --force-with-lease --recurse-submodules= --receive-pack= --exec= --set-upstream --progress --prune --no-verify --follow-tags --signed --atomic --push-option= --ipv4 --ipv6 --verify -- --no-verbose --no-quiet --no-repo --no-all --no-mirror --no-delete --no-tags --no-dry-run --no-porcelain --no-force --no-force-with-lease --no-recurse-submodules --no-receive-pack --no-exec --no-set-upstream --no-progress --no-prune --no-follow-tags --no-signed --no-atomic --no-push-option --no-ipv4 --no-ipv6" -__gitcomp_builtin_range_diff_default=" --creation-factor= --no-dual-color --notes --patch --no-patch --unified --function-context --raw --patch-with-raw --patch-with-stat --numstat --shortstat --dirstat --cumulative --dirstat-by-file --check --summary --name-only --name-status --stat --stat-width= --stat-name-width= --stat-graph-width= --stat-count= --compact-summary --binary --full-index --color --ws-error-highlight= --abbrev --src-prefix= --dst-prefix= --line-prefix= --no-prefix --inter-hunk-context= --output-indicator-new= --output-indicator-old= --output-indicator-context= --break-rewrites --find-renames --irreversible-delete --find-copies --find-copies-harder --no-renames --rename-empty --follow --minimal --ignore-all-space --ignore-space-change --ignore-space-at-eol --ignore-cr-at-eol --ignore-blank-lines --indent-heuristic --patience --histogram --diff-algorithm= --anchored= --word-diff --word-diff-regex= --color-words --color-moved --color-moved-ws= --relative --text --exit-code --quiet --ext-diff --textconv --ignore-submodules --submodule --ita-invisible-in-index --ita-visible-in-index --pickaxe-all --pickaxe-regex --find-object= --diff-filter= --output= --dual-color -- --no-creation-factor --no-notes --no-function-context --no-compact-summary --no-full-index --no-color --no-abbrev --no-find-copies-harder --no-rename-empty --no-follow --no-minimal --no-indent-heuristic --no-color-moved --no-color-moved-ws --no-relative --no-text --no-exit-code --no-quiet --no-ext-diff --no-textconv" +__gitcomp_builtin_pull_default=" --verbose --quiet --progress --recurse-submodules --rebase --stat --log --signoff --squash --commit --edit --cleanup= --ff --ff-only --verify --verify-signatures --autostash --strategy= --strategy-option= --gpg-sign --allow-unrelated-histories --all --append --upload-pack= --force --tags --prune --jobs --dry-run --keep --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --show-forced-updates --set-upstream --no-verbose -- --no-quiet --no-progress --no-recurse-submodules --no-rebase --no-stat --no-log --no-signoff --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-verify --no-verify-signatures --no-autostash --no-strategy --no-strategy-option --no-gpg-sign --no-allow-unrelated-histories --no-all --no-append --no-upload-pack --no-force --no-tags --no-prune --no-jobs --no-dry-run --no-keep --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-show-forced-updates --no-set-upstream" +__gitcomp_builtin_push_default=" --verbose --quiet --repo= --all --mirror --delete --tags --dry-run --porcelain --force --force-with-lease --force-if-includes --recurse-submodules= --receive-pack= --exec= --set-upstream --progress --prune --no-verify --follow-tags --signed --atomic --push-option= --ipv4 --ipv6 --verify -- --no-verbose --no-quiet --no-repo --no-all --no-mirror --no-delete --no-tags --no-dry-run --no-porcelain --no-force --no-force-with-lease --no-force-if-includes --no-recurse-submodules --no-receive-pack --no-exec --no-set-upstream --no-progress --no-prune --no-follow-tags --no-signed --no-atomic --no-push-option --no-ipv4 --no-ipv6" +__gitcomp_builtin_range_diff_default=" --creation-factor= --no-dual-color --notes --left-only --right-only --patch --no-patch --unified --function-context --raw --patch-with-raw --patch-with-stat --numstat --shortstat --dirstat --cumulative --dirstat-by-file --check --summary --name-only --name-status --stat --stat-width= --stat-name-width= --stat-graph-width= --stat-count= --compact-summary --binary --full-index --color --ws-error-highlight= --abbrev --src-prefix= --dst-prefix= --line-prefix= --no-prefix --inter-hunk-context= --output-indicator-new= --output-indicator-old= --output-indicator-context= --break-rewrites --find-renames --irreversible-delete --find-copies --find-copies-harder --no-renames --rename-empty --follow --minimal --ignore-all-space --ignore-space-change --ignore-space-at-eol --ignore-cr-at-eol --ignore-blank-lines --ignore-matching-lines= --indent-heuristic --patience --histogram --diff-algorithm= --anchored= --word-diff --word-diff-regex= --color-words --color-moved --color-moved-ws= --relative --text --exit-code --quiet --ext-diff --textconv --ignore-submodules --submodule --ita-invisible-in-index --ita-visible-in-index --pickaxe-all --pickaxe-regex --rotate-to= --skip-to= --find-object= --diff-filter= --output= --dual-color -- --no-creation-factor --no-notes --no-left-only --no-right-only --no-function-context --no-compact-summary --no-full-index --no-color --no-abbrev --no-find-copies-harder --no-rename-empty --no-follow --no-minimal --no-ignore-matching-lines --no-indent-heuristic --no-color-moved --no-color-moved-ws --no-relative --no-text --no-exit-code --no-quiet --no-ext-diff --no-textconv" __gitcomp_builtin_read_tree_default=" --index-output= --empty --verbose --trivial --aggressive --reset --prefix= --exclude-per-directory= --dry-run --no-sparse-checkout --debug-unpack --recurse-submodules --quiet --sparse-checkout -- --no-empty --no-verbose --no-trivial --no-aggressive --no-reset --no-dry-run --no-debug-unpack --no-recurse-submodules --no-quiet" __gitcomp_builtin_rebase_default=" --onto= --keep-base --no-verify --quiet --verbose --no-stat --signoff --committer-date-is-author-date --reset-author-date --ignore-whitespace --whitespace= --force-rebase --no-ff --continue --skip --abort --quit --edit-todo --show-current-patch --apply --merge --interactive --rerere-autoupdate --empty= --autosquash --gpg-sign --autostash --exec= --rebase-merges --fork-point --strategy= --strategy-option= --root --reschedule-failed-exec --reapply-cherry-picks --verify --stat --ff -- --no-onto --no-keep-base --no-quiet --no-verbose --no-signoff --no-committer-date-is-author-date --no-reset-author-date --no-ignore-whitespace --no-whitespace --no-force-rebase --no-rerere-autoupdate --no-autosquash --no-gpg-sign --no-autostash --no-exec --no-rebase-merges --no-fork-point --no-strategy --no-strategy-option --no-root --no-reschedule-failed-exec --no-reapply-cherry-picks" -__gitcomp_builtin_rebase__interactive_default=" --ff --rebase-merges --rebase-cousins --autosquash --signoff --verbose --continue --skip --edit-todo --show-current-patch --shorten-ids --expand-ids --check-todo-list --rearrange-squash --add-exec-commands --onto= --restrict-revision= --squash-onto= --upstream= --head-name= --gpg-sign --strategy= --strategy-opts= --switch-to= --onto-name= --cmd= --rerere-autoupdate --reschedule-failed-exec --no-ff -- --no-rebase-merges --no-rebase-cousins --no-autosquash --no-signoff --no-verbose --no-head-name --no-gpg-sign --no-strategy --no-strategy-opts --no-switch-to --no-onto-name --no-cmd --no-rerere-autoupdate --no-reschedule-failed-exec" __gitcomp_builtin_receive_pack_default=" --quiet --no-quiet" -__gitcomp_builtin_reflog_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate" +__gitcomp_builtin_reflog_default=" --quiet --source --use-mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate" __gitcomp_builtin_remote_default=" --verbose --no-verbose" -__gitcomp_builtin_repack_default=" --quiet --local --write-bitmap-index --delta-islands --unpack-unreachable= --keep-unreachable --window= --window-memory= --depth= --threads= --max-pack-size= --pack-kept-objects --keep-pack= --no-quiet -- --no-local --no-write-bitmap-index --no-delta-islands --no-unpack-unreachable --no-keep-unreachable --no-window --no-window-memory --no-depth --no-threads --no-max-pack-size --no-pack-kept-objects --no-keep-pack" +__gitcomp_builtin_repack_default=" --quiet --local --write-bitmap-index --delta-islands --unpack-unreachable= --keep-unreachable --window= --window-memory= --depth= --threads= --max-pack-size= --pack-kept-objects --keep-pack= --geometric= --write-midx --no-quiet -- --no-local --no-write-bitmap-index --no-delta-islands --no-unpack-unreachable --no-keep-unreachable --no-window --no-window-memory --no-depth --no-threads --no-max-pack-size --no-pack-kept-objects --no-keep-pack --no-geometric --no-write-midx" __gitcomp_builtin_replace_default=" --list --delete --edit --graft --convert-graft-file --raw --format= --no-raw -- --no-format" __gitcomp_builtin_rerere_default=" --rerere-autoupdate --no-rerere-autoupdate" __gitcomp_builtin_reset_default=" --quiet --mixed --soft --hard --merge --keep --recurse-submodules --patch --intent-to-add --pathspec-from-file= --pathspec-file-nul --no-quiet -- --no-mixed --no-soft --no-hard --no-merge --no-keep --no-recurse-submodules --no-patch --no-intent-to-add --no-pathspec-from-file --no-pathspec-file-nul" __gitcomp_builtin_restore_default=" --source= --staged --worktree --ignore-unmerged --overlay --quiet --recurse-submodules --progress --merge --conflict= --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-source -- --no-staged --no-worktree --no-ignore-unmerged --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul" __gitcomp_builtin_revert_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign" -__gitcomp_builtin_rm_default=" --dry-run --quiet --cached --ignore-unmatch --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-quiet --no-cached --no-ignore-unmatch --no-pathspec-from-file --no-pathspec-file-nul" -__gitcomp_builtin_send_pack_default=" --verbose --quiet --receive-pack= --exec= --remote= --all --dry-run --mirror --force --signed --push-option= --progress --thin --atomic --stateless-rpc --stdin --helper-status --force-with-lease --no-verbose -- --no-quiet --no-receive-pack --no-exec --no-remote --no-all --no-dry-run --no-mirror --no-force --no-signed --no-push-option --no-progress --no-thin --no-atomic --no-stateless-rpc --no-stdin --no-helper-status --no-force-with-lease" +__gitcomp_builtin_rm_default=" --dry-run --quiet --cached --ignore-unmatch --sparse --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-quiet --no-cached --no-ignore-unmatch --no-sparse --no-pathspec-from-file --no-pathspec-file-nul" +__gitcomp_builtin_send_pack_default=" --verbose --quiet --receive-pack= --exec= --remote= --all --dry-run --mirror --force --signed --push-option= --progress --thin --atomic --stateless-rpc --stdin --helper-status --force-with-lease --force-if-includes --no-verbose -- --no-quiet --no-receive-pack --no-exec --no-remote --no-all --no-dry-run --no-mirror --no-force --no-signed --no-push-option --no-progress --no-thin --no-atomic --no-stateless-rpc --no-stdin --no-helper-status --no-force-with-lease --no-force-if-includes" __gitcomp_builtin_shortlog_default=" --committer --numbered --summary --email --group= --no-committer -- --no-numbered --no-summary --no-email --no-group" -__gitcomp_builtin_show_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate" +__gitcomp_builtin_show_default=" --quiet --source --use-mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate" __gitcomp_builtin_show_branch_default=" --all --remotes --color --more --list --no-name --current --sha1-name --merge-base --independent --topo-order --topics --sparse --date-order --reflog --name -- --no-all --no-remotes --no-color --no-more --no-list --no-current --no-sha1-name --no-merge-base --no-independent --no-topo-order --no-topics --no-sparse --no-date-order" __gitcomp_builtin_show_index_default=" --object-format= --no-object-format" __gitcomp_builtin_show_ref_default=" --tags --heads --verify --head --dereference --hash --abbrev --quiet --exclude-existing --no-tags -- --no-heads --no-verify --no-head --no-dereference --no-hash --no-abbrev --no-quiet" __gitcomp_builtin_sparse_checkout_default="" -__gitcomp_builtin_stage_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul" +__gitcomp_builtin_stage_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --sparse --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-sparse --no-chmod --no-pathspec-from-file --no-pathspec-file-nul" __gitcomp_builtin_stash_default="" __gitcomp_builtin_status_default=" --verbose --short --branch --show-stash --ahead-behind --porcelain --long --null --untracked-files --ignored --ignore-submodules --column --no-renames --find-renames --renames -- --no-verbose --no-short --no-branch --no-show-stash --no-ahead-behind --no-porcelain --no-long --no-null --no-untracked-files --no-ignored --no-ignore-submodules --no-column" __gitcomp_builtin_stripspace_default=" --strip-comments --comment-lines" __gitcomp_builtin_switch_default=" --create= --force-create= --guess --discard-changes --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --no-create -- --no-force-create --no-guess --no-discard-changes --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees" __gitcomp_builtin_symbolic_ref_default=" --quiet --delete --short --no-quiet -- --no-delete --no-short" -__gitcomp_builtin_tag_default=" --list --delete --verify --annotate --message= --file= --edit --sign --cleanup= --local-user= --force --create-reflog --column --contains --no-contains --merged --no-merged --sort= --points-at --format= --color --ignore-case -- --no-annotate --no-file --no-edit --no-sign --no-cleanup --no-local-user --no-force --no-create-reflog --no-column --no-points-at --no-format --no-color --no-ignore-case" +__gitcomp_builtin_tag_default=" --list --delete --verify --annotate --message= --file= --edit --sign --cleanup= --local-user= --force --create-reflog --column --contains --no-contains --merged --no-merged --sort= --points-at --format= --color --ignore-case -- --no-annotate --no-file --no-edit --no-sign --no-cleanup --no-local-user --no-force --no-create-reflog --no-column --no-sort --no-points-at --no-format --no-color --no-ignore-case" __gitcomp_builtin_update_index_default=" --ignore-submodules --add --replace --remove --unmerged --refresh --really-refresh --cacheinfo --chmod= --assume-unchanged --no-assume-unchanged --skip-worktree --no-skip-worktree --ignore-skip-worktree-entries --info-only --force-remove --stdin --index-info --unresolve --again --ignore-missing --verbose --clear-resolve-undo --index-version= --split-index --untracked-cache --test-untracked-cache --force-untracked-cache --force-write-index --fsmonitor --fsmonitor-valid --no-fsmonitor-valid -- --no-ignore-submodules --no-add --no-replace --no-remove --no-unmerged --no-ignore-skip-worktree-entries --no-info-only --no-force-remove --no-ignore-missing --no-verbose --no-index-version --no-split-index --no-untracked-cache --no-test-untracked-cache --no-force-untracked-cache --no-force-write-index --no-fsmonitor" __gitcomp_builtin_update_ref_default=" --no-deref --stdin --create-reflog --deref -- --no-stdin --no-create-reflog" __gitcomp_builtin_update_server_info_default=" --force --no-force" -__gitcomp_builtin_upload_pack_default=" --stateless-rpc --advertise-refs --strict --timeout= --no-stateless-rpc -- --no-advertise-refs --no-strict --no-timeout" +__gitcomp_builtin_upload_pack_default=" --stateless-rpc --strict --timeout= --no-stateless-rpc -- --no-strict --no-timeout" __gitcomp_builtin_verify_commit_default=" --verbose --raw --no-verbose -- --no-raw" __gitcomp_builtin_verify_pack_default=" --verbose --stat-only --object-format= --no-verbose -- --no-stat-only --no-object-format" __gitcomp_builtin_verify_tag_default=" --verbose --raw --format= --no-verbose -- --no-raw --no-format" __gitcomp_builtin_version_default=" --build-options --no-build-options" -__gitcomp_builtin_whatchanged_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate" +__gitcomp_builtin_whatchanged_default=" --quiet --source --use-mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate" __gitcomp_builtin_write_tree_default=" --missing-ok --prefix= --no-missing-ok -- --no-prefix" -__gitcomp_builtin_send_email_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor" +__gitcomp_builtin_send_email_default="--cc= --smtp-server= --identity= --smtp-ssl --sender= --from= --cc-cover --no-to-cover --sendmail-cmd= --signed-off-cc --signed-off-by-cc --in-reply-to= --no-cc --confirm= --no-bcc --to= --annotate --smtp-encryption= --relogin-delay= --to-cmd= --smtp-domain= --smtp-auth= --bcc= --quiet --subject= --chain-reply-to --cc-cmd= --no-format-patch --transfer-encoding= --smtp-user= --reply-to= --force --dry-run --no-identity --no-validate --8bit-encoding= --to-cover --compose --thread --format-patch --no-thread --smtp-server-option= --compose-encoding= --smtp-server-port= --no-smtp-auth --no-signed-off-cc --no-signed-off-by-cc --smtp-debug= --no-suppress-from --suppress-from --no-to --dump-aliases --xmailer --no-annotate --no-cc-cover --smtp-pass= --smtp-ssl-cert-path= --no-chain-reply-to --suppress-cc= --validate --batch-size= --envelope-sender= --no-xmailer --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --filename-max-length= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --from --attach --inline --signature= --base= --signature-file= --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-filename-max-length --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-from --no-in-reply-to --no-attach --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor" __gitcomp_builtin_get_default () { @@ -500,7 +425,7 @@ __gitcomp_builtin_get_default () # This function is equivalent to # -# __gitcomp "$(git xxx --git-completion-helper) ..." +# __gitcomp_opts "$(git xxx --git-completion-helper) ..." # # except that the output is cached. Accept 1-3 arguments: # 1: the git command to execute, this is also the cache key @@ -520,7 +445,7 @@ __gitcomp_builtin () if [ -z "$options" ]; then local completion_helper - if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then + if [ "${GIT_COMPLETION_SHOW_ALL-}" = "1" ]; then completion_helper="--git-completion-helper-all" else completion_helper="--git-completion-helper" @@ -537,71 +462,7 @@ __gitcomp_builtin () eval "$var=\"$options\"" fi - __gitcomp "$options" -} - -# Variation of __gitcomp_nl () that appends to the existing list of -# completion candidates, COMPREPLY. -__gitcomp_nl_append () -{ - local IFS=$'\n' - __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" -} - -# Generates completion reply from newline-separated possible completion words -# by appending a space to all of them. -# It accepts 1 to 4 arguments: -# 1: List of possible completion words, separated by a single newline. -# 2: A prefix to be added to each possible completion word (optional). -# 3: Generate possible completion matches for this word (optional). -# 4: A suffix to be appended to each possible completion word instead of -# the default space (optional). If specified but empty, nothing is -# appended. -__gitcomp_nl () -{ - COMPREPLY=() - __gitcomp_nl_append "$@" -} - -# Fills the COMPREPLY array with prefiltered paths without any additional -# processing. -# Callers must take care of providing only paths that match the current path -# to be completed and adding any prefix path components, if necessary. -# 1: List of newline-separated matching paths, complete with all prefix -# path components. -__gitcomp_file_direct () -{ - local IFS=$'\n' - - COMPREPLY=($1) - - # use a hack to enable file mode in bash < 4 - compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true -} - -# Generates completion reply with compgen from newline-separated possible -# completion filenames. -# It accepts 1 to 3 arguments: -# 1: List of possible completion filenames, separated by a single newline. -# 2: A directory prefix to be added to each possible completion filename -# (optional). -# 3: Generate possible completion matches for this word (optional). -__gitcomp_file () -{ - local IFS=$'\n' - - # XXX does not work when the directory prefix contains a tilde, - # since tilde expansion is not applied. - # This means that COMPREPLY will be empty and Bash default - # completion will be used. - __gitcompadd "$1" "${2-}" "${3-$cur}" "" - - # use a hack to enable file mode in bash < 4 - compopt -o filenames +o nospace 2>/dev/null || - compgen -f /non-existing-dir/ >/dev/null || - true + __gitcomp_opts "$options" } # Execute 'git ls-files', unless the --committable option is specified, in @@ -610,7 +471,7 @@ __gitcomp_file () # argument, and using the options specified in the second argument. __git_ls_files_helper () { - if [ "$2" == "--committable" ]; then + if [ "$2" = "--committable" ]; then __git -C "$1" -c core.quotePath=false diff-index \ --name-only --relative HEAD -- "${3//\\/\\\\}*" else @@ -839,7 +700,7 @@ __git_refs () track="" ;; *) - for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD; do case "$i" in $match*) if [ -e "$dir/$i" ]; then @@ -947,7 +808,7 @@ __git_complete_refs () # Append DWIM remote branch names if requested if [ "$dwim" = "yes" ]; then - __gitcomp_direct_append "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")" + __gitcomp_direct "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")" fi } @@ -1103,8 +964,8 @@ __git_complete_revlist () __git_complete_remote_or_refspec () { - local cur_="$cur" cmd="${words[1]}" - local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0 + local cur_="$cur" cmd="${words[__git_cmd_idx]}" + local i c=$((__git_cmd_idx+1)) remote="" pfx="" lhs=1 no_complete_refspec=0 if [ "$cmd" = "remote" ]; then ((c++)) fi @@ -1184,7 +1045,7 @@ __git_complete_strategy () return 0 ;; -X) - __gitcomp "$__git_merge_strategy_options" + __gitcomp_opts "$__git_merge_strategy_options" return 0 ;; esac @@ -1194,7 +1055,7 @@ __git_complete_strategy () return 0 ;; --strategy-option=*) - __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}" + __gitcomp_opts "$__git_merge_strategy_options" "" "${cur##--strategy-option=}" return 0 ;; esac @@ -1226,7 +1087,7 @@ __git_pretty_aliases () # __git_aliased_command requires 1 argument __git_aliased_command () { - local cur=$1 last list word cmdline + local cur=$1 last list= word cmdline while [[ -n "$cur" ]]; do if [[ "$list" == *" $cur "* ]]; then @@ -1273,7 +1134,7 @@ __git_aliased_command () # --show-idx: Optionally show the index of the found word in the $words array. __git_find_on_cmdline () { - local word c=1 show_idx + local word c="$__git_cmd_idx" show_idx while test $# -gt 1; do case "$1" in @@ -1318,7 +1179,7 @@ __git_find_last_on_cmdline () done local wordlist="$1" - while [ $c -gt 1 ]; do + while [ $c -gt "$__git_cmd_idx" ]; do ((c--)) for word in $wordlist; do if [ "$word" = "${words[c]}" ]; then @@ -1403,7 +1264,7 @@ __git_count_arguments () local word i c=0 # Skip "git" (first argument) - for ((i=1; i < ${#words[@]}; i++)); do + for ((i=$__git_cmd_idx; i < ${#words[@]}; i++)); do word="${words[i]}" case "$word" in @@ -1430,12 +1291,13 @@ __git_whitespacelist="nowarn warn error error-all fix" __git_patchformat="mbox stgit stgit-series hg mboxrd" __git_showcurrentpatch="diff raw" __git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch" +__git_quoted_cr="nowarn warn strip" _git_am () { __git_find_repo_path if [ -d "$__git_repo_path"/rebase-apply ]; then - __gitcomp "$__git_am_inprogress_options" + __gitcomp_opts "$__git_am_inprogress_options" return fi case "$cur" in @@ -1451,6 +1313,10 @@ _git_am () __gitcomp "$__git_showcurrentpatch" "" "${cur##--show-current-patch=}" return ;; + --quoted-cr=*) + __gitcomp "$__git_quoted_cr" "" "${cur##--quoted-cr=}" + return + ;; --*) __gitcomp_builtin am "" \ "$__git_am_inprogress_options" @@ -1495,7 +1361,7 @@ _git_archive () { case "$cur" in --format=*) - __gitcomp "$(git archive --list)" "" "${cur##--format=}" + __gitcomp_nl "$(git archive --list)" "" "${cur##--format=}" return ;; --remote=*) @@ -1539,13 +1405,15 @@ __git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD _git_branch () { - local i c=1 only_local_ref="n" has_r="n" + local i c="$__git_cmd_idx" only_local_ref="n" has_r="n" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in - -d|--delete|-m|--move) only_local_ref="y" ;; - -r|--remotes) has_r="y" ;; + -d|-D|--delete|-m|-M|--move|-c|-C|--copy) + only_local_ref="y" ;; + -r|--remotes) + has_r="y" ;; esac ((c++)) done @@ -1569,12 +1437,12 @@ _git_branch () _git_bundle () { - local cmd="${words[2]}" + local cmd="${words[__git_cmd_idx+1]}" case "$cword" in - 2) + $((__git_cmd_idx+1))) __gitcomp "create list-heads verify unbundle" ;; - 3) + $((__git_cmd_idx+2))) # looking for a file ;; *) @@ -1590,14 +1458,15 @@ _git_bundle () # Helper function to decide whether or not we should enable DWIM logic for # git-switch and git-checkout. # -# To decide between the following rules in priority order -# 1) the last provided of "--guess" or "--no-guess" explicitly enable or -# disable completion of DWIM logic respectively. -# 2) If the --no-track option is provided, take this as a hint to disable the -# DWIM completion logic -# 3) If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion -# logic, as requested by the user. -# 4) Enable DWIM logic otherwise. +# To decide between the following rules in decreasing priority order: +# - the last provided of "--guess" or "--no-guess" explicitly enable or +# disable completion of DWIM logic respectively. +# - If checkout.guess is false, disable completion of DWIM logic. +# - If the --no-track option is provided, take this as a hint to disable the +# DWIM completion logic +# - If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion +# logic, as requested by the user. +# - Enable DWIM logic otherwise. # __git_checkout_default_dwim_mode () { @@ -1608,11 +1477,17 @@ __git_checkout_default_dwim_mode () fi # --no-track disables DWIM, but with lower priority than - # --guess/--no-guess + # --guess/--no-guess/checkout.guess if [ -n "$(__git_find_on_cmdline "--no-track")" ]; then dwim_opt="" fi + # checkout.guess = false disables DWIM, but with lower priority than + # --guess/--no-guess + if [ "$(__git config --type=bool checkout.guess)" = "false" ]; then + dwim_opt="" + fi + # Find the last provided --guess or --no-guess last_option="$(__git_find_last_on_cmdline "--guess --no-guess")" case "$last_option" in @@ -1649,7 +1524,7 @@ _git_checkout () case "$cur" in --conflict=*) - __gitcomp "diff3 merge" "" "${cur##--conflict=}" + __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}" ;; --*) __gitcomp_builtin checkout @@ -1682,7 +1557,7 @@ _git_cherry_pick () { __git_find_repo_path if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then - __gitcomp "$__git_cherry_pick_inprogress_options" + __gitcomp_opts "$__git_cherry_pick_inprogress_options" return fi @@ -1811,8 +1686,14 @@ __git_diff_common_options="--stat --numstat --shortstat --summary --submodule --submodule= --ignore-submodules --indent-heuristic --no-indent-heuristic --textconv --no-textconv + --patch --no-patch + --anchored= " +__git_diff_difftool_options="--cached --staged --pickaxe-all --pickaxe-regex + --base --ours --theirs --no-index --relative --merge-base + $__git_diff_common_options" + _git_diff () { __git_has_doubledash && return @@ -1835,10 +1716,7 @@ _git_diff () return ;; --*) - __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex - --base --ours --theirs --no-index - $__git_diff_common_options - " + __gitcomp_opts "$__git_diff_difftool_options" return ;; esac @@ -1860,11 +1738,7 @@ _git_difftool () return ;; --*) - __gitcomp_builtin difftool "$__git_diff_common_options - --base --cached --ours --theirs - --pickaxe-all --pickaxe-regex - --relative --staged - " + __gitcomp_builtin difftool "$__git_diff_difftool_options" return ;; esac @@ -1901,9 +1775,7 @@ _git_format_patch () { case "$cur" in --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --base=*|--interdiff=*|--range-diff=*) @@ -1930,7 +1802,7 @@ _git_fsck () _git_gitk () { - _gitk + __gitk_main } # Lists matching symbol names from a tag (as in ctags) file. @@ -1984,7 +1856,7 @@ _git_grep () esac case "$cword,$prev" in - 2,*|*,-*) + $((__git_cmd_idx+1)),*|*,-*) __git_complete_symbol && return ;; esac @@ -2000,7 +1872,7 @@ _git_help () return ;; esac - if test -n "$GIT_TESTING_ALL_COMMAND_LIST" + if test -n "${GIT_TESTING_ALL_COMMAND_LIST-}" then __gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk" else @@ -2085,7 +1957,7 @@ __git_log_shortlog_options=" " __git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd" -__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:" +__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:" _git_log () { @@ -2136,7 +2008,7 @@ _git_log () return ;; --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options @@ -2154,11 +2026,9 @@ _git_log () --no-walk --no-walk= --do-walk --parents --children --expand-tabs --expand-tabs= --no-expand-tabs - --patch $merge $__git_diff_common_options --pickaxe-all --pickaxe-regex - --patch --no-patch " return ;; @@ -2201,7 +2071,7 @@ _git_mergetool () return ;; --*) - __gitcomp "--tool= --prompt --no-prompt --gui --no-gui" + __gitcomp_opts "--tool= --prompt --no-prompt --gui --no-gui" return ;; esac @@ -2349,7 +2219,7 @@ _git_range_diff () { case "$cur" in --*) - __gitcomp " + __gitcomp_opts " --creation-factor= --no-dual-color $__git_diff_common_options " @@ -2366,11 +2236,11 @@ _git_rebase () { __git_find_repo_path if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then - __gitcomp "$__git_rebase_interactive_inprogress_options" + __gitcomp_opts "$__git_rebase_interactive_inprogress_options" return elif [ -d "$__git_repo_path"/rebase-apply ] || \ [ -d "$__git_repo_path"/rebase-merge ]; then - __gitcomp "$__git_rebase_inprogress_options" + __gitcomp_opts "$__git_rebase_inprogress_options" return fi __git_complete_strategy && return @@ -2404,6 +2274,7 @@ _git_reflog () fi } +__git_send_email_options="--no-cc-cover --cc= --no-bcc --force --relogin-delay= --to= --suppress-cc= --no-annotate --no-chain-reply-to --sendmail-cmd= --no-identity --transfer-encoding= --validate --no-smtp-auth --confirm= --no-format-patch --reply-to= --smtp-pass= --smtp-server= --annotate --envelope-sender= --no-validate --dry-run --no-thread --smtp-debug= --no-to --thread --no-xmailer --identity= --no-signed-off-cc --no-signed-off-by-cc --smtp-domain= --to-cover --8bit-encoding= --bcc= --smtp-ssl-cert-path= --smtp-user= --cc-cmd= --to-cmd= --no-cc --smtp-server-option= --in-reply-to= --subject= --batch-size= --smtp-auth= --compose --smtp-server-port= --xmailer --no-to-cover --chain-reply-to --smtp-encryption= --dump-aliases --quiet --smtp-ssl --signed-off-cc --signed-off-by-cc --suppress-from --compose-encoding= --no-suppress-from --sender= --from= --format-patch --cc-cover --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --filename-max-length= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --from --attach --inline --signature= --base= --signature-file= --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-filename-max-length --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-from --no-in-reply-to --no-attach --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor" __git_send_email_confirm_options="always never auto cc compose" __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" @@ -2411,7 +2282,7 @@ _git_send_email () { case "$prev" in --to|--cc|--bcc|--from) - __gitcomp "$(__git send-email --dump-aliases)" + __gitcomp_nl "$(__git send-email --dump-aliases)" return ;; esac @@ -2435,9 +2306,7 @@ _git_send_email () return ;; --thread=*) - __gitcomp " - deep shallow - " "" "${cur##--thread=}" + __gitcomp "deep shallow" "" "${cur##--thread=}" return ;; --to=*|--cc=*|--bcc=*|--from=*) @@ -2445,16 +2314,7 @@ _git_send_email () return ;; --*) - __gitcomp_builtin send-email "--annotate --bcc --cc --cc-cmd --chain-reply-to - --compose --confirm= --dry-run --envelope-sender - --from --identity - --in-reply-to --no-chain-reply-to --no-signed-off-by-cc - --no-suppress-from --no-thread --quiet --reply-to - --signed-off-by-cc --smtp-pass --smtp-server - --smtp-server-port --smtp-encryption= --smtp-user - --subject --suppress-cc= --suppress-from --thread --to - --validate --no-validate - $__git_format_patch_extra_options" + __gitcomp_builtin send-email "$__git_send_email_options $__git_format_patch_extra_options" return ;; esac @@ -2532,7 +2392,7 @@ _git_switch () case "$cur" in --conflict=*) - __gitcomp "diff3 merge" "" "${cur##--conflict=}" + __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}" ;; --*) __gitcomp_builtin switch @@ -2566,7 +2426,7 @@ _git_switch () __git_config_get_set_variables () { local prevword word config_file= c=$cword - while [ $c -gt 1 ]; do + while [ $c -gt "$__git_cmd_idx" ]; do word="${words[c]}" case "$word" in --system|--global|--local|--file=*) @@ -2629,7 +2489,7 @@ __git_complete_config_variable_value () return ;; branch.*.rebase) - __gitcomp "false true merges preserve interactive" "" "$cur_" + __gitcomp "false true merges interactive" "" "$cur_" return ;; remote.pushdefault) @@ -2717,7 +2577,7 @@ __git_complete_config_variable_value () # subsections) instead of the default space. __git_complete_config_variable_name () { - local cur_="$cur" sfx + local cur_="$cur" sfx=" " while test $# != 0; do case "$1" in @@ -2739,7 +2599,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" - __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx:- }" + __gitcomp "autoSetupMerge autoSetupRebase" "$pfx" "$cur_" "$sfx" return ;; guitool.*.*) @@ -2773,7 +2633,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __git_compute_all_commands - __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }" + __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "$sfx" return ;; remote.*.*) @@ -2789,7 +2649,7 @@ __git_complete_config_variable_name () local pfx="${cur_%.*}." cur_="${cur_#*.}" __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." - __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx:- }" + __gitcomp "pushDefault" "$pfx" "$cur_" "$sfx" return ;; url.*.*) @@ -2804,7 +2664,7 @@ __git_complete_config_variable_name () ;; *) __git_compute_config_vars - __gitcomp "$(echo "$__git_config_vars" | + __gitcomp_nl "$(echo "$__git_config_vars" | awk -F . '{ sections[$1] = 1 } @@ -2812,7 +2672,7 @@ __git_complete_config_variable_name () for (s in sections) print s "." } - ')" "" "$cur_" + ')" "" "$cur_" "" ;; esac } @@ -2906,7 +2766,7 @@ _git_remote () __gitcomp_builtin remote_update ;; update,*) - __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")" + __gitcomp_nl "$(__git_remotes) $(__git_get_config_variables "remotes")" ;; set-url,--*) __gitcomp_builtin remote_set-url @@ -2973,7 +2833,7 @@ _git_restore () case "$cur" in --conflict=*) - __gitcomp "diff3 merge" "" "${cur##--conflict=}" + __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}" ;; --source=*) __git_complete_refs --cur="${cur##--source=}" @@ -2990,7 +2850,7 @@ _git_revert () { __git_find_repo_path if [ -f "$__git_repo_path"/REVERT_HEAD ]; then - __gitcomp "$__git_revert_inprogress_options" + __gitcomp_opts "$__git_revert_inprogress_options" return fi __git_complete_strategy && return @@ -3022,7 +2882,7 @@ _git_shortlog () case "$cur" in --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_shortlog_options --numbered --summary --email @@ -3060,8 +2920,8 @@ _git_show () return ;; --*) - __gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit - --oneline --show-signature --patch + __gitcomp_opts "--pretty= --format= --abbrev-commit --no-abbrev-commit + --oneline --show-signature --expand-tabs --expand-tabs= --no-expand-tabs $__git_diff_common_options " @@ -3093,10 +2953,10 @@ _git_sparse_checkout () case "$subcommand,$cur" in init,--*) - __gitcomp "--cone" + __gitcomp_opts "--cone" ;; set,--*) - __gitcomp "--stdin" + __gitcomp_opts "--stdin" ;; *) ;; @@ -3105,63 +2965,48 @@ _git_sparse_checkout () _git_stash () { - local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' local subcommands='push list show apply clear drop pop create branch' local subcommand="$(__git_find_on_cmdline "$subcommands save")" - if [ -z "$subcommand" -a -n "$(__git_find_on_cmdline "-p")" ]; then - subcommand="push" - fi + if [ -z "$subcommand" ]; then - case "$cur" in - --*) - __gitcomp "$save_opts" + case "$((cword - __git_cmd_idx)),$cur" in + *,--*) + __gitcomp_builtin stash_push ;; - sa*) - if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then - __gitcomp "save" - fi + 1,sa*) + __gitcomp "save" ;; - *) - if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then - __gitcomp "$subcommands" - fi + 1,*) + __gitcomp "$subcommands" ;; esac - else - case "$subcommand,$cur" in - push,--*) - __gitcomp "$save_opts --message" - ;; - save,--*) - __gitcomp "$save_opts" - ;; - apply,--*|pop,--*) - __gitcomp "--index --quiet" - ;; - drop,--*) - __gitcomp "--quiet" - ;; - list,--*) - __gitcomp "--name-status --oneline --patch-with-stat" - ;; - show,--*|branch,--*) - ;; - branch,*) - if [ $cword -eq 3 ]; then - __git_complete_refs - else - __gitcomp_nl "$(__git stash list \ - | sed -n -e 's/:.*//p')" - fi - ;; - show,*|apply,*|drop,*|pop,*) + return + fi + + case "$subcommand,$cur" in + list,--*) + # NEEDSWORK: can we somehow unify this with the options in _git_log() and _git_show() + __gitcomp_builtin stash_list "$__git_log_common_options $__git_diff_common_options" + ;; + show,--*) + __gitcomp_builtin stash_show "$__git_diff_common_options" + ;; + *,--*) + __gitcomp_builtin "stash_$subcommand" + ;; + branch,*) + if [ $cword -eq $((__git_cmd_idx+2)) ]; then + __git_complete_refs + else __gitcomp_nl "$(__git stash list \ | sed -n -e 's/:.*//p')" - ;; - *) - ;; - esac - fi + fi + ;; + show,*|apply,*|drop,*|pop,*) + __gitcomp_nl "$(__git stash list \ + | sed -n -e 's/:.*//p')" + ;; + esac } _git_submodule () @@ -3173,7 +3018,7 @@ _git_submodule () if [ -z "$subcommand" ]; then case "$cur" in --*) - __gitcomp "--quiet" + __gitcomp_opts "--quiet" ;; *) __gitcomp "$subcommands" @@ -3184,29 +3029,29 @@ _git_submodule () case "$subcommand,$cur" in add,--*) - __gitcomp "--branch --force --name --reference --depth" + __gitcomp_opts "--branch --force --name --reference --depth" ;; status,--*) - __gitcomp "--cached --recursive" + __gitcomp_opts "--cached --recursive" ;; deinit,--*) - __gitcomp "--force --all" + __gitcomp_opts "--force --all" ;; update,--*) - __gitcomp " + __gitcomp_opts " --init --remote --no-fetch --recommend-shallow --no-recommend-shallow --force --rebase --merge --reference --depth --recursive --jobs " ;; set-branch,--*) - __gitcomp "--default --branch" + __gitcomp_opts "--default --branch" ;; summary,--*) - __gitcomp "--cached --files --summary-limit" + __gitcomp_opts "--cached --files --summary-limit" ;; foreach,--*|sync,--*) - __gitcomp "--recursive" + __gitcomp_opts "--recursive" ;; *) ;; @@ -3247,64 +3092,64 @@ _git_svn () case "$subcommand,$cur" in fetch,--*) - __gitcomp "--revision= --fetch-all $fc_opts" + __gitcomp_opts "--revision= --fetch-all $fc_opts" ;; clone,--*) - __gitcomp "--revision= $fc_opts $init_opts" + __gitcomp_opts "--revision= $fc_opts $init_opts" ;; init,--*) - __gitcomp "$init_opts" + __gitcomp_opts "$init_opts" ;; dcommit,--*) - __gitcomp " + __gitcomp_opts " --merge --strategy= --verbose --dry-run --fetch-all --no-rebase --commit-url --revision --interactive $cmt_opts $fc_opts " ;; set-tree,--*) - __gitcomp "--stdin $cmt_opts $fc_opts" + __gitcomp_opts "--stdin $cmt_opts $fc_opts" ;; create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ show-externals,--*|mkdirs,--*) - __gitcomp "--revision=" + __gitcomp_opts "--revision=" ;; log,--*) - __gitcomp " + __gitcomp_opts " --limit= --revision= --verbose --incremental --oneline --show-commit --non-recursive --authors-file= --color " ;; rebase,--*) - __gitcomp " + __gitcomp_opts " --merge --verbose --strategy= --local --fetch-all --dry-run $fc_opts " ;; commit-diff,--*) - __gitcomp "--message= --file= --revision= $cmt_opts" + __gitcomp_opts "--message= --file= --revision= $cmt_opts" ;; info,--*) - __gitcomp "--url" + __gitcomp_opts "--url" ;; branch,--*) - __gitcomp "--dry-run --message --tag" + __gitcomp_opts "--dry-run --message --tag" ;; tag,--*) - __gitcomp "--dry-run --message" + __gitcomp_opts "--dry-run --message" ;; blame,--*) - __gitcomp "--git-format" + __gitcomp_opts "--git-format" ;; migrate,--*) - __gitcomp " + __gitcomp_opts " --config-dir= --ignore-paths= --minimize --no-auth-cache --username= " ;; reset,--*) - __gitcomp "--revision= --parent" + __gitcomp_opts "--revision= --parent" ;; *) ;; @@ -3314,7 +3159,7 @@ _git_svn () _git_tag () { - local i c=1 f=0 + local i c="$__git_cmd_idx" f=0 while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in @@ -3357,9 +3202,10 @@ _git_whatchanged () __git_complete_worktree_paths () { local IFS=$'\n' + # Generate completion reply from worktree list skipping the first + # entry: it's the path of the main worktree, which can't be moved, + # removed, locked, etc. __gitcomp_nl "$(git worktree list --porcelain | - # Skip the first entry: it's the path of the main worktree, - # which can't be moved, removed, locked, etc. sed -n -e '2,$ s/^worktree //p')" } @@ -3458,15 +3304,19 @@ __git_support_parseopt_helper () { esac } +__git_have_func () { + declare -f -- "$1" >/dev/null 2>&1 +} + __git_complete_command () { local command="$1" local completion_func="_git_${command//-/_}" - if ! declare -f $completion_func >/dev/null 2>/dev/null && - declare -f _completion_loader >/dev/null 2>/dev/null + if ! __git_have_func $completion_func && + __git_have_func _completion_loader then _completion_loader "git-$command" fi - if declare -f $completion_func >/dev/null 2>/dev/null + if __git_have_func $completion_func then $completion_func return 0 @@ -3483,21 +3333,40 @@ __git_main () { local i c=1 command __git_dir __git_repo_path local __git_C_args C_args_count=0 + local __git_cmd_idx while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in - --git-dir=*) __git_dir="${i#--git-dir=}" ;; - --git-dir) ((c++)) ; __git_dir="${words[c]}" ;; - --bare) __git_dir="." ;; - --help) command="help"; break ;; - -c|--work-tree|--namespace) ((c++)) ;; - -C) __git_C_args[C_args_count++]=-C + --git-dir=*) + __git_dir="${i#--git-dir=}" + ;; + --git-dir) + ((c++)) + __git_dir="${words[c]}" + ;; + --bare) + __git_dir="." + ;; + --help) + command="help" + break + ;; + -c|--work-tree|--namespace) + ((c++)) + ;; + -C) + __git_C_args[C_args_count++]=-C ((c++)) __git_C_args[C_args_count++]="${words[c]}" ;; - -*) ;; - *) command="$i"; break ;; + -*) + ;; + *) + command="$i" + __git_cmd_idx="$c" + break + ;; esac ((c++)) done @@ -3519,7 +3388,8 @@ __git_main () ;; esac case "$cur" in - --*) __gitcomp " + --*) + __gitcomp_opts " --paginate --no-pager --git-dir= @@ -3541,7 +3411,7 @@ __git_main () then __gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST" else - __gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)" + __gitcomp_nl "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)" fi ;; esac @@ -3570,7 +3440,7 @@ __gitk_main () fi case "$cur" in --*) - __gitcomp " + __gitcomp_opts " $__git_log_common_options $__git_log_gitk_options $merge @@ -3586,17 +3456,106 @@ if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then return fi +# The following function is based on code from: +# +# bash_completion - programmable completion functions for bash 3.2+ +# +# Copyright © 2006-2008, Ian Macdonald <ian@caliban.org> +# © 2009-2010, Bash Completion Maintainers +# <bash-completion-devel@lists.alioth.debian.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see <http://www.gnu.org/licenses/>. +# +# The latest version of this software can be obtained here: +# +# http://bash-completion.alioth.debian.org/ +# +# RELEASE: 2.x + +# This function reorganizes the words on the command line to be processed by +# the rest of the script. +# +# This is roughly equivalent to going back in time and setting +# COMP_WORDBREAKS to exclude '=' and ':'. The intent is to +# make option types like --date=<type> and <rev>:<path> easy to +# recognize by treating each shell word as a single token. +# +# It is best not to set COMP_WORDBREAKS directly because the value is +# shared with other completion scripts. By the time the completion +# function gets called, COMP_WORDS has already been populated so local +# changes to COMP_WORDBREAKS have no effect. + +if ! type __git_get_comp_words_by_ref >/dev/null 2>&1; then +__git_get_comp_words_by_ref () +{ + local exclude i j first + + # Which word separators to exclude? + exclude="${COMP_WORDBREAKS//[^=:]}" + cword=$COMP_CWORD + if [ -n "$exclude" ]; then + # List of word completion separators has shrunk; + # re-assemble words to complete. + for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + # Append each nonempty word consisting of just + # word separator characters to the current word. + first=t + while + [ $i -gt 0 ] && + [ -n "${COMP_WORDS[$i]}" ] && + # word consists of excluded word separators + [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] + do + # Attach to the previous token, + # unless the previous token is the command name. + if [ $j -ge 2 ] && [ -n "$first" ]; then + ((j--)) + fi + first= + words[$j]=${words[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword=$j + fi + if (($i < ${#COMP_WORDS[@]} - 1)); then + ((i++)) + else + # Done. + break 2 + fi + done + words[$j]=${words[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword=$j + fi + done + else + words=("${COMP_WORDS[@]}") + fi + + cur=${words[cword]} + prev=${words[cword-1]} +} +fi + __git_func_wrap () { - local cur words cword prev - _get_comp_words_by_ref -n =: cur words cword prev + local cur words cword prev __git_cmd_idx=0 + __git_get_comp_words_by_ref $1 } -# Setup completion for certain functions defined above by setting common -# variables and workarounds. -# This is NOT a public function; use at your own risk. -__git_complete () +___git_complete () { local wrapper="__git_wrap${2}" eval "$wrapper () { __git_func_wrap $2 ; }" @@ -3604,15 +3563,35 @@ __git_complete () || complete -o default -o nospace -F $wrapper $1 } +# Setup the completion for git commands +# 1: command or alias +# 2: function to call (e.g. `git`, `gitk`, `git_fetch`) +__git_complete () +{ + local func + + if __git_have_func $2; then + func=$2 + elif __git_have_func __$2_main; then + func=__$2_main + elif __git_have_func _$2; then + func=_$2 + else + echo "ERROR: could not find function '$2'" 1>&2 + return 1 + fi + ___git_complete $1 $func +} + if ! git --list-cmds=main >/dev/null 2>&1; then declare -A __git_cmds __git_cmds[list-complete]="apply blame cherry config difftool fsck help instaweb mergetool prune reflog remote repack replace request-pull send-email show-branch stage whatchanged" - __git_cmds[list-guide]="attributes cli core-tutorial credentials cvs-migration diffcore everyday faq glossary hooks ignore modules namespaces remote-helpers repository-layout revisions submodules tutorial-2 tutorial workflows" - __git_cmds[list-mainporcelain]="add am archive bisect branch bundle checkout cherry-pick citool clean clone commit describe diff fetch format-patch gc grep gui init gitk log maintenance merge mv notes pull push range-diff rebase reset restore revert rm shortlog show sparse-checkout stash status submodule switch tag worktree" - __git_cmds[main]="add add--interactive am annotate apply archimport archive bisect bisect--helper blame branch bugreport bundle cat-file check-attr check-ignore check-mailmap check-ref-format checkout checkout-index cherry cherry-pick citool clean clone column commit commit-graph commit-tree config count-objects credential credential-cache credential-cache--daemon credential-gnome-keyring credential-libsecret credential-store cvsexportcommit cvsimport cvsserver daemon describe diff diff-files diff-index diff-tree difftool difftool--helper env--helper fast-export fast-import fetch fetch-pack filter-branch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc get-tar-commit-id grep gui gui--askpass hash-object help http-backend http-fetch http-push imap-send index-pack init init-db instaweb interpret-trailers log ls-files ls-remote ls-tree mailinfo mailsplit maintenance merge merge-base merge-file merge-index merge-octopus merge-one-file merge-ours merge-recursive merge-recursive-ours merge-recursive-theirs merge-resolve merge-subtree merge-tree mergetool mktag mktree multi-pack-index mv mw name-rev notes p4 pack-objects pack-redundant pack-refs patch-id pickaxe prune prune-packed pull push quiltimport range-diff read-tree rebase rebase--interactive receive-pack reflog remote remote-ext remote-fd remote-ftp remote-ftps remote-http remote-https remote-mediawiki repack replace request-pull rerere reset restore rev-list rev-parse revert rm send-email send-pack sh-i18n--envsubst shell shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace submodule submodule--helper subtree svn switch symbolic-ref tag unpack-file unpack-objects update-index update-ref update-server-info upload-archive upload-archive--writer upload-pack var verify-commit verify-pack verify-tag version web--browse whatchanged worktree write-tree" - __git_cmds[others]="compare reintegrate related remote-hg remote-sync send-series smartlist" - __git_cmds[parseopt]="add am apply archive bisect--helper blame branch bugreport cat-file check-attr check-ignore check-mailmap checkout checkout-index cherry cherry-pick clean clone column commit commit-graph config count-objects credential-cache credential-cache--daemon credential-store describe difftool env--helper fast-export fetch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc grep hash-object help init init-db interpret-trailers log ls-files ls-remote ls-tree merge merge-base merge-file mktree multi-pack-index mv name-rev notes pack-objects pack-refs pickaxe prune prune-packed pull push range-diff read-tree rebase rebase--interactive receive-pack reflog remote repack replace rerere reset restore revert rm send-pack shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace switch symbolic-ref tag update-index update-ref update-server-info upload-pack verify-commit verify-pack verify-tag version whatchanged write-tree " + __git_cmds[list-guide]="attributes cli core-tutorial credentials cvs-migration diffcore everyday faq glossary hooks ignore mailmap modules namespaces remote-helpers repository-layout revisions submodules tutorial tutorial-2 workflows" + __git_cmds[list-mainporcelain]="add am archive bisect branch bundle checkout cherry-pick citool clean clone commit describe diff fetch format-patch gc grep gui init log maintenance merge mv notes pull push range-diff rebase reset restore revert rm shortlog show sparse-checkout stash status submodule switch tag worktree gitk" + __git_cmds[main]="add add--interactive am annotate apply archimport archive bisect bisect--helper blame branch bugreport bundle cat-file check-attr check-ignore check-mailmap check-ref-format checkout checkout--worker checkout-index cherry cherry-pick citool clean clone column commit commit-graph commit-tree config count-objects credential credential-cache credential-cache--daemon credential-gnome-keyring credential-libsecret credential-store cvsexportcommit cvsimport cvsserver daemon describe diff diff-files diff-index diff-tree difftool difftool--helper env--helper fast-export fast-import fetch fetch-pack filter-branch fmt-merge-msg for-each-ref for-each-repo format-patch fsck fsck-objects gc get-tar-commit-id grep gui gui--askpass hash-object help http-backend http-fetch http-push imap-send index-pack init init-db instaweb interpret-trailers log ls-files ls-remote ls-tree mailinfo mailsplit maintenance merge merge-base merge-file merge-index merge-octopus merge-one-file merge-ours merge-recursive merge-recursive-ours merge-recursive-theirs merge-resolve merge-subtree merge-tree mergetool mktag mktree multi-pack-index mv mw name-rev notes p4 pack-objects pack-redundant pack-refs patch-id pickaxe prune prune-packed pull push quiltimport range-diff read-tree rebase receive-pack reflog remote remote-ext remote-fd remote-ftp remote-ftps remote-http remote-https remote-mediawiki repack replace request-pull rerere reset restore rev-list rev-parse revert rm send-email send-pack sh-i18n--envsubst shell shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace submodule submodule--helper subtree svn switch symbolic-ref tag unpack-file unpack-objects update-index update-ref update-server-info upload-archive upload-archive--writer upload-pack var verify-commit verify-pack verify-tag version web--browse whatchanged worktree write-tree" + __git_cmds[others]="" + __git_cmds[parseopt]="add am apply archive bisect--helper blame branch bugreport cat-file check-attr check-ignore check-mailmap checkout checkout--worker checkout-index cherry cherry-pick clean clone column commit commit-graph config count-objects credential-cache credential-cache--daemon credential-store describe difftool env--helper fast-export fetch fmt-merge-msg for-each-ref for-each-repo format-patch fsck fsck-objects gc grep hash-object help init init-db interpret-trailers log ls-files ls-remote ls-tree merge merge-base merge-file mktree multi-pack-index mv name-rev notes pack-objects pack-refs pickaxe prune prune-packed pull push range-diff read-tree rebase receive-pack reflog remote repack replace rerere reset restore revert rm send-pack shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace switch symbolic-ref tag update-index update-ref update-server-info upload-pack verify-commit verify-pack verify-tag version whatchanged write-tree " # Override __git __git () @@ -3641,13 +3620,13 @@ if ! git --list-cmds=main >/dev/null 2>&1; then fi -__git_complete git __git_main -__git_complete gitk __gitk_main +___git_complete git __git_main +___git_complete gitk __gitk_main # The following are necessary only for Cygwin, and only are needed # when the user has tab-completed the executable name and consequently # included the '.exe' suffix. # if [ "$OSTYPE" = cygwin ]; then - __git_complete git.exe __git_main + ___git_complete git.exe __git_main fi diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh index 54e123d63..db7c0068f 100644 --- a/plugins/gitfast/git-prompt.sh +++ b/plugins/gitfast/git-prompt.sh @@ -138,6 +138,7 @@ __git_ps1_show_upstream () done <<< "$output" # parse configuration values + local option for option in ${GIT_PS1_SHOWUPSTREAM}; do case "$option" in git|svn) upstream="$option" ;; @@ -432,8 +433,8 @@ __git_ps1 () fi local sparse="" - if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] && - [ -z "${GIT_PS1_OMITSPARSESTATE}" ] && + if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] && + [ -z "${GIT_PS1_OMITSPARSESTATE-}" ] && [ "$(git config --bool core.sparseCheckout)" = "true" ]; then sparse="|SPARSE" fi @@ -542,7 +543,7 @@ __git_ps1 () u="%${ZSH_VERSION+%}" fi - if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] && + if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] && [ "$(git config --bool core.sparseCheckout)" = "true" ]; then h="?" fi diff --git a/plugins/gitfast/update b/plugins/gitfast/update index 5311065a1..5ebaaef3d 100755 --- a/plugins/gitfast/update +++ b/plugins/gitfast/update @@ -1,7 +1,7 @@ #!/bin/sh url="https://raw.githubusercontent.com/felipec/git-completion" -version="1.2" +version="1.3.6" curl -s -o _git "${url}/v${version}/git-completion.zsh" && curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" && diff --git a/plugins/helm/helm.plugin.zsh b/plugins/helm/helm.plugin.zsh index 472c1c9dd..cadfa551a 100644 --- a/plugins/helm/helm.plugin.zsh +++ b/plugins/helm/helm.plugin.zsh @@ -11,12 +11,12 @@ command rm -f "${ZSH_CACHE_DIR}/helm_completion" command mkdir -p "$ZSH_CACHE_DIR/completions" (( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath) -# If the completion file doesn't exist yet, we need to autoload it and -# bind it to `helm`. Otherwise, compinit will have already done that. +# If the completion file does not exist, generate it and then source it +# Otherwise, source it and regenerate in the background if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then - declare -A _comps - autoload -Uz _helm - _comps[helm]=_helm + helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm" + source "$ZSH_CACHE_DIR/completions/_helm" +else + source "$ZSH_CACHE_DIR/completions/_helm" + helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm" &| fi - -helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm" &| diff --git a/plugins/jenv/jenv.plugin.zsh b/plugins/jenv/jenv.plugin.zsh index 946ce18a5..240102604 100644 --- a/plugins/jenv/jenv.plugin.zsh +++ b/plugins/jenv/jenv.plugin.zsh @@ -18,13 +18,19 @@ if [[ $FOUND_JENV -eq 1 ]]; then (( $+commands[jenv] )) || export PATH="${jenvdir}/bin:$PATH" eval "$(jenv init - zsh)" - function jenv_prompt_info() { jenv version-name 2>/dev/null } + function jenv_prompt_info() { + local version="$(jenv version-name 2>/dev/null)" + echo "${version:gs/%/%%}" + } if [[ -d "${jenvdir}/versions" ]]; then export JENV_ROOT=$jenvdir fi else - function jenv_prompt_info() { echo "system: $(java -version 2>&1 | cut -f 2 -d ' ')" } + function jenv_prompt_info() { + local version="$(java -version 2>&1 | cut -d' ' -f2)" + echo "system: ${version:gs/%/%%}" + } fi unset jenvdir jenvdirs FOUND_JENV diff --git a/plugins/juju/README.md b/plugins/juju/README.md index 49f8b0d47..f0c65309c 100644 --- a/plugins/juju/README.md +++ b/plugins/juju/README.md @@ -15,34 +15,46 @@ Naming convention: - `!` suffix: `--force --no-wait -y`. - `ds` suffix: `--destroy-storage`. +- `jsh` prefix means `juju show-*`. ### General -| Alias | Command | Description | -|--------|---------------------------------------------|--------------------------------------------------------| -| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution | -| `jdlr` | `juju debug-log --ms --replay` | Replay entire log | -| `jh` | `juju help` | Show help on a command or other topic | -| `jssl` | `juju juju show-status-log` | Output past statuses for the specified entity | -| `jstj` | `juju status --format=json` | Show status in json format (more detailed) | -| `jst` | `juju status --relations --storage --color` | Show status, including relations and storage, in color | +| Alias | Command | Description | +|---------|---------------------------------------------|--------------------------------------------------------| +| `j` | `juju` | The juju command | +| `jcld` | `juju clouds` | Lists all clouds with registered credentials | +| `jclda` | `juju clouds --all` | Lists all clouds available to Juju | +| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution | +| `jdlr` | `juju debug-log --ms --replay` | Replay entire log | +| `jh` | `juju help` | Show help on a command or other topic | +| `jshsl` | `juju show-status-log` | Output past statuses for the specified entity | +| `jstj` | `juju status --format=json` | Show status in json format (more detailed) | +| `jst` | `juju status --relations --color` | Show status, including relations, in color | +| `jsts` | `juju status --relations --storage --color` | Show status, including relations and storage, in color | ### Bootstrap -| Alias | Command | Description | -|-------|---------------------------|-------------------------------------------| -| `jb` | `juju bootstrap` | Initializing a Juju cloud environment | -| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment | +| Alias | Command | Description | +|---------|-------------------------------------|-------------------------------------------------------| +| `jb` | `juju bootstrap` | Initializing a Juju cloud environment | +| `jbng` | `juju bootstrap --no-gui` | Initializing a Juju cloud environment without GUI | +| `jbl` | `juju bootstrap localhost` | Initializing an lxd cloud environment | +| `jblng` | `juju bootstrap --no-gui localhost` | Initializing an lxd cloud environment without GUI | +| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment | +| `jbmng` | `juju bootstrap --no-gui microk8s` | Initializing a MicroK8s cloud environment without GUI | ### Controller | Alias | Command | Description | |----------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------| +| `jctl` | `juju controllers` | List all controllers | +| `jctlr` | `juju controllers --refresh` | List all controllers (download latest details) | | `jdc` | `juju destroy-controller --destroy-all-models` | Destroy a controller | | `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | Destroy a controller | | `jdcds` | `juju destroy-controller --destroy-all-models --destroy-storage` | Destroy a controller and associated storage | | `jdcds!` | `juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y` | Destroy a controller and associated storage | | `jkc` | `juju kill-controller -y -t 0` | Forcibly terminate all associated resources for a Juju controller | +| `jshc` | `juju show-controller` | Shows detailed information of a controller | | `jsw` | `juju switch` | Select or identify the current controller and model | ### Model @@ -74,9 +86,9 @@ Naming convention: | `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage | | `jrp` | `juju refresh --path` | Upgrade charm from local charm file | | `jsa` | `juju scale-application` | Set the desired number of application units | -| `jsh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target | -| `jshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container | -| `jsu` | `juju show-unit` | Displays information about a unit | +| `jssh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target | +| `jsshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container | +| `jshu` | `juju show-unit` | Displays information about a unit | ### Storage @@ -113,5 +125,6 @@ Naming convention: - `jaddr <app_name> [unit_num]`: display app or unit IP address. - `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data. +- `jclean`: destroy all controllers - `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval (default: 5s); you may pass additional arguments to `watch`. diff --git a/plugins/juju/juju.plugin.zsh b/plugins/juju/juju.plugin.zsh index 07f15b392..be8a2c7ae 100644 --- a/plugins/juju/juju.plugin.zsh +++ b/plugins/juju/juju.plugin.zsh @@ -16,12 +16,22 @@ unset completion_file # Generally, # # - `!` means --force --no-wait -y # # - `ds` suffix means --destroy-storage # +# - `jsh` prefix means juju show-* # # ---------------------------------------------------------- # +alias j="juju" alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\ --config update-status-hook-interval=\"60m\"" alias jb='juju bootstrap' +alias jbng='juju bootstrap --no-gui' +alias jbl='juju bootstrap localhost' +alias jblng='juju bootstrap --no-gui localhost' alias jbm='juju bootstrap microk8s' +alias jbmng='juju bootstrap --no-gui microk8s' alias jc='juju config' +alias jcld='juju clouds' +alias jclda='juju clouds --all' +alias jctl='juju controllers' +alias jctlr='juju controllers --refresh' alias jdc='juju destroy-controller --destroy-all-models' alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y' alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage' @@ -56,13 +66,16 @@ alias jrp='juju refresh --path' alias jrs='juju remove-storage' alias 'jrs!'='juju remove-storage --force' alias jsa='juju scale-application' -alias jsh='juju ssh' -alias jshc='juju ssh --container' +alias jsha='juju show-application' +alias jshc='juju show-controller' alias jshm='juju show-model' -alias jssl='juju show-status-log' +alias jshsl='juju show-status-log' +alias jshu='juju show-unit' +alias jssh='juju ssh' +alias jsshc='juju ssh --container' alias jstj='juju status --format=json' -alias jst='juju status --relations --storage --color' -alias jsu='juju show-unit' +alias jst='juju status --relations --color' +alias jsts='juju status --relations --storage --color' alias jsw='juju switch' # ---------------------------------------------------------- # @@ -95,6 +108,37 @@ jaddr() { fi } +# Destroy all controllers +jclean() { + if (( ! ${+commands[jq]} )); then + echo "jq is required but could not be found." >&2 + return 1 + fi + + local controllers=$(juju controllers --format=json | jq -r '.controllers | keys[]' 2>/dev/null) + if [[ -z "$controllers" ]]; then + echo "No controllers registered" + return 0 + fi + + echo "This will forcefully destroy all storages, models and controllers." + echo "Controllers to be destroyed:" + echo "$controllers" + + if ! read -q '?Are you sure (y/n)? '; then + echo + echo "Aborted." + return 0 + fi + + echo + for controller in ${=controllers}; do + timeout 2m juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y $controller + timeout 2m juju kill-controller -y -t 0 $controller 2>/dev/null + timeout 10s juju unregister $controller 2>/dev/null + done +} + # Display app and unit relation data jreld() { # $1 = relation name @@ -123,5 +167,6 @@ jreld() { wjst() { local interval="${1:-5}" shift $(( $# > 0 )) - watch -n "$interval" --color juju status --relations --storage --color "$@" + watch -n "$interval" --color juju status --relations --color "$@" } + diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 3630facaa..eed5727d1 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -1,13 +1,22 @@ if (( $+commands[kubectl] )); then - __KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion" - - if [[ ! -f $__KUBECTL_COMPLETION_FILE || ! -s $__KUBECTL_COMPLETION_FILE ]]; then - kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE - fi - - [[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE - - unset __KUBECTL_COMPLETION_FILE + # TODO: 2022-01-05: remove this block + # remove old generated files + command rm -f "$ZSH_CACHE_DIR/kubectl_completion" + + # TODO: 2022-01-05: remove this bit of code as it exists in oh-my-zsh.sh + # Add completions folder in $ZSH_CACHE_DIR + command mkdir -p "$ZSH_CACHE_DIR/completions" + (( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath) + + # If the completion file does not exist, generate it and then source it + # Otherwise, source it and regenerate in the background + if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then + kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl" + source "$ZSH_CACHE_DIR/completions/_kubectl" + else + source "$ZSH_CACHE_DIR/completions/_kubectl" + kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl" &| + fi fi # This command is used a LOT both below and in daily life @@ -20,7 +29,7 @@ alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca' alias kaf='kubectl apply -f' # Drop into an interactive terminal on a container -alias keti='kubectl exec -ti' +alias keti='kubectl exec -t -i' # Manage configuration quickly to switch contexts between local, dev ad staging. alias kcuc='kubectl config use-context' @@ -97,8 +106,9 @@ alias kdd='kubectl describe deployment' alias kdeld='kubectl delete deployment' alias ksd='kubectl scale deployment' alias krsd='kubectl rollout status deployment' -kres(){ - kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S) + +function kres(){ + kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S) } # Rollout management. @@ -170,9 +180,9 @@ alias kdelcj='kubectl delete cronjob' # Only run if the user actually has kubectl installed if (( ${+_comps[kubectl]} )); then - kj() { kubectl "$@" -o json | jq; } - kjx() { kubectl "$@" -o json | fx; } - ky() { kubectl "$@" -o yaml | yh; } + function kj() { kubectl "$@" -o json | jq; } + function kjx() { kubectl "$@" -o json | fx; } + function ky() { kubectl "$@" -o yaml | yh; } compdef kj=kubectl compdef kjx=kubectl diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh index abbdc254b..6096feeae 100644 --- a/plugins/kubectx/kubectx.plugin.zsh +++ b/plugins/kubectx/kubectx.plugin.zsh @@ -1,9 +1,13 @@ -typeset -A kubectx_mapping +typeset -g -A kubectx_mapping function kubectx_prompt_info() { - if [ $commands[kubectl] ]; then - local current_ctx=`kubectl config current-context` - # use value in associative array if it exists, otherwise fall back to the context name - echo "${kubectx_mapping[$current_ctx]:-$current_ctx}" - fi + (( $+commands[kubectl] )) || return + + local current_ctx=$(kubectl config current-context 2> /dev/null) + + [[ -n "$current_ctx" ]] || return + + # use value in associative array if it exists + # otherwise fall back to the context name + echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}" } diff --git a/plugins/multipass/README.md b/plugins/multipass/README.md new file mode 100644 index 000000000..f6b2d76f4 --- /dev/null +++ b/plugins/multipass/README.md @@ -0,0 +1,22 @@ +# multipass + +This plugin provides completion for [multipass](https://multipass.run), as well as aliases +for multipass commands. + +To use it, add `multipass` to the plugins array in your zshrc file: + +```zsh +plugins=(... multipass) +``` + +## Aliases + +| Alias | Command | +| ------ | ------------------------------------------------------------------- | +| `mp` | `multipass` | +| `mpl` | `multipass list` | +| `mpla` | `multipass launch` | +| `mpln` | `multipass launch --network en0 --network name=bridge0,mode=manual` | +| `mps` | `multipass shell` | +| `mpsp` | `multipass stop` | +| `mpst` | `multipass start` | diff --git a/plugins/multipass/_multipass b/plugins/multipass/_multipass new file mode 100644 index 000000000..c742df650 --- /dev/null +++ b/plugins/multipass/_multipass @@ -0,0 +1,73 @@ +#compdef multipass + +_multipass_get_command_list () { + # Sample output: + # $ multipass --help + # ... + # Options: + # -h, --help Display this help + # -v, --verbose Increase logging verbosity. Repeat the 'v' in the short option + # for more detail. Maximum verbosity is obtained with 4 (or more) + # v's, i.e. -vvvv. + # ... + # Available commands: + # alias Create an alias + # aliases List available aliases + # ... + # + $_comp_command1 --help | sed '1,/Available commands/d' | awk '/^[ \t]*[a-z]+/ { print $1 }' +} + +_multipass_get_args_list () { + # Sample output: + # $ multpass help stop + # ... + # Options: + # -h, --help Display this help + # -v, --verbose Increase logging verbosity. Repeat the 'v' in the short + # option for more detail. Maximum verbosity is obtained with + # 4 (or more) v's, i.e. -vvvv. + # --all Stop all instances + # -t, --time <time> Time from now, in minutes, to delay shutdown of the + # instance + # -c, --cancel Cancel a pending delayed shutdown + # + # Arguments: + # name Names of instances to stop. If omitted, and without the + # --all option, 'primary' will be assumed. + # + local arg_name=$($_comp_command1 help ${words[2]} | sed '1,/Arguments/d' | awk '/^[ \t]*[a-z]+/ { print $1; exit }') + + case $arg_name in + name) + # Sample output: + # $ multipass list + # Name State IPv4 Image + # workable-poacher Running 10.2.0.28 Ubuntu openHAB Home Appliance + # + $_comp_command1 list | sed '1d' | awk '/^[ \t]*[^ ]+/ { print $1 }' + ;; + command) + _multipass_get_command_list + ;; + esac +} + +_multipass () { + typeset -A opt_args + + _arguments \ + '1: :->command'\ + '*: :->args' + + case $state in + command) + compadd $(_multipass_get_command_list) + ;; + *) + compadd $(_multipass_get_args_list) + ;; + esac +} + +_multipass "$@" diff --git a/plugins/multipass/multipass.plugin.zsh b/plugins/multipass/multipass.plugin.zsh new file mode 100644 index 000000000..95025b2ad --- /dev/null +++ b/plugins/multipass/multipass.plugin.zsh @@ -0,0 +1,7 @@ +alias mp="multipass" +alias mpl="multipass list" +alias mpla="multipass launch" +alias mpln="multipass launch --network en0 --network name=bridge0,mode=manual" +alias mps="multipass shell" +alias mpsp="multipass stop" +alias mpst="multipass start" diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index e32729aa6..1b9141f21 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -117,7 +117,7 @@ function listMavenCompletions { done # List modules - modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|')) + modules=($(print -l **/pom.xml(-.N:h) | grep -v '/target/classes/META-INF/')) reply=( # common lifecycle diff --git a/plugins/npx/README.md b/plugins/npx/README.md index 41e4c1352..4b2aba8f0 100644 --- a/plugins/npx/README.md +++ b/plugins/npx/README.md @@ -1,27 +1,4 @@ -# NPX Plugin - -> npx(1) -- execute npm package binaries. ([more info](https://github.com/npm/npx)) - -This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`. - -To use it, add `npx` to the plugins array in your zshrc file: - -```zsh -plugins=(.... npx) -``` - -## Note - -The shell auto-fallback doesn't auto-install plain packages. In order to get it to install something, you need to add `@`: - -``` -➜ jasmine@latest # or just `jasmine@` -npx: installed 13 in 1.896s -Randomized with seed 54385 -Started -``` - -It does it this way so folks using the fallback don't accidentally try to install regular typoes. +# npx plugin ## Deprecation diff --git a/plugins/npx/npx.plugin.zsh b/plugins/npx/npx.plugin.zsh index 32bb67377..c1e2eca98 100644 --- a/plugins/npx/npx.plugin.zsh +++ b/plugins/npx/npx.plugin.zsh @@ -1,7 +1,12 @@ -# NPX Plugin -# https://www.npmjs.com/package/npx -# Maintainer: Pooya Parsa <pooya@pi0.ir> +if (( ! $+commands[npx] )); then + return +fi -(( $+commands[npx] )) && { - source <(npx --shell-auto-fallback zsh) -} +if ! npx_fallback_script="$(npx --shell-auto-fallback zsh 2>/dev/null)"; then + print -u2 ${(%):-"%F{yellow}This \`npx\` version ($(npx --version)) is not supported.%f"} +else + source <(<<< "$npx_fallback_script") +fi + +print -u2 ${(%):-"%F{yellow}The \`npx\` plugin is deprecated and will be removed soon. %BPlease disable it%b.%f"} +unset npx_fallback_script diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 9304e7f32..3b0935981 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -1,5 +1,5 @@ -print ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'} -print ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'} +print -u2 ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'} +print -u2 ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'} (( ${fpath[(Ie)$ZSH/plugins/macos]} )) || fpath=("$ZSH/plugins/macos" $fpath) source "$ZSH/plugins/macos/macos.plugin.zsh" diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index e36d49204..431576f4b 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/plugins/pj/pj.plugin.zsh @@ -1,37 +1,34 @@ alias pjo="pj open" -pj () { - emulate -L zsh - - cmd="cd" - project=$1 - - if [[ "open" == "$project" ]]; then - shift - project=$* - cmd=${=EDITOR} - else - project=$* +function pj() { + local cmd="cd" + local project="$1" + + if [[ "open" == "$project" ]]; then + shift + project=$* + cmd=${=EDITOR} + else + project=$* + fi + + for basedir ($PROJECT_PATHS); do + if [[ -d "$basedir/$project" ]]; then + $cmd "$basedir/$project" + return fi + done - for basedir ($PROJECT_PATHS); do - if [[ -d "$basedir/$project" ]]; then - $cmd "$basedir/$project" - return - fi - done - - echo "No such project '${project}'." + echo "No such project '${project}'." } _pj () { - emulate -L zsh + local -a projects + for basedir ($PROJECT_PATHS); do + projects+=(${basedir}/*(/N)) + done - typeset -a projects - for basedir ($PROJECT_PATHS); do - projects+=(${basedir}/*(/N)) - done - - compadd ${projects:t} + compadd ${projects:t} } + compdef _pj pj diff --git a/plugins/poetry/README.md b/plugins/poetry/README.md new file mode 100644 index 000000000..51780cbed --- /dev/null +++ b/plugins/poetry/README.md @@ -0,0 +1,9 @@ +# Poetry Plugin + +This plugin automatically installs [Poetry](https://python-poetry.org/)'s completions for you, and keeps them up to date as your Poetry version changes. + +To use it, add `poetry` to the plugins array in your zshrc file: + +```zsh +plugins=(... poetry) +``` diff --git a/plugins/poetry/poetry.plugin.zsh b/plugins/poetry/poetry.plugin.zsh new file mode 100644 index 000000000..cebcb46c4 --- /dev/null +++ b/plugins/poetry/poetry.plugin.zsh @@ -0,0 +1,14 @@ +# Return immediately if poetry is not found +if (( ! $+commands[poetry] )); then + return +fi + +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `poetry`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_poetry" ]]; then + typeset -g -A _comps + autoload -Uz _poetry + _comps[poetry]=_poetry +fi + +poetry completions zsh >| "$ZSH_CACHE_DIR/completions/_poetry" &| diff --git a/plugins/postgres/postgres.plugin.zsh b/plugins/postgres/postgres.plugin.zsh index c2dbef244..b6d365d8a 100644 --- a/plugins/postgres/postgres.plugin.zsh +++ b/plugins/postgres/postgres.plugin.zsh @@ -1,8 +1,13 @@ # Aliases to control Postgres # Paths noted below are for Postgres installed via Homebrew on OSX +if (( ! $+commands[brew] )); then + return +fi -alias startpost='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start' -alias stoppost='pg_ctl -D /usr/local/var/postgres stop -s -m fast' -alias restartpost='stoppost && sleep 1 && startpost' -alias reloadpost='pg_ctl reload -D /usr/local/var/postgres -s' -alias statuspost='pg_ctl status -D /usr/local/var/postgres -s'
\ No newline at end of file +local PG_BREW_DIR=$(brew --prefix)/var/postgres + +alias startpost="pg_ctl -D $PG_BREW_DIR -l $PG_BREW_DIR/server.log start" +alias stoppost="pg_ctl -D $PG_BREW_DIR stop -s -m fast" +alias restartpost="stoppost && sleep 1 && startpost" +alias reloadpost="pg_ctl reload -D $PG_BREW_DIR -s" +alias statuspost="pg_ctl status -D $PG_BREW_DIR -s" diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 39897ed16..ebb1a708a 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -83,12 +83,14 @@ if [[ $FOUND_PYENV -eq 1 ]]; then fi function pyenv_prompt_info() { - echo "$(pyenv version-name)" + local version="$(pyenv version-name)" + echo "${version:gs/%/%%}" } else # Fall back to system python function pyenv_prompt_info() { - echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')" + local version="$(python -V 2>&1 | cut -d' ' -f2)" + echo "system: ${version:gs/%/%%}" } fi diff --git a/plugins/rbw/README.md b/plugins/rbw/README.md index 87d073d24..cae36cead 100644 --- a/plugins/rbw/README.md +++ b/plugins/rbw/README.md @@ -9,4 +9,14 @@ To use it, add `rbw` to the plugins array in your zshrc file: plugins=(... rbw) ``` +## `rbwpw` + +The `rbwpw` function is a wrapper around `rbw`. It copies the password in the +clipboard for the service you ask for and clears the clipboard 20s later. +The usage is as follows: + +```zsh +rbwpw <service> +``` + This plugin does not add any aliases. diff --git a/plugins/rbw/rbw.plugin.zsh b/plugins/rbw/rbw.plugin.zsh index 3825be7a6..523e35aff 100644 --- a/plugins/rbw/rbw.plugin.zsh +++ b/plugins/rbw/rbw.plugin.zsh @@ -11,9 +11,39 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `rbw`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _rbw _comps[rbw]=_rbw fi rbw gen-completions zsh >| "$ZSH_CACHE_DIR/completions/_rbw" &| + +# rbwpw function copies the password of a service to the clipboard +# and clears it after 20 seconds +function rbwpw { + if [[ $# -ne 1 ]]; then + echo "usage: rbwpw <service>" + return 1 + fi + local service=$1 + if ! rbw unlock; then + echo "rbw is locked" + return 1 + fi + local pw=$(rbw get $service 2>/dev/null) + if [[ -z $pw ]]; then + echo "$service not found" + return 1 + fi + echo -n $pw | clipcopy + echo "password for $service copied!" + {sleep 20 && clipcopy </dev/null 2>/dev/null} &| +} + +function _rbwpw { + local -a services + services=("${(@f)$(rbw ls 2>/dev/null)}") + [[ -n "$services" ]] && compadd -a -- services +} + +compdef _rbwpw rbwpw diff --git a/plugins/ripgrep/README.md b/plugins/ripgrep/README.md index a26f45823..ab9d04116 100644 --- a/plugins/ripgrep/README.md +++ b/plugins/ripgrep/README.md @@ -7,7 +7,3 @@ To use it, add `ripgrep` to the plugins array in your zshrc file: ```zsh plugins=(... ripgrep) ``` - -Completion is taken from the ripgrep release [`12.1.1`](https://github.com/BurntSushi/ripgrep/releases/tag/12.1.1). - -Updated on April 1st, 2021. diff --git a/plugins/ripgrep/_ripgrep b/plugins/ripgrep/_ripgrep index 828a6e601..31bc697c7 100644 --- a/plugins/ripgrep/_ripgrep +++ b/plugins/ripgrep/_ripgrep @@ -121,7 +121,7 @@ _rg() { "(pretty-vimgrep)--no-heading[don't show matches grouped by file name]" + '(hidden)' # Hidden-file options - '--hidden[search hidden files and directories]' + {-.,--hidden}'[search hidden files and directories]' $no"--no-hidden[don't search hidden files and directories]" + '(hybrid)' # hybrid regex options @@ -303,6 +303,8 @@ _rg() { '--context-separator=[specify string used to separate non-continuous context lines in output]:separator' $no"--no-context-separator[don't print context separators]" '--debug[show debug messages]' + '--field-context-separator[set string to delimit fields in context lines]' + '--field-match-separator[set string to delimit fields in matching lines]' '--trace[show more verbose debug messages]' '--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)' "(1 stats)--files[show each file that would be searched (but don't search)]" diff --git a/plugins/rust/rust.plugin.zsh b/plugins/rust/rust.plugin.zsh index 014c73b3b..db6ca9e74 100644 --- a/plugins/rust/rust.plugin.zsh +++ b/plugins/rust/rust.plugin.zsh @@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # bind it to `cargo`. Otherwise, compinit will have already done that if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then autoload -Uz _cargo - declare -A _comps + typeset -g -A _comps _comps[cargo]=_cargo fi @@ -19,7 +19,7 @@ fi # bind it to `rustup`. Otherwise, compinit will have already done that if [[ ! -f "$ZSH_CACHE_DIR/completions/_rustup" ]]; then autoload -Uz _rustup - declare -A _comps + typeset -g -A _comps _comps[rustup]=_rustup fi @@ -27,5 +27,5 @@ fi rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &| cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF' #compdef cargo -source $(rustc +${${(z)$(rustup default)}[1]} --print sysroot)/share/zsh/site-functions/_cargo +source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo EOF diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 4ba885563..864389ba8 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -1,7 +1,7 @@ # Completion fpath+=("${rvm_path}/scripts/zsh/Completion") -declare -A _comps +typeset -g -A _comps autoload -Uz _rvm _comps[rvm]=_rvm diff --git a/plugins/sudo/README.md b/plugins/sudo/README.md index 012fc5325..27cd20c18 100644 --- a/plugins/sudo/README.md +++ b/plugins/sudo/README.md @@ -24,6 +24,20 @@ By pressing the <kbd>esc</kbd> key twice, you will have the same command with `s $ sudo apt-get install build-essential ``` +The same happens for editing files with your default editor (defined in `$SUDO_EDITOR`, `$VISUAL` or `$EDITOR`, in that order): + +If the editor defined were `vim`: + +```console +$ vim /etc/hosts +``` + +By pressing the <kbd>esc</kbd> key twice, you will have the same command with `sudo -e` instead of the editor, that would open that editor with root privileges: + +```console +$ sudo -e /etc/hosts +``` + ### Previous executed commands Say you want to delete a system file and denied: @@ -44,6 +58,8 @@ Password: $ ``` +The same happens for file editing, as told before. + ## Key binding By default, the `sudo` plugin uses <kbd>Esc</kbd><kbd>Esc</kbd> as the trigger. diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index e02f88a87..2a0b3bfc4 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -2,7 +2,7 @@ # Description # ----------- # -# sudo or sudoedit will be inserted before the command +# sudo or sudo -e (replacement for sudoedit) will be inserted before the command # # ------------------------------------------------------------------------------ # Authors @@ -11,14 +11,19 @@ # * Dongweiming <ciici123@gmail.com> # * Subhaditya Nath <github.com/subnut> # * Marc Cornellà <github.com/mcornella> +# * Carlo Sala <carlosalag@protonmail.com> # # ------------------------------------------------------------------------------ __sudo-replace-buffer() { local old=$1 new=$2 space=${2:+ } - if [[ ${#LBUFFER} -le ${#old} ]]; then - RBUFFER="${space}${BUFFER#$old }" - LBUFFER="${new}" + + # if the cursor is positioned in the $old part of the text, make + # the substitution and leave the cursor after the $new text + if [[ $CURSOR -le ${#old} ]]; then + BUFFER="${new}${space}${BUFFER#$old }" + CURSOR=${#new} + # otherwise just replace $old with $new in the text before the cursor else LBUFFER="${new}${space}${LBUFFER#$old }" fi @@ -35,14 +40,21 @@ sudo-command-line() { LBUFFER="${LBUFFER:1}" fi - # If $EDITOR is not set, just toggle the sudo prefix on and off - if [[ -z "$EDITOR" ]]; then - case "$BUFFER" in - sudoedit\ *) __sudo-replace-buffer "sudoedit" "" ;; - sudo\ *) __sudo-replace-buffer "sudo" "" ;; - *) LBUFFER="sudo $LBUFFER" ;; - esac - else + { + # If $SUDO_EDITOR or $VISUAL are defined, then use that as $EDITOR + # Else use the default $EDITOR + local EDITOR=${SUDO_EDITOR:-${VISUAL:-$EDITOR}} + + # If $EDITOR is not set, just toggle the sudo prefix on and off + if [[ -z "$EDITOR" ]]; then + case "$BUFFER" in + sudo\ -e\ *) __sudo-replace-buffer "sudo -e" "" ;; + sudo\ *) __sudo-replace-buffer "sudo" "" ;; + *) LBUFFER="sudo $LBUFFER" ;; + esac + return + fi + # Check if the typed command is really an alias to $EDITOR # Get the first part of the typed command @@ -67,24 +79,25 @@ sudo-command-line() { if [[ "$realcmd" = (\$EDITOR|$editorcmd|${editorcmd:c}) \ || "${realcmd:c}" = ($editorcmd|${editorcmd:c}) ]] \ || builtin which -a "$realcmd" | command grep -Fx -q "$editorcmd"; then - editorcmd="$cmd" # replace $editorcmd with the typed command so it matches below + __sudo-replace-buffer "$cmd" "sudo -e" + return fi # Check for editor commands in the typed command and replace accordingly case "$BUFFER" in - $editorcmd\ *) __sudo-replace-buffer "$editorcmd" "sudoedit" ;; - \$EDITOR\ *) __sudo-replace-buffer '$EDITOR' "sudoedit" ;; - sudoedit\ *) __sudo-replace-buffer "sudoedit" "$EDITOR" ;; + $editorcmd\ *) __sudo-replace-buffer "$editorcmd" "sudo -e" ;; + \$EDITOR\ *) __sudo-replace-buffer '$EDITOR' "sudo -e" ;; + sudo\ -e\ *) __sudo-replace-buffer "sudo -e" "$EDITOR" ;; sudo\ *) __sudo-replace-buffer "sudo" "" ;; *) LBUFFER="sudo $LBUFFER" ;; esac - fi - - # Preserve beginning space - LBUFFER="${WHITESPACE}${LBUFFER}" + } always { + # Preserve beginning space + LBUFFER="${WHITESPACE}${LBUFFER}" - # Redisplay edit buffer (compatibility with zsh-syntax-highlighting) - zle redisplay + # Redisplay edit buffer (compatibility with zsh-syntax-highlighting) + zle redisplay + } } zle -N sudo-command-line diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index f40a59685..46dd5cb0c 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -1,6 +1,6 @@ function svn_prompt_info() { local info - info=$(svn info 2>&1) || return 1 # capture stdout and stderr + info=$(LANG= svn info 2>&1) || return 1 # capture stdout and stderr local repo_need_upgrade=$(svn_repo_need_upgrade $info) if [[ -n $repo_need_upgrade ]]; then @@ -20,7 +20,7 @@ function svn_prompt_info() { "$ZSH_PROMPT_BASE_COLOR" \ \ "$ZSH_THEME_BRANCH_NAME_COLOR" \ - "$(svn_current_branch_name $info)" \ + "${$(svn_current_branch_name $info):gs/%/%%}" \ "$ZSH_PROMPT_BASE_COLOR" \ \ "$(svn_current_revision $info)" \ @@ -31,42 +31,44 @@ function svn_prompt_info() { } function svn_repo_need_upgrade() { - grep -q "E155036" <<< "${1:-$(svn info 2> /dev/null)}" && \ + command grep -q "E155036" <<< "${1:-$(LANG= svn info 2>/dev/null)}" && \ echo "E155036: upgrade repo with svn upgrade" } function svn_current_branch_name() { - grep '^URL:' <<< "${1:-$(svn info 2> /dev/null)}" | egrep -o '(tags|branches)/[^/]+|trunk' + omz_urldecode "$( + command grep '^URL:' <<< "${1:-$(svn info 2>/dev/null)}" | command grep -Eo '(tags|branches)/[^/]+|trunk' + )" } function svn_repo_root_name() { - grep '^Repository\ Root:' <<< "${1:-$(svn info 2> /dev/null)}" | sed 's#.*/##' + command grep '^Repository\ Root:' <<< "${1:-$(LANG= svn info 2>/dev/null)}" | sed 's#.*/##' } function svn_current_revision() { - echo "${1:-$(svn info 2> /dev/null)}" | sed -n 's/Revision: //p' + echo "${1:-$(LANG= svn info 2>/dev/null)}" | sed -n 's/Revision: //p' } function svn_status_info() { local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN" - local svn_status="$(svn status 2> /dev/null)"; - if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then - svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}" + local svn_status="$(svn status 2>/dev/null)"; + if command grep -E '^\s*A' &>/dev/null <<< "$svn_status"; then + svn_status_string+="${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}" fi - if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then - svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}" + if command grep -E '^\s*D' &>/dev/null <<< "$svn_status"; then + svn_status_string+="${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}" fi - if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then - svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}" + if command grep -E '^\s*M' &>/dev/null <<< "$svn_status"; then + svn_status_string+="${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}" fi - if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then - svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}" + if command grep -E '^\s*[R~]' &>/dev/null <<< "$svn_status"; then + svn_status_string+="${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}" fi - if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then - svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}" + if command grep -E '^\s*\?' &>/dev/null <<< "$svn_status"; then + svn_status_string+="${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}" fi - if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then - svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DIRTY:-!}" + if command grep -E '^\s*[CI!L]' &>/dev/null <<< "$svn_status"; then + svn_status_string+="${ZSH_THEME_SVN_PROMPT_DIRTY:-!}" fi echo $svn_status_string } diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index fbc9ee538..22b07b4ec 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -1,72 +1,76 @@ svn_prompt_info() { - local _DISPLAY - if in_svn; then - if [[ "$SVN_SHOW_BRANCH" = true ]]; then - unset SVN_SHOW_BRANCH - _DISPLAY=$(svn_get_branch_name) - else - _DISPLAY=$(svn_get_repo_name) - _DISPLAY=$(omz_urldecode "${_DISPLAY}") - fi - echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ -$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR" + local info display + info="$(LANG= svn info 2>/dev/null)" || return 1 + + if [[ "$SVN_SHOW_BRANCH" = true ]]; then + display="$(svn_get_branch_name "$info")" + else + display="$(svn_get_repo_name "$info")" fi -} + printf '%s%s%s%s%s%s%s%s%s%s' \ + "$ZSH_PROMPT_BASE_COLOR" \ + "$ZSH_THEME_SVN_PROMPT_PREFIX" \ + "$ZSH_THEME_REPO_NAME_COLOR" \ + "${display:gs/%/%%}" \ + "$ZSH_PROMPT_BASE_COLOR" \ + "$ZSH_THEME_SVN_PROMPT_SUFFIX" \ + "$ZSH_PROMPT_BASE_COLOR" \ + "$(svn_dirty $info)" \ + "$(svn_dirty_pwd)" \ + "$ZSH_PROMPT_BASE_COLOR" +} in_svn() { - svn info >/dev/null 2>&1 + svn info &>/dev/null } svn_get_repo_name() { - if in_svn; then - LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT - LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p" - fi + local info name + info="${1:-$(LANG= svn info 2>/dev/null)}" + name="$(sed -n 's/^Repository\ Root:\ .*\///p' <<< "$info")" + omz_urldecode "$name" } svn_get_branch_name() { - local _DISPLAY=$( - LANG=C svn info 2> /dev/null | \ - awk -F/ \ - '/^URL:/ { \ - for (i=0; i<=NF; i++) { \ - if ($i == "branches" || $i == "tags" ) { \ - print $(i+1); \ - break;\ - }; \ - if ($i == "trunk") { print $i; break; } \ - } \ - }' + local info branch + info="${1:-$(LANG= svn info 2>/dev/null)}" + branch=$( + awk -F/ '/^URL:/ { + for (i=0; i<=NF; i++) { + if ($i == "branches" || $i == "tags" ) { + print $(i+1) + break + }; + if ($i == "trunk") { + print $i + break + } + } + }' <<< "$info" ) + branch="$(omz_urldecode "$branch")" - if [[ -z "$_DISPLAY" ]]; then - svn_get_repo_name - else - echo $_DISPLAY - fi + echo "${branch:-$(svn_get_repo_name "$info")}" } svn_get_rev_nr() { - if in_svn; then - LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p' - fi + sed -n 's/Revision:\ //p' <<<"${1:-$(LANG= svn info 2>/dev/null)}" } svn_dirty() { - svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN + svn_dirty_choose "${1:-$(LANG= svn info 2>/dev/null)}" $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN } svn_dirty_choose() { - if in_svn; then - local root=$(LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p') - if svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then - # Grep exits with 0 when "One or more lines were selected", return "dirty". - echo $1 - else - # Otherwise, no lines were found, or an error occurred. Return clean. - echo $2 - fi + local root + root=$(sed -n 's/^Working Copy Root Path: //p' <<< "${1:-$(LANG= svn info 2>/dev/null)}") + if LANG= svn status "$root" 2>/dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then + # Grep exits with 0 when "One or more lines were selected", return "dirty". + echo $2 + else + # Otherwise, no lines were found, or an error occurred. Return clean. + echo $3 fi } @@ -75,13 +79,11 @@ svn_dirty_pwd () { } svn_dirty_choose_pwd () { - if in_svn; then - if svn status "$PWD" 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then - # Grep exits with 0 when "One or more lines were selected", return "dirty". - echo $1 - else - # Otherwise, no lines were found, or an error occurred. Return clean. - echo $2 - fi + if LANG= svn status "$PWD" 2>/dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then + # Grep exits with 0 when "One or more lines were selected", return "dirty". + echo $1 + else + # Otherwise, no lines were found, or an error occurred. Return clean. + echo $2 fi } diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index 551814a39..7348f77c9 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -15,20 +15,21 @@ The plugin also supports the following: ## Aliases -| Alias | Command | Description | -| ------ | -----------------------|---------------------------------------------------------- | -| `ta` | tmux attach -t | Attach new tmux session to already running named session | -| `tad` | tmux attach -d -t | Detach named tmux session | -| `ts` | tmux new-session -s | Create a new named tmux session | -| `tl` | tmux list-sessions | Displays a list of running tmux sessions | -| `tksv` | tmux kill-server | Terminate all running tmux sessions | -| `tkss` | tmux kill-session -t | Terminate named running tmux session | -| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session | +| Alias | Command | Description | +| ---------- | -------------------------- | -------------------------------------------------------- | +| `ta` | tmux attach -t | Attach new tmux session to already running named session | +| `tad` | tmux attach -d -t | Detach named tmux session | +| `ts` | tmux new-session -s | Create a new named tmux session | +| `tl` | tmux list-sessions | Displays a list of running tmux sessions | +| `tksv` | tmux kill-server | Terminate all running tmux sessions | +| `tkss` | tmux kill-session -t | Terminate named running tmux session | +| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session | +| `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor | ## Configuration Variables | Variable | Description | -|-------------------------------------|-------------------------------------------------------------------------------| +| ----------------------------------- | ----------------------------------------------------------------------------- | | `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) | | `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) | | `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) | diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 5474c3522..b9bb66d59 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -3,15 +3,6 @@ if ! (( $+commands[tmux] )); then return 1 fi -# ALIASES - -alias ta='tmux attach -t' -alias tad='tmux attach -d -t' -alias ts='tmux new-session -s' -alias tl='tmux list-sessions' -alias tksv='tmux kill-server' -alias tkss='tmux kill-session -t' - # CONFIGURATION VARIABLES # Automatically start tmux : ${ZSH_TMUX_AUTOSTART:=false} @@ -39,6 +30,16 @@ alias tkss='tmux kill-session -t' # Set -u option to support unicode : ${ZSH_TMUX_UNICODE:=false} +# ALIASES + +alias ta='tmux attach -t' +alias tad='tmux attach -d -t' +alias ts='tmux new-session -s' +alias tl='tmux list-sessions' +alias tksv='tmux kill-server' +alias tkss='tmux kill-session -t' +alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG' + # Determine if the terminal supports 256 colors if [[ $terminfo[colors] == 256 ]]; then export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index 989ffd1ff..7b765a406 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -53,7 +53,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' # Usage: aar ppa:xxxxxx/xxxxxx [packagename] # If packagename is not given as 2nd argument the function will ask for it and guess the default by taking # the part after the / from the ppa name which is sometimes the right name for the package you want to install -aar() { +function aar() { if [ -n "$2" ]; then PACKAGE=$2 else @@ -76,7 +76,7 @@ aar() { # apt-history rollback # apt-history list # Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html -apt-history () { +function apt-history() { case "$1" in install) zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) @@ -105,7 +105,7 @@ apt-history () { } # Kernel-package building shortcut -kerndeb () { +function kerndeb() { # temporarily unset MAKEFLAGS ( '-j3' will fail ) MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) print '$MAKEFLAGS set to '"'$MAKEFLAGS'" diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md index a1d6bc6b0..476666bf6 100644 --- a/plugins/vi-mode/README.md +++ b/plugins/vi-mode/README.md @@ -30,10 +30,10 @@ plugins=(... vi-mode) ``` - `MODE_INDICATOR`: controls the string displayed when the shell is in normal mode. - See [Mode indicator](#mode-indicator) for details. + See [Mode indicators](#mode-indicators) for details. - `INSERT_MODE_INDICATOR`: controls the string displayed when the shell is in insert mode. - See [Mode indicator](#mode-indicator) for details. + See [Mode indicators](#mode-indicators) for details. ## Mode indicators diff --git a/plugins/virtualenv/virtualenv.plugin.zsh b/plugins/virtualenv/virtualenv.plugin.zsh index 3041475ed..56707bb98 100644 --- a/plugins/virtualenv/virtualenv.plugin.zsh +++ b/plugins/virtualenv/virtualenv.plugin.zsh @@ -1,6 +1,6 @@ function virtualenv_prompt_info(){ [[ -n ${VIRTUAL_ENV} ]] || return - echo "${ZSH_THEME_VIRTUALENV_PREFIX=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX=]}" + echo "${ZSH_THEME_VIRTUALENV_PREFIX=[}${VIRTUAL_ENV:t:gs/%/%%}${ZSH_THEME_VIRTUALENV_SUFFIX=]}" } # disables prompt mangling in virtual_env/bin/activate diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index c30216f51..d359e0c21 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -56,7 +56,13 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_VIRTUAL_ENV" ]]; then # We've just left the repo, deactivate the environment # Note: this only happens if the virtualenv was activated automatically - deactivate && unset CD_VIRTUAL_ENV + if [[ -n "$VIRTUAL_ENV" ]]; then + # Only deactivate if VIRTUAL_ENV was set + # User may have deactivated manually or via another mechanism + deactivate + fi + # clean up regardless + unset CD_VIRTUAL_ENV fi if [[ "$ENV_NAME" != "" ]]; then # Activate the environment only if it is not already active diff --git a/plugins/volta/volta.plugin.zsh b/plugins/volta/volta.plugin.zsh index 756dc84b3..79319394c 100644 --- a/plugins/volta/volta.plugin.zsh +++ b/plugins/volta/volta.plugin.zsh @@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `deno`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_volta" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _volta _comps[volta]=_volta fi diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md index 9a0d1708d..9c16ff2c3 100644 --- a/plugins/yarn/README.md +++ b/plugins/yarn/README.md @@ -9,6 +9,15 @@ To use it, add `yarn` to the plugins array in your zshrc file: plugins=(... yarn) ``` +## Global scripts directory + +It also adds `yarn` global scripts dir (commonly `~/.yarn/bin`) to the `$PATH`. +To disable this feature, set the following style in your `.zshrc`: + +```zsh +zstyle ':omz:plugins:yarn' global-path false +``` + ## Aliases | Alias | Command | Description | diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn index 9db02602e..1237ba672 100644 --- a/plugins/yarn/_yarn +++ b/plugins/yarn/_yarn @@ -116,7 +116,7 @@ _yarn_commands_scripts() { fi if [[ -n $packageJson ]]; then - scripts=($(cat "$packageJson" | perl -0777 -MJSON::PP -n -E '%r=decode_json($_); say for sort keys %{$r->{scripts}}')) + scripts=($(cat "$packageJson" | perl -0777 -MJSON::PP -n -E '$r=decode_json($_); do{($k=$_)=~s/:/\\:/g;say $k}for sort keys %{$r->{scripts}}')) fi _describe 'command or script' _commands -- _global_commands -- scripts -- binaries @@ -144,7 +144,7 @@ _yarn_scripts() { fi if [[ -n $packageJson ]]; then - scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E '%r=%{decode_json($_)->{scripts}}; printf "$_:$r{$_}\n" for sort keys %r')}") + scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E '%r=%{decode_json($_)->{scripts}}; do{$k=$_;($e=$k)=~s/:/\\:/g; printf "$e:$r{$k}\n"} for sort keys %r')}") fi commands=('env' $scripts $binaries) diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh index 9ba24420a..bcb8661cf 100644 --- a/plugins/yarn/yarn.plugin.zsh +++ b/plugins/yarn/yarn.plugin.zsh @@ -1,12 +1,14 @@ -# Skip yarn call if default global bin dir exists -[[ -d "$HOME/.yarn/bin" ]] && bindir="$HOME/.yarn/bin" || bindir="$(yarn global bin 2>/dev/null)" +if zstyle -T ':omz:plugins:yarn' global-path; then + # Skip yarn call if default global bin dir exists + [[ -d "$HOME/.yarn/bin" ]] && bindir="$HOME/.yarn/bin" || bindir="$(yarn global bin 2>/dev/null)" -# Add yarn bin directory to $PATH if it exists and not already in $PATH -[[ $? -eq 0 ]] \ - && [[ -d "$bindir" ]] \ - && (( ! ${path[(Ie)$bindir]} )) \ - && path+=("$bindir") -unset bindir + # Add yarn bin directory to $PATH if it exists and not already in $PATH + [[ $? -eq 0 ]] \ + && [[ -d "$bindir" ]] \ + && (( ! ${path[(Ie)$bindir]} )) \ + && path+=("$bindir") + unset bindir +fi alias y="yarn" alias ya="yarn add" diff --git a/plugins/zsh_reload/README.md b/plugins/zsh_reload/README.md deleted file mode 100644 index 0b2e2a775..000000000 --- a/plugins/zsh_reload/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# zsh_reload plugin - -**This plugin is deprecated.** Use `omz reload` or `exec zsh` instead. diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh deleted file mode 100644 index 6a058ec5e..000000000 --- a/plugins/zsh_reload/zsh_reload.plugin.zsh +++ /dev/null @@ -1,7 +0,0 @@ -print ${(%):-"%F{yellow}The \`zsh_reload\` plugin is deprecated and will be removed."} -print ${(%):-"Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f"} - -src() { - print ${(%):-"%F{yellow}$0 is deprecated. Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f\n"} - omz reload -} |