From d997f114fabd4c15a9666bb7966ed2866bb69c8d Mon Sep 17 00:00:00 2001 From: DazAh <9095216+DazAh@users.noreply.github.com> Date: Sun, 13 Dec 2020 21:56:15 +0000 Subject: [PATCH] upgradeohmyzsh --- dot_zshrc | 2 +- exact_dot_oh-my-zsh/dot_editorconfig | 6 +- .../exact_cache/dot_zsh-update | 2 +- exact_dot_oh-my-zsh/exact_dot_git/FETCH_HEAD | 2 +- exact_dot_oh-my-zsh/exact_dot_git/ORIG_HEAD | 2 +- exact_dot_oh-my-zsh/exact_dot_git/config | 2 + .../exact_dot_git/exact_logs/HEAD | 9 + .../exact_logs/exact_refs/exact_heads/master | 3 + .../exact_remotes/exact_origin/master | 1 + .../exact_refs/exact_heads/master | 2 +- .../exact_remotes/exact_origin/master | 2 +- exact_dot_oh-my-zsh/exact_dot_git/index | Bin 92878 -> 92541 bytes .../exact_dot_github/CODEOWNERS | 9 +- .../exact_ISSUE_TEMPLATE/feature_request.md | 2 +- .../exact_ISSUE_TEMPLATE/support.md | 2 +- exact_dot_oh-my-zsh/exact_lib/functions.zsh | 14 +- exact_dot_oh-my-zsh/exact_lib/git.zsh | 25 +- exact_dot_oh-my-zsh/exact_lib/history.zsh | 4 +- .../exact_ansible/ansible.plugin.zsh | 4 +- .../exact_archlinux/archlinux.plugin.zsh | 18 +- .../exact_plugins/exact_aws/README.md | 41 +- .../exact_plugins/exact_aws/aws.plugin.zsh | 112 +- .../exact_battery/battery.plugin.zsh | 5 +- .../exact_colored-man-pages/README.md | 14 + .../colored-man-pages.plugin.zsh | 73 +- .../exact_colorize/colorize.plugin.zsh | 3 +- .../command-not-found.plugin.zsh | 24 +- .../exact_common-aliases/README.md | 4 +- .../common-aliases.plugin.zsh | 2 +- .../exact_composer/composer.plugin.zsh | 2 +- .../exact_plugins/exact_fzf/fzf.plugin.zsh | 4 +- .../exact_git-auto-fetch/README.md | 45 +- .../git-auto-fetch.plugin.zsh | 81 +- .../exact_git-prompt/gitstatus.py | 4 +- .../exact_plugins/exact_git/git.plugin.zsh | 14 +- .../exact_plugins/exact_gitfast/_git | 218 +- .../exact_gitfast/executable_update | 11 +- .../exact_gitfast/git-completion.bash | 2275 ++++++++++------- .../exact_plugins/exact_gitfast/git-prompt.sh | 72 +- .../exact_plugins/exact_hanami/README.md | 61 +- .../exact_hanami/hanami.plugin.zsh | 6 +- .../exact_magic-enter/magic-enter.plugin.zsh | 53 +- .../exact_plugins/exact_sudo/sudo.plugin.zsh | 52 +- .../exact_plugins/exact_terraform/_terraform | 228 +- .../exact_plugins/exact_thefuck/README.md | 4 + .../exact_plugins/exact_wp-cli/README.md | 204 +- .../exact_wp-cli/wp-cli.plugin.zsh | 51 +- .../exact_tools/check_for_upgrade.sh | 110 +- .../exact_tools/executable_install.sh | 365 +-- exact_dot_oh-my-zsh/exact_tools/upgrade.sh | 82 - private_dot_config/nvim/init.vim | 2 + private_dot_config/private_pulse/daemon.conf | 7 +- 52 files changed, 2509 insertions(+), 1831 deletions(-) delete mode 100644 exact_dot_oh-my-zsh/exact_tools/upgrade.sh diff --git a/dot_zshrc b/dot_zshrc index 3ea61a2..099decb 100644 --- a/dot_zshrc +++ b/dot_zshrc @@ -70,7 +70,7 @@ ZSH_THEME="agnoster" # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. -plugins=(git npm fd docker-compose docker zsh-autosuggestions) +plugins=(git npm fd zsh-autosuggestions) source $ZSH/oh-my-zsh.sh # User configuration diff --git a/exact_dot_oh-my-zsh/dot_editorconfig b/exact_dot_oh-my-zsh/dot_editorconfig index aa18e0e..b5321de 100644 --- a/exact_dot_oh-my-zsh/dot_editorconfig +++ b/exact_dot_oh-my-zsh/dot_editorconfig @@ -4,7 +4,5 @@ root = true end_of_line = lf insert_final_newline = true charset = utf-8 - -[*.sh] -indent_size = 4 -indent_style = tab +indent_size = 2 +indent_style = space diff --git a/exact_dot_oh-my-zsh/exact_cache/dot_zsh-update b/exact_dot_oh-my-zsh/exact_cache/dot_zsh-update index 2912a9e..f73442a 100644 --- a/exact_dot_oh-my-zsh/exact_cache/dot_zsh-update +++ b/exact_dot_oh-my-zsh/exact_cache/dot_zsh-update @@ -1 +1 @@ -LAST_EPOCH=18360 +LAST_EPOCH=18558 diff --git a/exact_dot_oh-my-zsh/exact_dot_git/FETCH_HEAD b/exact_dot_oh-my-zsh/exact_dot_git/FETCH_HEAD index 8d08d39..45f5576 100644 --- a/exact_dot_oh-my-zsh/exact_dot_git/FETCH_HEAD +++ b/exact_dot_oh-my-zsh/exact_dot_git/FETCH_HEAD @@ -1 +1 @@ -3b1699b59527ee8095397b9909a37d55689a0481 branch 'master' of https://github.com/ohmyzsh/ohmyzsh +2a0ae3315db98d137de547e2cb9adfbc38263e6c branch 'master' of https://github.com/ohmyzsh/ohmyzsh diff --git a/exact_dot_oh-my-zsh/exact_dot_git/ORIG_HEAD b/exact_dot_oh-my-zsh/exact_dot_git/ORIG_HEAD index 7880203..9e85b81 100644 --- a/exact_dot_oh-my-zsh/exact_dot_git/ORIG_HEAD +++ b/exact_dot_oh-my-zsh/exact_dot_git/ORIG_HEAD @@ -1 +1 @@ -fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 +db4fc1fcfe07b7bbc882e3850d9c94c88181374b diff --git a/exact_dot_oh-my-zsh/exact_dot_git/config b/exact_dot_oh-my-zsh/exact_dot_git/config index 191e3df..5a4eaef 100644 --- a/exact_dot_oh-my-zsh/exact_dot_git/config +++ b/exact_dot_oh-my-zsh/exact_dot_git/config @@ -17,3 +17,5 @@ zeroPaddedFilemode = ignore [receive "fsck"] zeroPaddedFilemode = ignore +[oh-my-zsh] + lastVersion = b81dd43a0baf3d3984955a6547a7a6b4ac4757c0 diff --git a/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/HEAD b/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/HEAD index 2ee8c5e..8f78ba2 100644 --- a/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/HEAD +++ b/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/HEAD @@ -29,3 +29,12 @@ e38099de96e8b62976354b468da1b21ec2d57f68 52f58785645c18aa88ea515d070a42bcfe97508 486857f709aa2fa229391097651e043b62d316e5 fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 DazAh <9095216+DazAh@users.noreply.github.com> 1587285078 +0100 rebase (pick): commit message fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 DazAh <9095216+DazAh@users.noreply.github.com> 1587285078 +0100 rebase (finish): returning to refs/heads/master fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 b4c49847e4ac5e235056165350c3a4be46244ce3 DazAh <9095216+DazAh@users.noreply.github.com> 1603487324 +0100 pull: Merge made by the 'recursive' strategy. +b4c49847e4ac5e235056165350c3a4be46244ce3 3b1699b59527ee8095397b9909a37d55689a0481 DazAh <9095216+DazAh@users.noreply.github.com> 1603488161 +0100 pull --rebase --stat origin master (start): checkout 3b1699b59527ee8095397b9909a37d55689a0481 +3b1699b59527ee8095397b9909a37d55689a0481 e196f4412dc9a2216df1418b662ad4b07cd71ff8 DazAh <9095216+DazAh@users.noreply.github.com> 1603488162 +0100 pull --rebase --stat origin master (pick): deleted: cache/.gitkeep +e196f4412dc9a2216df1418b662ad4b07cd71ff8 db4fc1fcfe07b7bbc882e3850d9c94c88181374b DazAh <9095216+DazAh@users.noreply.github.com> 1603488162 +0100 pull --rebase --stat origin master (pick): commit message +db4fc1fcfe07b7bbc882e3850d9c94c88181374b db4fc1fcfe07b7bbc882e3850d9c94c88181374b DazAh <9095216+DazAh@users.noreply.github.com> 1603488162 +0100 pull --rebase --stat origin master (finish): returning to refs/heads/master +db4fc1fcfe07b7bbc882e3850d9c94c88181374b b81dd43a0baf3d3984955a6547a7a6b4ac4757c0 DazAh <9095216+DazAh@users.noreply.github.com> 1607896397 +0000 pull: Merge made by the 'recursive' strategy. +b81dd43a0baf3d3984955a6547a7a6b4ac4757c0 2a0ae3315db98d137de547e2cb9adfbc38263e6c DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (start): checkout 2a0ae3315db98d137de547e2cb9adfbc38263e6c +2a0ae3315db98d137de547e2cb9adfbc38263e6c b4ec9d8125e9ec565706ed32ab82434dd8f8d7dc DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (pick): deleted: cache/.gitkeep +b4ec9d8125e9ec565706ed32ab82434dd8f8d7dc 9366d477c4e361a30c32b9210db378cbe83a9f86 DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (pick): commit message +9366d477c4e361a30c32b9210db378cbe83a9f86 9366d477c4e361a30c32b9210db378cbe83a9f86 DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (finish): returning to refs/heads/master diff --git a/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/exact_refs/exact_heads/master b/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/exact_refs/exact_heads/master index 6b3f569..d4629bf 100644 --- a/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/exact_refs/exact_heads/master +++ b/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/exact_refs/exact_heads/master @@ -22,3 +22,6 @@ e38099de96e8b62976354b468da1b21ec2d57f68 52f58785645c18aa88ea515d070a42bcfe97508 11ccf2bbf21a52536b408095af0e25574c7e62f5 5fc3c3fca4eb259cbb2a68435a11a8fffec6539f DazAh <9095216+DazAh@users.noreply.github.com> 1587285072 +0100 commit: commit message 5fc3c3fca4eb259cbb2a68435a11a8fffec6539f fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 DazAh <9095216+DazAh@users.noreply.github.com> 1587285078 +0100 rebase (finish): refs/heads/master onto 31eca46ee3b94ca84a038628e0bf6089a7488908 fab59ebc3d2ce439a70bd7a68a987c0a895b2ca0 b4c49847e4ac5e235056165350c3a4be46244ce3 DazAh <9095216+DazAh@users.noreply.github.com> 1603487324 +0100 pull: Merge made by the 'recursive' strategy. +b4c49847e4ac5e235056165350c3a4be46244ce3 db4fc1fcfe07b7bbc882e3850d9c94c88181374b DazAh <9095216+DazAh@users.noreply.github.com> 1603488162 +0100 pull --rebase --stat origin master (finish): refs/heads/master onto 3b1699b59527ee8095397b9909a37d55689a0481 +db4fc1fcfe07b7bbc882e3850d9c94c88181374b b81dd43a0baf3d3984955a6547a7a6b4ac4757c0 DazAh <9095216+DazAh@users.noreply.github.com> 1607896397 +0000 pull: Merge made by the 'recursive' strategy. +b81dd43a0baf3d3984955a6547a7a6b4ac4757c0 9366d477c4e361a30c32b9210db378cbe83a9f86 DazAh <9095216+DazAh@users.noreply.github.com> 1607896412 +0000 pull --rebase --stat origin master (finish): refs/heads/master onto 2a0ae3315db98d137de547e2cb9adfbc38263e6c diff --git a/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/exact_refs/exact_remotes/exact_origin/master b/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/exact_refs/exact_remotes/exact_origin/master index 7b9984f..2c6e754 100644 --- a/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/exact_refs/exact_remotes/exact_origin/master +++ b/exact_dot_oh-my-zsh/exact_dot_git/exact_logs/exact_refs/exact_remotes/exact_origin/master @@ -19,3 +19,4 @@ e38099de96e8b62976354b468da1b21ec2d57f68 52f58785645c18aa88ea515d070a42bcfe97508 3e4d10c4f17b2fe57090a524d5d78781beda204a 05a38c8b99ea5bc54e7fdfc1cc1ea6d2729c05e5 DazAh <9095216+DazAh@users.noreply.github.com> 1580316594 +0000 pull --rebase --stat origin master: fast-forward 05a38c8b99ea5bc54e7fdfc1cc1ea6d2729c05e5 31eca46ee3b94ca84a038628e0bf6089a7488908 DazAh <9095216+DazAh@users.noreply.github.com> 1587285078 +0100 pull --rebase --stat origin master: fast-forward 31eca46ee3b94ca84a038628e0bf6089a7488908 3b1699b59527ee8095397b9909a37d55689a0481 DazAh <9095216+DazAh@users.noreply.github.com> 1603487324 +0100 pull: fast-forward +3b1699b59527ee8095397b9909a37d55689a0481 2a0ae3315db98d137de547e2cb9adfbc38263e6c DazAh <9095216+DazAh@users.noreply.github.com> 1607896397 +0000 pull: fast-forward diff --git a/exact_dot_oh-my-zsh/exact_dot_git/exact_refs/exact_heads/master b/exact_dot_oh-my-zsh/exact_dot_git/exact_refs/exact_heads/master index 7e41bb8..55d97c2 100644 --- a/exact_dot_oh-my-zsh/exact_dot_git/exact_refs/exact_heads/master +++ b/exact_dot_oh-my-zsh/exact_dot_git/exact_refs/exact_heads/master @@ -1 +1 @@ -b4c49847e4ac5e235056165350c3a4be46244ce3 +9366d477c4e361a30c32b9210db378cbe83a9f86 diff --git a/exact_dot_oh-my-zsh/exact_dot_git/exact_refs/exact_remotes/exact_origin/master b/exact_dot_oh-my-zsh/exact_dot_git/exact_refs/exact_remotes/exact_origin/master index 2c32bce..ca6db4a 100644 --- a/exact_dot_oh-my-zsh/exact_dot_git/exact_refs/exact_remotes/exact_origin/master +++ b/exact_dot_oh-my-zsh/exact_dot_git/exact_refs/exact_remotes/exact_origin/master @@ -1 +1 @@ -3b1699b59527ee8095397b9909a37d55689a0481 +2a0ae3315db98d137de547e2cb9adfbc38263e6c diff --git a/exact_dot_oh-my-zsh/exact_dot_git/index b/exact_dot_oh-my-zsh/exact_dot_git/index index 02f5c8147a6d226485767e559a42bdbcdf38a3a4..24a758571311930de1b28b1d04de970655fb34b0 100644 GIT binary patch delta 4336 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 delta 4080 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 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color" - fi - - # Run update script - env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh" - # Update last updated file - zmodload zsh/datetime - echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update" - # Remove update lock if it exists - command rm -rf "$ZSH/log/update.lock" + echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color" + omz update } function take() { @@ -134,6 +125,7 @@ zmodload zsh/langinfo # -P causes spaces to be encoded as '%20' instead of '+' function omz_urlencode() { emulate -L zsh + local -a opts zparseopts -D -E -a opts r m P local in_str=$1 diff --git a/exact_dot_oh-my-zsh/exact_lib/git.zsh b/exact_dot_oh-my-zsh/exact_lib/git.zsh index 53d3960..157c850 100644 --- a/exact_dot_oh-my-zsh/exact_lib/git.zsh +++ b/exact_dot_oh-my-zsh/exact_lib/git.zsh @@ -9,14 +9,27 @@ function __git_prompt_git() { GIT_OPTIONAL_LOCKS=0 command git "$@" } -# Outputs current branch info in prompt format function git_prompt_info() { - local ref - if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then - ref=$(__git_prompt_git symbolic-ref HEAD 2> /dev/null) || \ - ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return 0 - echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + # If we are on a folder not tracked by git, get out. + # Otherwise, check for hide-info at global and local repository level + if ! __git_prompt_git rev-parse --git-dir &> /dev/null \ + || [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then + return 0 fi + + local ref + ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \ + || ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \ + || return 0 + + # Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info + local upstream + if (( ${+ZSH_THEME_GIT_SHOW_UPSTREAM} )); then + upstream=$(__git_prompt_git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}" 2>/dev/null) \ + && upstream=" -> ${upstream}" + fi + + echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref}${upstream}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" } # Checks if working tree is dirty diff --git a/exact_dot_oh-my-zsh/exact_lib/history.zsh b/exact_dot_oh-my-zsh/exact_lib/history.zsh index 8d922a3..7940769 100644 --- a/exact_dot_oh-my-zsh/exact_lib/history.zsh +++ b/exact_dot_oh-my-zsh/exact_lib/history.zsh @@ -6,7 +6,8 @@ function omz_history { if [[ -n "$clear" ]]; then # if -c provided, clobber the history file echo -n >| "$HISTFILE" - echo >&2 History file deleted. Reload the session to see its effects. + fc -p "$HISTFILE" + echo >&2 History file deleted. elif [[ -n "$list" ]]; then # if -l provided, run as if calling `fc' directly builtin fc "$@" @@ -36,3 +37,4 @@ setopt hist_expire_dups_first # delete duplicates first when HISTFILE size excee setopt hist_ignore_dups # ignore duplicated commands history list setopt hist_ignore_space # ignore commands that start with space setopt hist_verify # show command with history expansion to user before running it +setopt share_history # share command history data diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_ansible/ansible.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_ansible/ansible.plugin.zsh index f68ff23..75393b7 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_ansible/ansible.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_ansible/ansible.plugin.zsh @@ -4,7 +4,7 @@ function ansible-version(){ } function ansible-role-init(){ - if ! [ -z $1] ; then + if ! [ -z $1 ] ; then echo "Ansible Role : $1 Creating...." ansible-galaxy init $1 tree $1 @@ -25,4 +25,4 @@ alias ainv='ansible-inventory ' alias adoc='ansible-doc ' alias agal='ansible-galaxy ' alias apull='ansible-pull ' -alias aval='ansible-vault' \ No newline at end of file +alias aval='ansible-vault' diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_archlinux/archlinux.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_archlinux/archlinux.plugin.zsh index 4d39bd8..c72e06d 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_archlinux/archlinux.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_archlinux/archlinux.plugin.zsh @@ -171,14 +171,13 @@ function paclist() { } function pacdisowned() { - emulate -L zsh - + local tmp db fs tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$ db=$tmp/db fs=$tmp/fs mkdir "$tmp" - trap 'rm -rf "$tmp"' EXIT + trap 'rm -rf "$tmp"' EXIT pacman -Qlq | sort -u > "$db" @@ -189,15 +188,14 @@ function pacdisowned() { } function pacmanallkeys() { - emulate -L zsh curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \ awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \ xargs sudo pacman-key --recv-keys } function pacmansignkeys() { - emulate -L zsh - for key in $*; do + local key + for key in $@; do sudo pacman-key --recv-keys $key sudo pacman-key --lsign-key $key printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \ @@ -207,13 +205,13 @@ function pacmansignkeys() { if (( $+commands[xdg-open] )); then function pacweb() { - pkg="$1" - infos="$(LANG=C pacman -Si "$pkg")" + local pkg="$1" + local infos="$(LANG=C pacman -Si "$pkg")" if [[ -z "$infos" ]]; then return fi - repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')" - arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')" + local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')" + local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')" xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null } fi diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_aws/README.md b/exact_dot_oh-my-zsh/exact_plugins/exact_aws/README.md index 57c3b54..011bbd8 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_aws/README.md +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_aws/README.md @@ -15,6 +15,13 @@ plugins=(... aws) It also sets `$AWS_EB_PROFILE` to `` for the Elastic Beanstalk CLI. Run `asp` without arguments to clear the profile. +* `acp []`: in addition to `asp` functionality, it actually changes the profile by + assuming the role specified in the `` 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. + * `agp`: gets the current value of `$AWS_PROFILE`. * `aws_change_access_key`: changes the AWS access key of a profile. @@ -33,6 +40,36 @@ plugins=(... aws) The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays the current `$AWS_PROFILE`. It uses two variables to control how that is shown: -- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to ``. +* ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`. + +## Configuration + +[Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS + +### Scenario: IAM roles with a source profile and MFA authentication + +Source profile credentials in `~/.aws/credentials`: + +``` +[source-profile-name] +aws_access_key_id = ... +aws_secret_access_key = ... +``` + +Role configuration in `~/.aws/config`: + +``` +[profile source-profile-name] +mfa_serial = arn:aws:iam::111111111111:mfa/myuser +region = us-east-1 +output = json + +[profile profile-with-role] +role_arn = arn:aws:iam::9999999999999:role/myrole +mfa_serial = arn:aws:iam::111111111111:mfa/myuser +source_profile = source-profile-name +region = us-east-1 +output = json +``` diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_aws/aws.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_aws/aws.plugin.zsh index 7994963..e1566b1 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_aws/aws.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_aws/aws.plugin.zsh @@ -23,31 +23,131 @@ function asp() { export AWS_EB_PROFILE=$1 } +# AWS profile switch +function acp() { + if [[ -z "$1" ]]; then + unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE + unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN + echo AWS profile cleared. + return + fi + + local -a available_profiles + available_profiles=($(aws_profiles)) + if [[ -z "${available_profiles[(r)$1]}" ]]; then + echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2 + echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2 + return 1 + fi + + local profile="$1" + + # 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)" + local aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $profile)" + local aws_session_token="$(aws configure get aws_session_token --profile $profile)" + + + # First, if the profile has MFA configured, lets get the token and session duration + local mfa_serial="$(aws configure get mfa_serial --profile $profile)" + local sess_duration="$(aws configure get duration_seconds --profile $profile)" + + 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 "$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 + fi + mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}") + + # Now see whether we need to just MFA for the current role, or assume a different one + local role_arn="$(aws configure get role_arn --profile $profile)" + local sess_name="$(aws configure get role_session_name --profile $profile)" + + if [[ -n "$role_arn" ]]; then + # Means we need to assume a specified role + aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}") + + # Check whether external_id is configured to use while assuming the role + local external_id="$(aws configure get external_id --profile $profile)" + if [[ -n "$external_id" ]]; then + aws_command+=(--external-id "$external_id") + fi + + # Get source profile to use to assume role + local source_profile="$(aws configure get source_profile --profile $profile)" + if [[ -z "$sess_name" ]]; then + sess_name="${source_profile:-profile}" + fi + aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}") + + echo "Assuming role $role_arn using profile ${source_profile:-profile}" + else + # Means we only need to do MFA + aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}") + echo "Obtaining session token for profile $profile" + fi + + # Format output of aws command for easier processing + aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text) + + # Run the aws command to obtain credentials + local -a credentials + credentials=(${(ps:\t:)"$(${aws_command[@]})"}) + + if [[ -n "$credentials" ]]; then + aws_access_key_id="${credentials[1]}" + aws_secret_access_key="${credentials[2]}" + aws_session_token="${credentials[3]}" + fi + fi + + # Switch to AWS profile + if [[ -n "${aws_access_key_id}" && -n "$aws_secret_access_key" ]]; then + export AWS_DEFAULT_PROFILE="$profile" + export AWS_PROFILE="$profile" + export AWS_EB_PROFILE="$profile" + export AWS_ACCESS_KEY_ID="$aws_access_key_id" + export AWS_SECRET_ACCESS_KEY="$aws_secret_access_key" + + if [[ -n "$aws_session_token" ]]; then + export AWS_SESSION_TOKEN="$aws_session_token" + else + unset AWS_SESSION_TOKEN + fi + + echo "Switched to AWS Profile: $profile" + fi +} + function aws_change_access_key() { if [[ -z "$1" ]]; then echo "usage: $0 " return 1 fi - echo Insert the credentials when asked. + echo "Insert the credentials when asked." asp "$1" || return 1 AWS_PAGER="" aws iam create-access-key AWS_PAGER="" aws configure --profile "$1" - echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\` - echo Your current keys are: + echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`" + echo "Your current keys are:" AWS_PAGER="" aws iam list-access-keys } function aws_profiles() { [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 - grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9@_\.-]*\).*/\1/' + grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([-_[:alnum:]\.@]+)\][[:space:]]*$/\2/g' } function _aws_profiles() { reply=($(aws_profiles)) } -compctl -K _aws_profiles asp aws_change_access_key +compctl -K _aws_profiles asp acp aws_change_access_key # AWS prompt function aws_prompt_info() { @@ -55,7 +155,7 @@ function aws_prompt_info() { echo "${ZSH_THEME_AWS_PREFIX:=}" } -if [ "$SHOW_AWS_PROMPT" != false ]; then +if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then RPROMPT='$(aws_prompt_info)'"$RPROMPT" fi diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_battery/battery.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_battery/battery.plugin.zsh index 755ec8d..a525fd7 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_battery/battery.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_battery/battery.plugin.zsh @@ -18,10 +18,7 @@ if [[ "$OSTYPE" = darwin* ]]; then } function battery_pct() { - local battery_status="$(ioreg -rc AppleSmartBattery)" - local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status) - local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status) - echo $(( current * 100 / capacity )) + pmset -g batt | grep -Eo "\d+%" | cut -d% -f1 } function battery_pct_remaining() { diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_colored-man-pages/README.md b/exact_dot_oh-my-zsh/exact_plugins/exact_colored-man-pages/README.md index f34941e..4cbf64d 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_colored-man-pages/README.md +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_colored-man-pages/README.md @@ -16,3 +16,17 @@ You can also try to color other pages by prefixing the respective command with ` ```zsh colored git help clone ``` + +## Customization + +The plugin declares global associative array `less_termcap`, which maps termcap capabilities to escape +sequences for the `less` pager. This mapping can be further customized by the user after the plugin is +loaded. Check out sources for more. + +For example: `less_termcap[md]` maps to `LESS_TERMCAP_md` which is the escape sequence that tells `less` +how to print something in bold. It's currently shown in bold red, but if you want to change it, you +can redefine `less_termcap[md]` in your zshrc file, after OMZ is sourced: + +```zsh +less_termcap[md]="${fg_bold[blue]}" # this tells less to print bold text in bold blue +``` diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_colored-man-pages/colored-man-pages.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_colored-man-pages/colored-man-pages.plugin.zsh index ec51847..37faed6 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_colored-man-pages/colored-man-pages.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_colored-man-pages/colored-man-pages.plugin.zsh @@ -1,39 +1,48 @@ -if [[ "$OSTYPE" = solaris* ]] -then - if [[ ! -x "$HOME/bin/nroff" ]] - then - mkdir -p "$HOME/bin" - cat > "$HOME/bin/nroff" <&2 + return 127 + fi + return 0 + } +fi # Arch Linux command-not-found support, you must have package pkgfile installed # https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook @@ -10,13 +25,12 @@ # Fedora command-not-found support if [ -f /usr/libexec/pk-command-not-found ]; then - command_not_found_handler () { + command_not_found_handler() { runcnf=1 retval=127 [ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0 [ ! -x /usr/libexec/packagekitd ] && runcnf=0 - if [ $runcnf -eq 1 ] - then + if [ $runcnf -eq 1 ]; then /usr/libexec/pk-command-not-found $@ retval=$? fi @@ -32,7 +46,7 @@ fi # NixOS command-not-found support if [ -x /run/current-system/sw/bin/command-not-found ]; then - command_not_found_handler () { + command_not_found_handler() { /run/current-system/sw/bin/command-not-found $@ } fi diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_common-aliases/README.md b/exact_dot_oh-my-zsh/exact_plugins/exact_common-aliases/README.md index d198a29..b6f34cb 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_common-aliases/README.md +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_common-aliases/README.md @@ -40,11 +40,13 @@ plugins=(... common-aliases) | Alias | Command | Description | |-------|-----------------------------------------------------|-----------------------------------------| -| fd | `find . -type d -name` | Find a directory with the given name | +| fd\* | `find . -type d -name` | Find a directory with the given name | | ff | `find . -type f -name` | Find a file with the given name | | grep | `grep --color` | Searches for a query string | | sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files | +\* Only if the [`fd`](https://github.com/sharkdp/fd) command isn't installed. + ### Other Aliases | Alias | Command | Description | diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_common-aliases/common-aliases.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_common-aliases/common-aliases.plugin.zsh index a9d4f1a..4e5ff84 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_common-aliases/common-aliases.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_common-aliases/common-aliases.plugin.zsh @@ -34,7 +34,7 @@ alias -g P="2>&1| pygmentize -l pytb" alias dud='du -d 1 -h' alias duf='du -sh *' -alias fd='find . -type d -name' +(( $+commands[fd] )) || alias fd='find . -type d -name' alias ff='find . -type f -name' alias h='history' diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_composer/composer.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_composer/composer.plugin.zsh index 75b03ff..218a13e 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_composer/composer.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_composer/composer.plugin.zsh @@ -51,7 +51,7 @@ alias cget='curl -s https://getcomposer.org/installer | php' # Add Composer's global binaries to PATH, using Composer if available. if (( $+commands[composer] )); then - autoload -Uz _store_cache _retrieve_cache + autoload -Uz _store_cache _retrieve_cache _cache_invalid _retrieve_cache composer diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_fzf/fzf.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_fzf/fzf.plugin.zsh index 2f48215..5240899 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_fzf/fzf.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_fzf/fzf.plugin.zsh @@ -154,10 +154,10 @@ unset -f setup_using_opensuse_package setup_using_debian_package setup_using_bas if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then if (( $+commands[rg] )); then - export FZF_DEFAULT_COMMAND='rg --files --hidden' + export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"' elif (( $+commands[fd] )); then export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git' elif (( $+commands[ag] )); then - export FZF_DEFAULT_COMMAND='ag -l --hidden -g ""' + export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git' fi fi diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_git-auto-fetch/README.md b/exact_dot_oh-my-zsh/exact_plugins/exact_git-auto-fetch/README.md index 35f3c2f..e96ab42 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_git-auto-fetch/README.md +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_git-auto-fetch/README.md @@ -1,26 +1,29 @@ # Git auto-fetch -Automatically fetches all changes from all remotes while you are working in git-initialized directory. +Automatically fetches all changes from all remotes while you are working in a git-initialized directory. -#### Usage - -Add `git-auto-fetch` to the plugins array in your zshrc file: +To use it, add `git-auto-fetch` to the plugins array in your zshrc file: ```shell plugins=(... git-auto-fetch) ``` -Every time you launch a command in your shell all remotes will be fetched in background. -By default autofetch will be triggered only if last fetch was done at least 60 seconds ago. -You can change fetch interval in your .zshrc: -``` -GIT_AUTO_FETCH_INTERVAL=1200 #in seconds -``` -Log of `git fetch --all` will be saved into `.git/FETCH_LOG` +## Usage +Every time the command prompt is shown all remotes will be fetched in the background. By default, +`git-auto-fetch` will be triggered only if the last auto-fetch was done at least 60 seconds ago. +You can change the fetch interval in your .zshrc: -#### Toggle auto fetch per folder -If you are using mobile connection or for any other reason you can disable git-auto-fetch for any folder: +```sh +GIT_AUTO_FETCH_INTERVAL=1200 # in seconds +``` + +A log of `git fetch --all` will be saved in `.git/FETCH_LOG`. + +## Toggle auto-fetch per folder + +If you are using a mobile connection or for any other reason you can disable git-auto-fetch +for any folder: ```shell $ cd to/your/project @@ -29,3 +32,19 @@ disabled $ git-auto-fetch enabled ``` + +## Caveats + +Automatically fetching all changes defeats the purpose of `git push --force-with-lease`, +and makes it behave like `git push --force` in some cases. For example: + +Consider that you made some changes and possibly rebased some stuff, which means you'll +need to use `--force-with-lease` to overwrite the remote history of a branch. Between the +time when you make the changes (maybe do a `git log`) and the time when you `git push`, +it's possible that someone else updates the branch you're working on. + +If `git-auto-fetch` triggers then, you'll have fetched the remote changes without knowing +it, and even though you're running the push with `--force-with-lease`, git will overwrite +the recent changes because you already have them in your local repository. The +[`git push --force-with-lease` docs](https://git-scm.com/docs/git-push) talk about possible +solutions to this problem. diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_git-auto-fetch/git-auto-fetch.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_git-auto-fetch/git-auto-fetch.plugin.zsh index 5c42c21..0da84f2 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_git-auto-fetch/git-auto-fetch.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_git-auto-fetch/git-auto-fetch.plugin.zsh @@ -1,36 +1,61 @@ -GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60} +# Default auto-fetch interval: 60 seconds +: ${GIT_AUTO_FETCH_INTERVAL:=60} + +# Necessary for the git-fetch-all function +zmodload zsh/datetime zsh/stat function git-fetch-all { - (`command git rev-parse --is-inside-work-tree 2>/dev/null` && - dir=`command git rev-parse --git-dir` && - [[ ! -f $dir/NO_AUTO_FETCH ]] && - (( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) && - GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \ - command git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &) + ( + # Get git root directory + if ! gitdir="$(command git rev-parse --git-dir 2>/dev/null)"; then + return 0 + fi + + # Do nothing if auto-fetch disabled + if [[ -z "$gitdir" || -f "$gitdir/NO_AUTO_FETCH" ]]; then + return 0 + fi + + # Get time (seconds) when auto-fetch was last run + lastrun="$(zstat +mtime "$gitdir/FETCH_LOG" 2>/dev/null || echo 0)" + # Do nothing if not enough time has passed since last auto-fetch + if (( EPOCHSECONDS - lastrun < $GIT_AUTO_FETCH_INTERVAL )); then + return 0 + fi + + # Fetch all remotes (avoid ssh passphrase prompt) + GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \ + command git fetch --all 2>/dev/null &>! "$gitdir/FETCH_LOG" + ) &| } function git-auto-fetch { - `command git rev-parse --is-inside-work-tree 2>/dev/null` || return - guard="`command git rev-parse --git-dir`/NO_AUTO_FETCH" + # Do nothing if not in a git repository + command git rev-parse --is-inside-work-tree &>/dev/null || return 0 - (rm $guard 2>/dev/null && - echo "${fg_bold[green]}enabled${reset_color}") || - (touch $guard && - echo "${fg_bold[red]}disabled${reset_color}") + # Remove or create guard file depending on its existence + local guard="$(command git rev-parse --git-dir)/NO_AUTO_FETCH" + if [[ -f "$guard" ]]; then + command rm "$guard" && echo "${fg_bold[green]}enabled${reset_color}" + else + command touch "$guard" && echo "${fg_bold[red]}disabled${reset_color}" + fi } -# Override zle-line-init if it exists -if (( $+functions[zle-line-init] )); then - eval "override-git-auto-fetch-$(declare -f zle-line-init)" - - function zle-line-init () { - git-fetch-all - override-git-auto-fetch-zle-line-init - } -else - function zle-line-init () { - git-fetch-all - } -fi - -zle -N zle-line-init +# zle-line-init widget (don't redefine if already defined) +(( ! ${+functions[_git-auto-fetch_zle-line-init]} )) || return 0 + +case "$widgets[zle-line-init]" in + # Simply define the function if zle-line-init doesn't yet exist + builtin|"") function _git-auto-fetch_zle-line-init() { + git-fetch-all + } ;; + # Override the current zle-line-init widget, calling the old one + user:*) zle -N _git-auto-fetch_orig_zle-line-init "${widgets[zle-line-init]#user:}" + function _git-auto-fetch_zle-line-init() { + git-fetch-all + zle _git-auto-fetch_orig_zle-line-init -- "$@" + } ;; +esac + +zle -N zle-line-init _git-auto-fetch_zle-line-init diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_git-prompt/gitstatus.py b/exact_dot_oh-my-zsh/exact_plugins/exact_git-prompt/gitstatus.py index 300365d..bf31736 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_git-prompt/gitstatus.py +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_git-prompt/gitstatus.py @@ -11,11 +11,11 @@ def get_tagname_or_hash(): """return tagname if exists else hash""" # get hash hash_cmd = ['git', 'rev-parse', '--short', 'HEAD'] - hash_ = check_output(hash_cmd).strip() + hash_ = check_output(hash_cmd).decode('utf-8').strip() # get tagname tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '--format=%(refname:short)', 'refs/tags'] - tags = check_output(tags_cmd).split() + tags = check_output(tags_cmd).decode('utf-8').split() if tags: return tags[0] + ('+' if len(tags) > 1 else '') diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_git/git.plugin.zsh b/exact_dot_oh-my-zsh/exact_plugins/exact_git/git.plugin.zsh index ccb9d84..e32136f 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_git/git.plugin.zsh +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_git/git.plugin.zsh @@ -31,11 +31,15 @@ function work_in_progress() { # Check if main exists and use instead of master function git_main_branch() { - if [[ -n "$(git branch --list main)" ]]; then - echo main - else - echo master - fi + command git rev-parse --git-dir &>/dev/null || return + local branch + for branch in main trunk; do + if command git show-ref -q --verify refs/heads/$branch; then + echo $branch + return + fi + done + echo master } # diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/_git b/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/_git index 78a6dbb..988f5b1 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/_git +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/_git @@ -2,25 +2,24 @@ # zsh completion wrapper for git # -# Copyright (c) 2012-2013 Felipe Contreras +# Copyright (c) 2012-2020 Felipe Contreras # -# You need git's bash completion script installed somewhere, by default it -# would be the location bash-completion uses. +# The recommended way to install this script is to make a copy of it as a +# file named '_git' inside any directory in your fpath. # -# If your script is somewhere else, you can configure it on your ~/.zshrc: -# -# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh -# -# The recommended way to install this script is to copy to '~/.zsh/_git', and -# then add the following to your ~/.zshrc file: +# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git', +# and then add the following to your ~/.zshrc file: # # fpath=(~/.zsh $fpath) - -complete () -{ - # do nothing - return 0 -} +# +# You need git's bash completion script installed. By default bash-completion's +# location will be used (e.g. pkg-config --variable=completionsdir bash-completion). +# +# If your bash completion script is somewhere else, you can specify the +# location in your ~/.zshrc: +# +# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash +# zstyle -T ':completion:*:*:git:*' tag-order && \ zstyle ':completion:*:*:git:*' tag-order 'common-commands' @@ -28,18 +27,32 @@ zstyle -T ':completion:*:*:git:*' tag-order && \ zstyle -s ":completion:*:*:git:*" script script if [ -z "$script" ]; then local -a locations - local e + local e bash_completion + + bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) || + bash_completion='/usr/share/bash-completion/completions/' + locations=( - "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash" - '/etc/bash_completion.d/git' # fedora, old debian - '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian - '/usr/share/bash-completion/git' # gentoo + "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash + "$HOME/.local/share/bash-completion/completions/git" + "$bash_completion/git" + '/etc/bash_completion.d/git' # old debian ) for e in $locations; do test -f $e && script="$e" && break done fi -ZSH_VERSION='' . "$script" + +local old_complete="$functions[complete]" +functions[complete]=: +COMP_WORDBREAKS=':' +GIT_SOURCING_ZSH_COMPLETION=y . "$script" +functions[complete]="$old_complete" + +__gitcompadd () +{ + compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0 +} __gitcomp () { @@ -47,59 +60,85 @@ __gitcomp () local cur_="${3-$cur}" - case "$cur_" in - --*=) - ;; - *) - local c IFS=$' \t\n' - local -a array - for c in ${=1}; do - c="$c${4-}" + [[ "$cur_" == *= ]] && return + + local c IFS=$' \t\n' sfx + for c in ${=1}; do + if [[ $c == "--" ]]; then + [[ "$cur_" == --no-* ]] && continue + __gitcompadd "--no-..." + break + fi + + if [[ -z "${4-}" ]]; then case $c in - --*=*|*.) ;; - *) c="$c " ;; + *=) c="${c%=}"; sfx="=" ;; + *.) sfx="" ;; + *) sfx=" " ;; esac - array+=("$c") - done - compset -P '*[=:]' - compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 - ;; - esac -} - -__gitcomp_direct () -{ - emulate -L zsh - - local IFS=$'\n' - compset -P '*[=:]' - compadd -Q -- ${=1} && _ret=0 + else + sfx="$4" + fi + __gitcompadd "$c" "${2-}" "$sfx" -q + done } __gitcomp_nl () { emulate -L zsh - local IFS=$'\n' - compset -P '*[=:]' - compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 -} - -__gitcomp_nl_append () -{ - emulate -L zsh - - local IFS=$'\n' - compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 + IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }" } __gitcomp_file () { emulate -L zsh - local IFS=$'\n' + compadd -f -p "${2-}" -- ${(f)1} && _ret=0 +} + +__gitcomp_direct () +{ + __gitcomp_nl "$1" "" "" "" +} + +__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 + compset -P '*[=:]' - compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 + + local command="$1" + local completion_func="_git_${command//-/_}" + if (( $+functions[$completion_func] )); then + emulate ksh -c $completion_func + return 0 + elif emulate ksh -c "__git_support_parseopt_helper $command"; then + emulate ksh -c "__git_complete_common $command" + return 0 + else + return 1 + fi } __git_zsh_bash_func () @@ -108,14 +147,12 @@ __git_zsh_bash_func () local command=$1 - local completion_func="_git_${command//-/_}" - declare -f $completion_func >/dev/null && $completion_func && return + __git_complete_command "$command" && return local expansion=$(__git_aliased_command "$command") if [ -n "$expansion" ]; then words[1]=$expansion - completion_func="_git_${expansion//-/_}" - declare -f $completion_func >/dev/null && $completion_func + __git_complete_command "$expansion" fi } @@ -140,9 +177,11 @@ __git_zsh_cmd_common () push:'update remote refs along with associated objects' rebase:'forward-port local commits to the updated upstream head' reset:'reset current HEAD to the specified state' + restore:'restore working tree files' rm:'remove files from the working tree and from the index' show:'show various types of objects' status:'show the working tree status' + switch:'switch branches' tag:'create, list, delete or verify a tag object signed with GPG') _describe -t common-commands 'common commands' list && _ret=0 } @@ -150,8 +189,9 @@ __git_zsh_cmd_common () __git_zsh_cmd_alias () { local -a list - list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*}) - _describe -t alias-commands 'aliases' list $* && _ret=0 + list=(${${(0)"$(git config -z --get-regexp '^alias\.*')"}#alias.}) + list=(${(f)"$(printf "%s:alias for '%s'\n" ${(f@)list})"}) + _describe -t alias-commands 'aliases' list && _ret=0 } __git_zsh_cmd_all () @@ -166,33 +206,43 @@ __git_zsh_main () { local curcontext="$curcontext" state state_descr line typeset -A opt_args - local -a orig_words + local -a orig_words __git_C_args orig_words=( ${words[@]} ) _arguments -C \ - '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ - '(-p --paginate)--no-pager[do not pipe git output into a pager]' \ - '--git-dir=-[set the path to the repository]: :_directories' \ - '--bare[treat the repository as a bare repository]' \ + '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ + '(-p --paginate -P --no-pager)'{-P,--no-pager}'[do not pipe git output into a pager]' \ + '(--bare)--git-dir=[set the path to the repository]: :_directories' \ + '(--git-dir)--bare[treat the repository as a bare repository]' \ '(- :)--version[prints the git suite version]' \ - '--exec-path=-[path to where your core git programs are installed]:: :_directories' \ - '--html-path[print the path where git''s HTML documentation is installed]' \ - '--info-path[print the path where the Info files are installed]' \ - '--man-path[print the manpath (see `man(1)`) for the man pages]' \ - '--work-tree=-[set the path to the working tree]: :_directories' \ - '--namespace=-[set the git namespace]' \ + '--exec-path=[path to where your core git programs are installed]: :_directories' \ + '(- :)--exec-path[print the path where your core git programs are installed]' \ + '(- :)--html-path[print the path where git''s HTML documentation is installed]' \ + '(- :)--info-path[print the path where the Info files are installed]' \ + '(- :)--man-path[print the manpath (see `man(1)`) for the man pages]' \ + '--work-tree=[set the path to the working tree]: :_directories' \ + '--namespace=[set the git namespace]:' \ '--no-replace-objects[do not use replacement refs to replace git objects]' \ '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \ + '*-C[run as if git was started in the given path]: :_directories' \ + '*-c[pass a configuration parameter to the command]: :->config' \ '(-): :->command' \ '(-)*:: :->arg' && return case $state in (command) - _alternative \ - 'alias-commands:alias:__git_zsh_cmd_alias' \ - 'common-commands:common:__git_zsh_cmd_common' \ - 'all-commands:all:__git_zsh_cmd_all' && _ret=0 + _tags common-commands alias-commands all-commands + while _tags; do + _requested common-commands && __git_zsh_cmd_common + _requested alias-commands && __git_zsh_cmd_alias + _requested all-commands && __git_zsh_cmd_all + let _ret || break + done + ;; + (config) + compset -P '*[=:]' + emulate ksh -c __git_complete_config_variable_name_and_value ;; (arg) local command="${words[1]}" __git_dir @@ -200,9 +250,13 @@ __git_zsh_main () if (( $+opt_args[--bare] )); then __git_dir='.' else - __git_dir=${opt_args[--git-dir]} + __git_dir=${~opt_args[--git-dir]} fi + for x in ${(s.:.)opt_args[-C]}; do + __git_C_args+=('-C' ${~x}) + done + (( $+opt_args[--help] )) && command='help' words=( ${orig_words[@]} ) @@ -227,6 +281,8 @@ _git () emulate ksh -c __${service}_main elif (( $+functions[_${service}] )); then emulate ksh -c _${service} + elif (( $+functions[_${service//-/_}] )); then + emulate ksh -c _${service//-/_} fi let _ret && _default && _ret=0 diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/executable_update b/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/executable_update index 0505424..5311065 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/executable_update +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/executable_update @@ -1,9 +1,8 @@ #!/bin/sh -url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion" -version="2.16.0" +url="https://raw.githubusercontent.com/felipec/git-completion" +version="1.2" -curl -s -o _git "${url}/git-completion.zsh?h=v${version}" && -curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" && -curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" && -git apply updates.patch +curl -s -o _git "${url}/v${version}/git-completion.zsh" && +curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" && +curl -s -o git-prompt.sh "${url}/v${version}/git-prompt.sh" diff --git a/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/git-completion.bash b/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/git-completion.bash index b6ff5dc..4497a29 100644 --- a/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/git-completion.bash +++ b/exact_dot_oh-my-zsh/exact_plugins/exact_gitfast/git-completion.bash @@ -29,25 +29,28 @@ # tell the completion to use commit completion. This also works with aliases # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". # +# Compatible with bash 3.2.57. +# # You can set the following environment variables to influence the behavior of # the completion routines: # # GIT_COMPLETION_CHECKOUT_NO_GUESS # # When set to "1", do not include "DWIM" suggestions in git-checkout -# completion (e.g., completing "foo" when "origin/foo" exists). - -case "$COMP_WORDBREAKS" in -*:*) : great ;; -*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" -esac +# and git-switch completion (e.g., completing "foo" when "origin/foo" +# exists). +# +# GIT_COMPLETION_SHOW_ALL +# +# When set to "1" suggest all options, including options which are +# typically hidden (e.g. '--allow-empty' for 'git commit'). # Discovers the path to the git repository taking any '--git-dir=' and # '-C ' options into account and stores it in the $__git_repo_path # variable. __git_find_repo_path () { - if [ -n "$__git_repo_path" ]; then + if [ -n "${__git_repo_path-}" ]; then # we already know where it is return fi @@ -92,6 +95,70 @@ __git () ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null } +# Removes backslash escaping, single quotes and double quotes from a word, +# stores the result in the variable $dequoted_word. +# 1: The word to dequote. +__git_dequote () +{ + local rest="$1" len ch + + dequoted_word="" + + while test -n "$rest"; do + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%[\\\'\"]*}" + rest="${rest:$((${#dequoted_word}-$len))}" + + case "${rest:0:1}" in + \\) + ch="${rest:1:1}" + case "$ch" in + $'\n') + ;; + *) + dequoted_word="$dequoted_word$ch" + ;; + esac + rest="${rest:2}" + ;; + \') + rest="${rest:1}" + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%\'*}" + rest="${rest:$((${#dequoted_word}-$len+1))}" + ;; + \") + rest="${rest:1}" + while test -n "$rest" ; do + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%[\\\"]*}" + rest="${rest:$((${#dequoted_word}-$len))}" + case "${rest:0:1}" in + \\) + ch="${rest:1:1}" + case "$ch" in + \"|\\|\$|\`) + dequoted_word="$dequoted_word$ch" + ;; + $'\n') + ;; + *) + dequoted_word="$dequoted_word\\$ch" + ;; + esac + rest="${rest:2}" + ;; + \") + rest="${rest:1}" + break + ;; + esac + done + ;; + esac + done +} + # The following function is based on code from: # # bash_completion - programmable completion functions for bash 3.2+ @@ -234,6 +301,19 @@ __gitcomp_direct () 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[@]} @@ -262,15 +342,38 @@ __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" @@ -280,6 +383,163 @@ __gitcomp () esac } +# Clear the variables caching builtins' options when (re-)sourcing +# the completion script. +if [[ -n ${ZSH_VERSION-} ]]; then + unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null +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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_get_default () +{ + eval "test -n \"\$${1}_default\" && echo \"\$${1}_default\"" +} + +# This function is equivalent to +# +# __gitcomp "$(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 +# 2: extra options to be added on top (e.g. negative forms) +# 3: options to be excluded +__gitcomp_builtin () +{ + # spaces must be replaced with underscore for multi-word + # commands, e.g. "git remote add" becomes remote_add. + local cmd="$1" + local incl="${2-}" + local excl="${3-}" + + local var=__gitcomp_builtin_"${cmd//-/_}" + local options + eval "options=\${$var-}" + + if [ -z "$options" ]; then + local completion_helper + if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then + completion_helper="--git-completion-helper-all" + else + completion_helper="--git-completion-helper" + fi + completion="$(__git ${cmd/_/ } $completion_helper || + __gitcomp_builtin_get_default $var)" || return + # leading and trailing spaces are significant to make + # option removal work correctly. + options=" $incl $completion " + + for i in $excl; do + options="${options/ $i / }" + done + eval "$var=\"$options\"" + fi + + __gitcomp "$options" +} + # Variation of __gitcomp_nl () that appends to the existing list of # completion candidates, COMPREPLY. __gitcomp_nl_append () @@ -303,6 +563,24 @@ __gitcomp_nl () __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: @@ -322,7 +600,8 @@ __gitcomp_file () # 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 + compgen -f /non-existing-dir/ >/dev/null || + true } # Execute 'git ls-files', unless the --committable option is specified, in @@ -332,10 +611,12 @@ __gitcomp_file () __git_ls_files_helper () { if [ "$2" == "--committable" ]; then - __git -C "$1" diff-index --name-only --relative HEAD + __git -C "$1" -c core.quotePath=false diff-index \ + --name-only --relative HEAD -- "${3//\\/\\\\}*" else # NOTE: $2 is not quoted in order to support multiple options - __git -C "$1" ls-files --exclude-standard $2 + __git -C "$1" -c core.quotePath=false ls-files \ + --exclude-standard $2 -- "${3//\\/\\\\}*" fi } @@ -346,17 +627,103 @@ __git_ls_files_helper () # If provided, only files within the specified directory are listed. # Sub directories are never recursed. Path must have a trailing # slash. +# 3: List only paths matching this path component (optional). __git_index_files () { - local root="${2-.}" file + local root="$2" match="$3" - __git_ls_files_helper "$root" "$1" | - while read -r file; do - case "$file" in - ?*/*) echo "${file%%/*}" ;; - *) echo "$file" ;; - esac - done | sort | uniq + __git_ls_files_helper "$root" "$1" "${match:-?}" | + awk -F / -v pfx="${2//\\/\\\\}" '{ + paths[$1] = 1 + } + END { + for (p in paths) { + if (substr(p, 1, 1) != "\"") { + # No special characters, easy! + print pfx p + continue + } + + # The path is quoted. + p = dequote(p) + if (p == "") + continue + + # Even when a directory name itself does not contain + # any special characters, it will still be quoted if + # any of its (stripped) trailing path components do. + # Because of this we may have seen the same directory + # both quoted and unquoted. + if (p in paths) + # We have seen the same directory unquoted, + # skip it. + continue + else + print pfx p + } + } + function dequote(p, bs_idx, out, esc, esc_idx, dec) { + # Skip opening double quote. + p = substr(p, 2) + + # Interpret backslash escape sequences. + while ((bs_idx = index(p, "\\")) != 0) { + out = out substr(p, 1, bs_idx - 1) + esc = substr(p, bs_idx + 1, 1) + p = substr(p, bs_idx + 2) + + if ((esc_idx = index("abtvfr\"\\", esc)) != 0) { + # C-style one-character escape sequence. + out = out substr("\a\b\t\v\f\r\"\\", + esc_idx, 1) + } else if (esc == "n") { + # Uh-oh, a newline character. + # We cannot reliably put a pathname + # containing a newline into COMPREPLY, + # and the newline would create a mess. + # Skip this path. + return "" + } else { + # Must be a \nnn octal value, then. + dec = esc * 64 + \ + substr(p, 1, 1) * 8 + \ + substr(p, 2, 1) + out = out sprintf("%c", dec) + p = substr(p, 3) + } + } + # Drop closing double quote, if there is one. + # (There is not any if this is a directory, as it was + # already stripped with the trailing path components.) + if (substr(p, length(p), 1) == "\"") + out = out substr(p, 1, length(p) - 1) + else + out = out p + + return out + }' +} + +# __git_complete_index_file requires 1 argument: +# 1: the options to pass to ls-file +# +# The exception is --committable, which finds the files appropriate commit. +__git_complete_index_file () +{ + local dequoted_word pfx="" cur_ + + __git_dequote "$cur" + + case "$dequoted_word" in + ?*/*) + pfx="${dequoted_word%/*}/" + cur_="${dequoted_word##*/}" + ;; + *) + cur_="$dequoted_word" + esac + + __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")" } # Lists branches from the local repository. @@ -372,6 +739,19 @@ __git_heads () "refs/heads/$cur_*" "refs/heads/$cur_*/**" } +# Lists branches from remote repositories. +# 1: A prefix to be added to each listed branch (optional). +# 2: List only branches matching this word (optional; list all branches if +# unset or empty). +# 3: A suffix to be appended to each listed branch (optional). +__git_remote_heads () +{ + local pfx="${1-}" cur_="${2-}" sfx="${3-}" + + __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ + "refs/remotes/$cur_*" "refs/remotes/$cur_*/**" +} + # Lists tags from the local repository. # Accepts the same positional parameters as __git_heads() above. __git_tags () @@ -382,6 +762,26 @@ __git_tags () "refs/tags/$cur_*" "refs/tags/$cur_*/**" } +# List unique branches from refs/remotes used for 'git checkout' and 'git +# switch' tracking DWIMery. +# 1: A prefix to be added to each listed branch (optional) +# 2: List only branches matching this word (optional; list all branches if +# unset or empty). +# 3: A suffix to be appended to each listed branch (optional). +__git_dwim_remote_heads () +{ + local pfx="${1-}" cur_="${2-}" sfx="${3-}" + local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers + + # employ the heuristic used by git checkout and git switch + # Try to find a remote branch that cur_es the completion word + # but only output if the branch name is unique + __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ + --sort="refname:strip=3" \ + "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \ + uniq -u +} + # Lists refs from the local (by default) or from a remote repository. # It accepts 0, 1 or 2 arguments: # 1: The remote to list refs from (optional; ignored, if set but empty). @@ -439,7 +839,7 @@ __git_refs () track="" ;; *) - for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do case "$i" in $match*) if [ -e "$dir/$i" ]; then @@ -457,13 +857,7 @@ __git_refs () __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \ "${refs[@]}" if [ -n "$track" ]; then - # employ the heuristic used by git checkout - # Try to find a remote branch that matches the completion word - # but only output if the branch name is unique - __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ - --sort="refname:strip=3" \ - "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \ - uniq -u + __git_dwim_remote_heads "$pfx" "$match" "$sfx" fi return fi @@ -510,29 +904,51 @@ __git_refs () # Usage: __git_complete_refs [