summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2022-02-19 17:12:23 -0600
committerTuowen Zhao <ztuowen@gmail.com>2022-02-19 17:12:23 -0600
commitcae9a2b797649379e865e6bd73bc67e294e4ac77 (patch)
tree481419eff4bc761c3ca516704427394193473419
parent49edbf438ed690c76e6b2af80368c59404cf0167 (diff)
parent3427da4057dbe302933a7b5b19b4e23bfb9d0969 (diff)
downloadzsh-cae9a2b797649379e865e6bd73bc67e294e4ac77.tar.gz
zsh-cae9a2b797649379e865e6bd73bc67e294e4ac77.tar.bz2
zsh-cae9a2b797649379e865e6bd73bc67e294e4ac77.zip
Merge remote-tracking branch 'origin/master'
-rw-r--r--.github/workflows/main.yml1
-rw-r--r--.github/workflows/project.yml131
-rw-r--r--LICENSE.txt2
-rw-r--r--README.md2
-rw-r--r--lib/cli.zsh94
-rw-r--r--lib/git.zsh2
-rw-r--r--lib/nvm.zsh2
-rw-r--r--lib/vcs_info.zsh50
-rw-r--r--oh-my-zsh.sh71
-rw-r--r--plugins/1password/1password.plugin.zsh46
-rw-r--r--plugins/1password/README.md35
-rw-r--r--plugins/aws/README.md8
-rw-r--r--plugins/aws/aws.plugin.zsh12
-rw-r--r--plugins/colored-man-pages/colored-man-pages.plugin.zsh2
-rw-r--r--plugins/deno/deno.plugin.zsh2
-rw-r--r--plugins/django/README.md12
-rw-r--r--plugins/django/django.plugin.zsh407
-rw-r--r--plugins/dotenv/dotenv.plugin.zsh9
-rw-r--r--plugins/fd/README.md4
-rw-r--r--plugins/fd/_fd9
-rw-r--r--plugins/fig/README.md9
-rw-r--r--plugins/fig/fig.plugin.zsh13
-rw-r--r--plugins/fnm/fnm.plugin.zsh2
-rw-r--r--plugins/fossil/fossil.plugin.zsh32
-rw-r--r--plugins/frontend-search/frontend-search.plugin.zsh32
-rw-r--r--plugins/gh/gh.plugin.zsh2
-rw-r--r--plugins/git/git.plugin.zsh4
-rw-r--r--plugins/gitfast/_git46
-rw-r--r--plugins/gitfast/git-completion.bash1007
-rw-r--r--plugins/gitfast/git-prompt.sh7
-rwxr-xr-xplugins/gitfast/update2
-rw-r--r--plugins/helm/helm.plugin.zsh14
-rw-r--r--plugins/jenv/jenv.plugin.zsh10
-rw-r--r--plugins/juju/README.md43
-rw-r--r--plugins/juju/juju.plugin.zsh57
-rw-r--r--plugins/kubectl/kubectl.plugin.zsh40
-rw-r--r--plugins/kubectx/kubectx.plugin.zsh16
-rw-r--r--plugins/multipass/README.md22
-rw-r--r--plugins/multipass/_multipass73
-rw-r--r--plugins/multipass/multipass.plugin.zsh7
-rw-r--r--plugins/mvn/mvn.plugin.zsh2
-rw-r--r--plugins/npx/README.md25
-rw-r--r--plugins/npx/npx.plugin.zsh17
-rw-r--r--plugins/osx/osx.plugin.zsh4
-rw-r--r--plugins/pj/pj.plugin.zsh51
-rw-r--r--plugins/poetry/README.md9
-rw-r--r--plugins/poetry/poetry.plugin.zsh14
-rw-r--r--plugins/postgres/postgres.plugin.zsh15
-rw-r--r--plugins/pyenv/pyenv.plugin.zsh6
-rw-r--r--plugins/rbw/README.md10
-rw-r--r--plugins/rbw/rbw.plugin.zsh32
-rw-r--r--plugins/ripgrep/README.md4
-rw-r--r--plugins/ripgrep/_ripgrep4
-rw-r--r--plugins/rust/rust.plugin.zsh6
-rw-r--r--plugins/rvm/rvm.plugin.zsh2
-rw-r--r--plugins/sudo/README.md16
-rw-r--r--plugins/sudo/sudo.plugin.zsh57
-rw-r--r--plugins/svn-fast-info/svn-fast-info.plugin.zsh40
-rw-r--r--plugins/svn/svn.plugin.zsh112
-rw-r--r--plugins/tmux/README.md21
-rw-r--r--plugins/tmux/tmux.plugin.zsh19
-rw-r--r--plugins/ubuntu/ubuntu.plugin.zsh6
-rw-r--r--plugins/vi-mode/README.md4
-rw-r--r--plugins/virtualenv/virtualenv.plugin.zsh2
-rw-r--r--plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh8
-rw-r--r--plugins/volta/volta.plugin.zsh2
-rw-r--r--plugins/yarn/README.md9
-rw-r--r--plugins/yarn/_yarn4
-rw-r--r--plugins/yarn/yarn.plugin.zsh18
-rw-r--r--plugins/zsh_reload/README.md3
-rw-r--r--plugins/zsh_reload/zsh_reload.plugin.zsh7
-rw-r--r--themes/Soliah.zsh-theme4
-rw-r--r--themes/agnoster.zsh-theme17
-rw-r--r--themes/avit.zsh-theme2
-rw-r--r--themes/bureau.zsh-theme89
-rw-r--r--themes/candy-kingdom.zsh-theme4
-rw-r--r--themes/dieter.zsh-theme2
-rw-r--r--themes/dogenpunk.zsh-theme4
-rw-r--r--themes/emotty.zsh-theme10
-rw-r--r--themes/fino-time.zsh-theme5
-rw-r--r--themes/fino.zsh-theme4
-rw-r--r--themes/jonathan.zsh-theme2
-rw-r--r--themes/rkj-repos.zsh-theme2
-rw-r--r--themes/simple.zsh-theme10
-rw-r--r--themes/smt.zsh-theme2
-rw-r--r--themes/trapd00r.zsh-theme2
-rw-r--r--themes/wedisagree.zsh-theme4
-rw-r--r--themes/ys.zsh-theme10
-rwxr-xr-xtools/changelog.sh42
-rw-r--r--tools/check_for_upgrade.sh86
-rwxr-xr-xtools/install.sh188
-rwxr-xr-xtools/upgrade.sh50
92 files changed, 1852 insertions, 1555 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 7ab7efdd6..cdadc1434 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -14,6 +14,7 @@ jobs:
tests:
name: Run tests
runs-on: ${{ matrix.os }}
+ if: github.repository == 'ohmyzsh/ohmyzsh'
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml
new file mode 100644
index 000000000..800761554
--- /dev/null
+++ b/.github/workflows/project.yml
@@ -0,0 +1,131 @@
+name: Project tracking
+on:
+ issues:
+ types: [opened]
+ pull_request_target:
+ types: [opened, synchronize]
+
+jobs:
+ add-to-project:
+ name: Add to project
+ runs-on: ubuntu-latest
+ if: github.repository == 'ohmyzsh/ohmyzsh'
+ env:
+ GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }}
+ steps:
+ - name: Read project data
+ env:
+ ORGANIZATION: ohmyzsh
+ PROJECT_NUMBER: "1"
+ run: |
+ # Get Project data
+ gh api graphql -f query='
+ query($org: String!, $number: Int!) {
+ organization(login: $org){
+ projectNext(number: $number) {
+ id
+ fields(first:20) {
+ nodes {
+ id
+ name
+ }
+ }
+ }
+ }
+ }
+ ' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
+
+ # Parse project data
+ cat >> $GITHUB_ENV <<EOF
+ PROJECT_ID=$(jq '.data.organization.projectNext.id' project_data.json)
+ PLUGIN_FIELD_ID=$(jq '.data.organization.projectNext.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
+ THEME_FIELD_ID=$(jq '.data.organization.projectNext.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
+ EOF
+
+ - name: Add to project
+ env:
+ ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }}
+ run: |
+ item_id="$(gh api graphql -f query='
+ mutation($project: ID!, $content: ID!) {
+ addProjectNextItem(input: {projectId: $project, contentId: $content}) {
+ projectNextItem {
+ id
+ }
+ }
+ }
+ ' -f project=$PROJECT_ID -f content=$ISSUE_OR_PR_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
+
+ echo "ITEM_ID=$item_id" >> $GITHUB_ENV
+
+ - name: Classify Pull Request
+ if: github.event_name == 'pull_request_target'
+ run: |
+ touch plugins.list themes.list
+
+ gh pr view ${{ github.event.pull_request.number }} \
+ --repo ${{ github.repository }} \
+ --json files --jq '.files.[].path' | awk -F/ '
+ /^plugins\// {
+ plugins[$2] = 1
+ }
+ /^themes\// {
+ gsub(/\.zsh-theme$/, "", $2)
+ themes[$2] = 1
+ }
+ END {
+ for (plugin in plugins) {
+ print plugin >> "plugins.list"
+ }
+ for (theme in themes) {
+ print theme >> "themes.list"
+ }
+ }
+ '
+ # If only one plugin is modified, add it to the plugin field
+ if [[ $(wc -l < plugins.list) = 1 ]]; then
+ echo "PLUGIN=$(cat plugins.list)" >> $GITHUB_ENV
+ fi
+ # If only one theme is modified, add it to the theme field
+ if [[ $(wc -l < themes.list) = 1 ]]; then
+ echo "THEME=$(cat themes.list)" >> $GITHUB_ENV
+ fi
+
+ - name: Fill Pull Request fields in project
+ if: github.event_name == 'pull_request_target'
+ run: |
+ gh api graphql -f query='
+ mutation (
+ $project: ID!
+ $item: ID!
+ $plugin_field: ID!
+ $plugin_value: String!
+ $theme_field: ID!
+ $theme_value: String!
+ ) {
+ set_plugin: updateProjectNextItemField(input: {
+ projectId: $project
+ itemId: $item
+ fieldId: $plugin_field
+ value: $plugin_value
+ }) {
+ projectNextItem {
+ id
+ }
+ }
+ set_theme: updateProjectNextItemField(input: {
+ projectId: $project
+ itemId: $item
+ fieldId: $theme_field
+ value: $theme_value
+ }) {
+ projectNextItem {
+ id
+ }
+ }
+ }
+ ' -f project=$PROJECT_ID -f item=$ITEM_ID \
+ -f plugin_field=$PLUGIN_FIELD_ID -f plugin_value=$PLUGIN \
+ -f theme_field=$THEME_FIELD_ID -f theme_value=$THEME \
+ --silent
+
diff --git a/LICENSE.txt b/LICENSE.txt
index becd6a7bd..2d7ca6f52 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2009-2021 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
+Copyright (c) 2009-2022 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 94a200850..5a6b98443 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-<p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p>
+<p align="center"><img src="https://ohmyzsh.s3.amazonaws.com/omz-ansi-github.png" alt="Oh My Zsh"></p>
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.
diff --git a/lib/cli.zsh b/lib/cli.zsh
index 8cf8368e6..c2fba8556 100644
--- a/lib/cli.zsh
+++ b/lib/cli.zsh
@@ -37,7 +37,7 @@ function _omz {
elif (( CURRENT == 3 )); then
case "$words[2]" in
changelog) local -a refs
- refs=("${(@f)$(cd "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
+ refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
_describe 'command' refs ;;
plugin) subcmds=(
'disable:Disable plugin(s)'
@@ -61,7 +61,7 @@ function _omz {
# if command is "disable", only offer already enabled plugins
valid_plugins=($plugins)
else
- valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t))
+ valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
# if command is "enable", remove already enabled plugins
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi
@@ -69,11 +69,11 @@ function _omz {
_describe 'plugin' valid_plugins ;;
plugin::info)
local -aU plugins
- plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t))
+ plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
_describe 'plugin' plugins ;;
theme::(set|use))
local -aU themes
- themes=("$ZSH"/themes/*.zsh-theme(.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
+ themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
_describe 'theme' themes ;;
esac
elif (( CURRENT > 4 )); then
@@ -85,7 +85,7 @@ function _omz {
# if command is "disable", only offer already enabled plugins
valid_plugins=($plugins)
else
- valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t))
+ valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
# if command is "enable", remove already enabled plugins
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi
@@ -105,7 +105,10 @@ function _omz {
return 0
}
-compdef _omz omz
+# If run from a script, do not set the completion function
+if (( ${+functions[compdef]} )); then
+ compdef _omz omz
+fi
## Utility functions
@@ -176,13 +179,13 @@ function _omz::changelog {
local version=${1:-HEAD} format=${3:-"--text"}
if (
- cd "$ZSH"
+ builtin cd -q "$ZSH"
! command git show-ref --verify refs/heads/$version && \
! command git show-ref --verify refs/tags/$version && \
! command git rev-parse --verify "${version}^{commit}"
) &>/dev/null; then
cat >&2 <<EOF
-Usage: omz changelog [version]
+Usage: ${(j: :)${(s.::.)0#_}} [version]
NOTE: <version> must be a valid branch, tag or commit.
EOF
@@ -193,9 +196,9 @@ EOF
}
function _omz::plugin {
- (( $# > 0 && $+functions[_omz::plugin::$1] )) || {
+ (( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
-Usage: omz plugin <command> [options]
+Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
@@ -212,12 +215,12 @@ EOF
local command="$1"
shift
- _omz::plugin::$command "$@"
+ $0::$command "$@"
}
function _omz::plugin::disable {
if [[ -z "$1" ]]; then
- echo >&2 "Usage: omz plugin disable <plugin> [...]"
+ echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi
@@ -289,7 +292,7 @@ multi == 1 && length(\$0) > 0 {
}
# Exit if the new .zshrc file has syntax errors
- if ! zsh -n "$zdot/.zshrc"; then
+ if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
@@ -299,15 +302,13 @@ multi == 1 && length(\$0) > 0 {
# Restart the zsh session if there were no errors
_omz::log info "plugins disabled: ${(j:, :)dis_plugins}."
- # Old zsh versions don't have ZSH_ARGZERO
- local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
- # Check whether to run a login shell
- [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
+ # Only reload zsh if run in an interactive session
+ [[ ! -o interactive ]] || _omz::reload
}
function _omz::plugin::enable {
if [[ -z "$1" ]]; then
- echo >&2 "Usage: omz plugin enable <plugin> [...]"
+ echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi
@@ -365,7 +366,7 @@ multi == 1 && /^[^#]*\)/ {
}
# Exit if the new .zshrc file has syntax errors
- if ! zsh -n "$zdot/.zshrc"; then
+ if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
@@ -375,15 +376,13 @@ multi == 1 && /^[^#]*\)/ {
# Restart the zsh session if there were no errors
_omz::log info "plugins enabled: ${(j:, :)add_plugins}."
- # Old zsh versions don't have ZSH_ARGZERO
- local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
- # Check whether to run a login shell
- [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
+ # Only reload zsh if run in an interactive session
+ [[ ! -o interactive ]] || _omz::reload
}
function _omz::plugin::info {
if [[ -z "$1" ]]; then
- echo >&2 "Usage: omz plugin info <plugin>"
+ echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin>"
return 1
fi
@@ -430,7 +429,7 @@ function _omz::plugin::list {
function _omz::plugin::load {
if [[ -z "$1" ]]; then
- echo >&2 "Usage: omz plugin load <plugin> [...]"
+ echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi
@@ -477,9 +476,9 @@ function _omz::plugin::load {
}
function _omz::pr {
- (( $# > 0 && $+functions[_omz::pr::$1] )) || {
+ (( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
-Usage: omz pr <command> [options]
+Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
@@ -493,7 +492,7 @@ EOF
local command="$1"
shift
- _omz::pr::$command "$@"
+ $0::$command "$@"
}
function _omz::pr::clean {
@@ -534,7 +533,7 @@ function _omz::pr::test {
# Check the input
if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then
- echo >&2 "Usage: omz pr test <PR_NUMBER_or_URL>"
+ echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <PR_NUMBER_or_URL>"
return 1
fi
@@ -574,7 +573,7 @@ function _omz::pr::test {
# Rebase pull request branch against the current master
_omz::log info "rebasing PR #$1..."
- command git rebase master ohmyzsh/pull-$1 || {
+ command git rebase --no-gpg-sign master ohmyzsh/pull-$1 || {
command git rebase --abort &>/dev/null
_omz::log warn "could not rebase PR #$1 on top of master."
_omz::log warn "you might not see the latest stable changes."
@@ -619,9 +618,9 @@ function _omz::reload {
}
function _omz::theme {
- (( $# > 0 && $+functions[_omz::theme::$1] )) || {
+ (( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
-Usage: omz theme <command> [options]
+Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
@@ -636,7 +635,7 @@ EOF
local command="$1"
shift
- _omz::theme::$command "$@"
+ $0::$command "$@"
}
function _omz::theme::list {
@@ -671,7 +670,7 @@ function _omz::theme::list {
function _omz::theme::set {
if [[ -z "$1" ]]; then
- echo >&2 "Usage: omz theme set <theme>"
+ echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1
fi
@@ -721,7 +720,7 @@ EOF
}
# Exit if the new .zshrc file has syntax errors
- if ! zsh -n "$zdot/.zshrc"; then
+ if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
@@ -731,15 +730,13 @@ EOF
# Restart the zsh session if there were no errors
_omz::log info "'$1' theme set correctly."
- # Old zsh versions don't have ZSH_ARGZERO
- local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
- # Check whether to run a login shell
- [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
+ # Only reload zsh if run in an interactive session
+ [[ ! -o interactive ]] || _omz::reload
}
function _omz::theme::use {
if [[ -z "$1" ]]; then
- echo >&2 "Usage: omz theme use <theme>"
+ echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1
fi
@@ -761,13 +758,13 @@ function _omz::theme::use {
}
function _omz::update {
- local last_commit=$(cd "$ZSH"; git rev-parse HEAD)
+ local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
# Run update script
if [[ "$1" != --unattended ]]; then
- ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive || return $?
+ ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" --interactive || return $?
else
- ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" || return $?
+ ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" || return $?
fi
# Update last updated file
@@ -777,7 +774,7 @@ function _omz::update {
command rm -rf "$ZSH/log/update.lock"
# Restart the zsh session if there were changes
- if [[ "$1" != --unattended && "$(cd "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
+ if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
@@ -787,16 +784,17 @@ function _omz::update {
function _omz::version {
(
- cd "$ZSH"
+ builtin cd -q "$ZSH"
# Get the version name:
# 1) try tag-like version
- # 2) try name-rev
- # 3) try branch name
+ # 2) try branch name
+ # 3) try name-rev (tag~<rev> or branch~<rev>)
local version
version=$(command git describe --tags HEAD 2>/dev/null) \
+ || version=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null) \
|| version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" HEAD 2>/dev/null) \
- || version=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null)
+ || version="<detached>"
# Get short hash for the current HEAD
local commit=$(command git rev-parse --short HEAD 2>/dev/null)
diff --git a/lib/git.zsh b/lib/git.zsh
index 62aac8f39..be9fa7e67 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -82,7 +82,7 @@ function git_remote_status() {
fi
if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
- git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
+ git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX${remote:gs/%/%%}$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
fi
echo $git_remote_status
diff --git a/lib/nvm.zsh b/lib/nvm.zsh
index 2fe57a8f4..a8989f9fe 100644
--- a/lib/nvm.zsh
+++ b/lib/nvm.zsh
@@ -2,5 +2,5 @@
function nvm_prompt_info() {
which nvm &>/dev/null || return
local nvm_prompt=${$(nvm current)#v}
- echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
+ echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt:gs/%/%%}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
}
diff --git a/lib/vcs_info.zsh b/lib/vcs_info.zsh
new file mode 100644
index 000000000..01dcd90b6
--- /dev/null
+++ b/lib/vcs_info.zsh
@@ -0,0 +1,50 @@
+# Impacted versions go from v5.0.3 to v5.8 (v5.8.1 is the first patched version)
+autoload -Uz is-at-least
+if is-at-least 5.8.1 || ! is-at-least 5.0.3; then
+ return
+fi
+
+# Quote necessary $hook_com[<field>] items just before they are used
+# in the line "VCS_INFO_hook 'post-backend'" of the VCS_INFO_formats
+# function, where <field> is:
+#
+# base: the full path of the repository's root directory.
+# base-name: the name of the repository's root directory.
+# branch: the name of the currently checked out branch.
+# misc: a string that may contain anything the vcs_info backend wants.
+# revision: an identifier of the currently checked out revision.
+# subdir: the path of the current directory relative to the
+# repository's root directory.
+#
+# This patch %-quotes these fields previous to their use in vcs_info hooks and
+# the zformat call and, eventually, when they get expanded in the prompt.
+# It's important to quote these here, and not later after hooks have modified the
+# fields, because then we could be quoting % characters from valid prompt sequences,
+# like %F{color}, %B, etc.
+#
+# 32 │ hook_com[subdir]="$(VCS_INFO_reposub ${hook_com[base]})"
+# 33 │ hook_com[subdir_orig]="${hook_com[subdir]}"
+# 34 │
+# 35 + │ for tmp in base base-name branch misc revision subdir; do
+# 36 + │ hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"
+# 37 + │ done
+# 38 + │
+# 39 │ VCS_INFO_hook 'post-backend'
+#
+# This is especially important so that no command substitution is performed
+# due to malicious input as a consequence of CVE-2021-45444, which affects
+# zsh versions from 5.0.3 to 5.8.
+#
+autoload -Uz +X regexp-replace VCS_INFO_formats
+
+# We use $tmp here because it's already a local variable in VCS_INFO_formats
+typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
+# Unique string to avoid reapplying the patch if this code gets called twice
+typeset PATCH_ID=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b
+# Only patch the VCS_INFO_formats function if not already patched
+if [[ "$functions[VCS_INFO_formats]" != *$PATCH_ID* ]]; then
+ regexp-replace 'functions[VCS_INFO_formats]' \
+ "VCS_INFO_hook 'post-backend'" \
+ ': ${PATCH_ID}; ${PATCH}; ${MATCH}'
+fi
+unset PATCH PATCH_ID
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index b388b341d..ab32ee9d3 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -57,14 +57,14 @@ mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# Check for updates on initial load...
-if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
- source $ZSH/tools/check_for_upgrade.sh
+if [[ "$DISABLE_AUTO_UPDATE" != true ]]; then
+ source "$ZSH/tools/check_for_upgrade.sh"
fi
# Initializes Oh My Zsh
# add a function path
-fpath=($ZSH/functions $ZSH/completions $fpath)
+fpath=("$ZSH/functions" "$ZSH/completions" $fpath)
# Load all stock functions (from $fpath files) called below.
autoload -U compaudit compinit
@@ -75,7 +75,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom"
fi
-
is_plugin() {
local base_dir=$1
local name=$2
@@ -86,10 +85,10 @@ is_plugin() {
# Add all defined plugins to fpath. This must be done
# before running compinit.
for plugin ($plugins); do
- if is_plugin $ZSH_CUSTOM $plugin; then
- fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
- elif is_plugin $ZSH $plugin; then
- fpath=($ZSH/plugins/$plugin $fpath)
+ if is_plugin "$ZSH_CUSTOM" "$plugin"; then
+ fpath=("$ZSH_CUSTOM/plugins/$plugin" $fpath)
+ elif is_plugin "$ZSH" "$plugin"; then
+ fpath=("$ZSH/plugins/$plugin" $fpath)
else
echo "[oh-my-zsh] plugin '$plugin' not found"
fi
@@ -98,14 +97,14 @@ done
# Figure out the SHORT hostname
if [[ "$OSTYPE" = darwin* ]]; then
# macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
- SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
+ SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
else
- SHORT_HOST=${HOST/.*/}
+ SHORT_HOST="${HOST/.*/}"
fi
# Save the location of the current completion dump file.
-if [ -z "$ZSH_COMPDUMP" ]; then
- ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
+if [[ -z "$ZSH_COMPDUMP" ]]; then
+ ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi
# Construct zcompdump OMZ metadata
@@ -119,15 +118,15 @@ if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
zcompdump_refresh=1
fi
-if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
- source $ZSH/lib/compfix.zsh
+if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then
+ source "$ZSH/lib/compfix.zsh"
# If completion insecurities exist, warn the user
handle_completion_insecurities
# Load only from secure directories
- compinit -i -C -d "${ZSH_COMPDUMP}"
+ compinit -i -C -d "$ZSH_COMPDUMP"
else
# If the user wants it, load from all found directories
- compinit -u -C -d "${ZSH_COMPDUMP}"
+ compinit -u -C -d "$ZSH_COMPDUMP"
fi
# Append zcompdump metadata if missing
@@ -140,40 +139,48 @@ $zcompdump_revision
$zcompdump_fpath
EOF
fi
-
unset zcompdump_revision zcompdump_fpath zcompdump_refresh
-
# Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore
-for config_file ($ZSH/lib/*.zsh); do
- custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
- [ -f "${custom_config_file}" ] && config_file=${custom_config_file}
- source $config_file
+for config_file ("$ZSH"/lib/*.zsh); do
+ custom_config_file="$ZSH_CUSTOM/lib/${config_file:t}"
+ [[ -f "$custom_config_file" ]] && config_file="$custom_config_file"
+ source "$config_file"
done
+unset custom_config_file
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
- if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
- source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
- elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
- source $ZSH/plugins/$plugin/$plugin.plugin.zsh
+ if [[ -f "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh" ]]; then
+ source "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh"
+ elif [[ -f "$ZSH/plugins/$plugin/$plugin.plugin.zsh" ]]; then
+ source "$ZSH/plugins/$plugin/$plugin.plugin.zsh"
fi
done
+unset plugin
# Load all of your custom configurations from custom/
-for config_file ($ZSH_CUSTOM/*.zsh(N)); do
- source $config_file
+for config_file ("$ZSH_CUSTOM"/*.zsh(N)); do
+ source "$config_file"
done
unset config_file
# Load the theme
-if [ ! "$ZSH_THEME" = "" ]; then
- if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
+is_theme() {
+ local base_dir=$1
+ local name=$2
+ builtin test -f $base_dir/$name.zsh-theme
+}
+
+if [[ -n "$ZSH_THEME" ]]; then
+ if is_theme "$ZSH_CUSTOM" "$ZSH_THEME"; then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
- elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
+ elif is_theme "$ZSH_CUSTOM/themes" "$ZSH_THEME"; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
- else
+ elif is_theme "$ZSH/themes" "$ZSH_THEME"; then
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
+ else
+ echo "[oh-my-zsh] theme '$ZSH_THEME' not found"
fi
fi
diff --git a/plugins/1password/1password.plugin.zsh b/plugins/1password/1password.plugin.zsh
new file mode 100644
index 000000000..9398b02b4
--- /dev/null
+++ b/plugins/1password/1password.plugin.zsh
@@ -0,0 +1,46 @@
+if (( ${+commands[op]} )); then
+ eval "$(op completion zsh)"
+ compdef _op op
+fi
+
+# opswd puts the password of the named service into the clipboard. If there's a
+# one time password, it will be copied into the clipboard after 10 seconds. The
+# clipboard is cleared after another 20 seconds.
+function opswd() {
+ if [[ $# -lt 1 ]]; then
+ echo "Usage: opswd <service>"
+ return 1
+ fi
+
+ local service=$1
+
+ # If not logged in, print error and return
+ op list users > /dev/null || return
+
+ local password
+ # Copy the password to the clipboard
+ if ! password=$(op get item "$service" --fields password 2>/dev/null); then
+ echo "error: could not obtain password for $service"
+ return 1
+ fi
+
+ echo -n "$password" | clipcopy
+ echo "✔ password for $service copied to clipboard"
+
+ # If there's a one time password, copy it to the clipboard after 5 seconds
+ local totp
+ if totp=$(op get totp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
+ sleep 10 && echo -n "$totp" | clipcopy
+ echo "✔ TOTP for $service copied to clipboard"
+ fi
+
+ (sleep 20 && clipcopy </dev/null 2>/dev/null) &!
+}
+
+function _opswd() {
+ local -a services
+ services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
+ [[ -z "$services" ]] || compadd -a -- services
+}
+
+compdef _opswd opswd
diff --git a/plugins/1password/README.md b/plugins/1password/README.md
new file mode 100644
index 000000000..f6790ca8a
--- /dev/null
+++ b/plugins/1password/README.md
@@ -0,0 +1,35 @@
+# 1Password
+
+This plugin adds 1Password functionality to oh-my-zsh.
+
+To use, add `1password` to the list of plugins in your `.zshrc` file:
+
+```zsh
+plugins=(... 1password)
+```
+
+Then, you can use the command `opswd` to copy passwords for services into your
+clipboard.
+
+## `opswd`
+
+The `opswd` command is a wrapper around the `op` command. It takes a service
+name as an argument and copies the password for that service to the clipboard.
+
+If the service also contains a TOTP, it is copied to the clipboard after 10 seconds.
+Finally, after 20 seconds, the clipboard is cleared.
+
+The function has completion support, so you can use tab completion to select
+which service you want to get.
+
+For example, `opswd github.com` will put your GitHub password into your clipboard, and if
+a TOTP is available, it will be copied to the clipboard after 10 seconds.
+
+> NOTE: you need to be logged in for `opswd` to work. See:
+>
+> - [Sign in or out](https://support.1password.com/command-line/#sign-in-or-out)
+> - [Session management](https://support.1password.com/command-line/#appendix-session-management)
+
+## Requirements
+
+- [1Password's command line utility](https://1password.com/downloads/command-line/).
diff --git a/plugins/aws/README.md b/plugins/aws/README.md
index 24c6429dd..d6f4f4600 100644
--- a/plugins/aws/README.md
+++ b/plugins/aws/README.md
@@ -16,10 +16,10 @@ plugins=(... aws)
Run `asp` without arguments to clear the profile.
* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
-* `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by
- assuming the role specified in the `<profile>` configuration. It supports MFA and sets
- `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It
- requires the roles to be configured as per the
+* `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes
+ the profile by assuming the role specified in the `<profile>` configuration. It supports
+ MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if
+ obtained. It requires the roles to be configured as per the
[official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
Run `acp` without arguments to clear the profile.
diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh
index 3a3a111b4..920a7139d 100644
--- a/plugins/aws/aws.plugin.zsh
+++ b/plugins/aws/aws.plugin.zsh
@@ -45,6 +45,7 @@ function acp() {
fi
local profile="$1"
+ local mfa_token="$2"
# Get fallback credentials for if the aws command fails or no command is run
local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
@@ -58,9 +59,10 @@ function acp() {
if [[ -n "$mfa_serial" ]]; then
local -a mfa_opt
- local mfa_token
- echo -n "Please enter your MFA token for $mfa_serial: "
- read -r mfa_token
+ if [[ -z "$mfa_token" ]]; then
+ echo -n "Please enter your MFA token for $mfa_serial: "
+ read -r mfa_token
+ fi
if [[ -z "$sess_duration" ]]; then
echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
read -r sess_duration
@@ -155,8 +157,8 @@ compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt
function aws_prompt_info() {
- [[ -z $AWS_PROFILE ]] && return
- echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
+ [[ -n "$AWS_PROFILE" ]] || return
+ echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX:=>}"
}
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
index 087ddce97..981992d88 100644
--- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh
+++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
@@ -22,7 +22,7 @@ less_termcap[ue]="${reset_color}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Absolute path to this file's directory.
-typeset __colored_man_pages_dir="${0:A:h}"
+typeset -g __colored_man_pages_dir="${0:A:h}"
function colored() {
local -a environment
diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh
index 77c2125d2..6c12bae13 100644
--- a/plugins/deno/deno.plugin.zsh
+++ b/plugins/deno/deno.plugin.zsh
@@ -32,7 +32,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `deno`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then
- declare -A _comps
+ typeset -g -A _comps
autoload -Uz _deno
_comps[deno]=_deno
fi
diff --git a/plugins/django/README.md b/plugins/django/README.md
deleted file mode 100644
index cfab43980..000000000
--- a/plugins/django/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Django plugin
-
-This plugin adds completion for the [Django Project](https://www.djangoproject.com/) commands
-(`manage.py`, `django-admin`, ...).
-
-## Deprecation (2021-09-22)
-
-The plugin used to provide completion for `./manage.py` and `django-admin`, but Zsh already provides
-a better, more extensive completion for those, so this plugin is no longer needed.
-
-Right now a warning message is shown, but in the near future the plugin will stop working altogether.
-So you can remove it from your plugins and you'll automatically start using Zsh's django completion.
diff --git a/plugins/django/django.plugin.zsh b/plugins/django/django.plugin.zsh
deleted file mode 100644
index a07a30889..000000000
--- a/plugins/django/django.plugin.zsh
+++ /dev/null
@@ -1,407 +0,0 @@
-#compdef manage.py
-
-typeset -ga nul_args
-nul_args=(
- '--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))'
- '--settings=-[the Python path to a settings module.]:file:_files'
- '--pythonpath=-[a directory to add to the Python path.]:directory:_directories'
- '--traceback[print traceback on exception.]'
- "--no-color[Don't colorize the command output.]"
- "--version[show program's version number and exit.]"
- {-h,--help}'[show this help message and exit.]'
-)
-
-typeset -ga start_args
-start_args=(
- '--template=-[The path or URL to load the template from.]:directory:_directories'
- '--extension=-[The file extension(s) to render (default: "py").]'
- '--name=-[The file name(s) to render.]:file:_files'
-)
-
-typeset -ga db_args
-db_args=(
- '--database=-[Nominates a database. Defaults to the "default" database.]'
-)
-
-typeset -ga noinput_args
-noinput_args=(
- '--noinput[tells Django to NOT prompt the user for input of any kind.]'
-)
-
-typeset -ga no_init_data_args
-no_init_data_args=(
- '--no-initial-data[Tells Django not to load any initial data after database synchronization.]'
-)
-
-typeset -ga tag_args
-tag_args=(
- '--tag=-[Run only checks labeled with given tag.]'
- '--list-tags[List available tags.]'
-)
-
-_managepy-check(){
- _arguments -s : \
- $tag_args \
- $nul_args && ret=0
-}
-
-_managepy-changepassword(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-createcachetable(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-createsuperuser(){
- _arguments -s : \
- '--username=-[Specifies the login for the superuser.]' \
- '--email=-[Specifies the email for the superuser.]' \
- $noinput_args \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-collectstatic(){
- _arguments -s : \
- '--link[Create a symbolic link to each file instead of copying.]' \
- '--no-post-process[Do NOT post process collected files.]' \
- '--ignore=-[Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.]' \
- '--dry-run[Do everything except modify the filesystem.]' \
- '--clear[Clear the existing files using the storage before trying to copy or link the original file.]' \
- '--link[Create a symbolic link to each file instead of copying.]' \
- '--no-default-ignore[Do not ignore the common private glob-style patterns "CVS", ".*" and "*~".]' \
- $noinput_args \
- $nul_args && ret=0
-}
-
-_managepy-dbshell(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-diffsettings(){
- _arguments -s : \
- "--all[Display all settings, regardless of their value.]"
- $nul_args && ret=0
-}
-
-_managepy-dumpdata(){
- _arguments -s : \
- '--format=-[Specifies the output serialization format for fixtures.]:format:(json yaml xml)' \
- '--indent=-[Specifies the indent level to use when pretty-printing output.]' \
- '--exclude=-[An app_label or app_label.ModelName to exclude (use multiple --exclude to exclude multiple apps/models).]' \
- '--natural-foreign[Use natural foreign keys if they are available.]' \
- '--natural-primary[Use natural primary keys if they are available.]' \
- "--all[Use Django's base manager to dump all models stored in the database.]" \
- '--pks=-[Only dump objects with given primary keys.]' \
- $db_args \
- $nul_args \
- '*::appname:_applist' && ret=0
-}
-
-_managepy-flush(){
- _arguments -s : \
- $no_init_data_args \
- $db_args \
- $noinput_args \
- $nul_args && ret=0
-}
-
-_managepy-help(){
- _arguments -s : \
- '*:command:_managepy_cmds' \
- $nul_args && ret=0
-}
-
-_managepy_cmds(){
- local line
- local -a cmd
- _call_program help-command ./manage.py help \
- |& sed -n '/^ /s/[(), ]/ /gp' \
- | while read -A line; do cmd=($line $cmd) done
- _describe -t managepy-command 'manage.py command' cmd
-}
-
-_managepy-inspectdb(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-loaddata(){
- _arguments -s : \
- '--ignorenonexistent[Ignores entries in the serialized data for fields that do not currently exist on the model.]' \
- '--app=-[Only look for fixtures in the specified app.]:appname:_applist' \
- '*::file:_files' \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-makemessages(){
- _arguments -s : \
- '--locale=-[Creates or updates the message files for the given locale(s) (e.g. pt_BR).]' \
- '--domain=-[The domain of the message files (default: "django").]' \
- '--all[Updates the message files for all existing locales.]' \
- '--extension=-[The file extension(s) to examine (default: "html,txt", or "js" if the domain is "djangojs").]' \
- '--symlinks[Follows symlinks to directories when examining source code and templates for translation strings.]' \
- '--ignore=-[Ignore files or directories matching this glob-style pattern.]' \
- "--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \
- "--no-wrap[Don't break long message lines into several lines.]" \
- "--no-location[Don't write '#: filename:line' lines.]" \
- '--no-obsolete[Remove obsolete message strings.]' \
- '--keep-pot[Keep .pot file after making messages.]' \
- $nul_args && ret=0
-}
-_managepy-makemigrations(){
- _arguments -s : \
- '--dry-run[Just show what migrations would be made]' \
- '--merge[Enable fixing of migration conflicts.]' \
- '--empty[Create an empty migration.]' \
- $noinput_args \
- $nul_args && ret=0
-}
-_managepy-migrate(){
- _arguments -s : \
- '--fake[Mark migrations as run without actually running them]' \
- '--list[Show a list of all known migrations and which are applied]' \
- $no_init_data_args \
- $noinput_args \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-runfcgi(){
- local state
-
- local fcgi_opts
- fcgi_opts=(
- 'protocol[fcgi, scgi, ajp, ... (default fcgi)]:protocol:(fcgi scgi ajp)'
- 'host[hostname to listen on..]:'
- 'port[port to listen on.]:'
- 'socket[UNIX socket to listen on.]:file:_files'
- 'method[prefork or threaded (default prefork)]:method:(prefork threaded)'
- 'maxrequests[number of requests a child handles before it is killed and a new child is forked (0 = no limit).]:'
- 'maxspare[max number of spare processes / threads.]:'
- 'minspare[min number of spare processes / threads.]:'
- 'maxchildren[hard limit number of processes / threads.]:'
- 'daemonize[whether to detach from terminal.]:boolean:(False True)'
- 'pidfile[write the spawned process-id to this file.]:file:_files'
- 'workdir[change to this directory when daemonizing.]:directory:_files'
- 'outlog[write stdout to this file.]:file:_files'
- 'errlog[write stderr to this file.]:file:_files'
- )
-
- _arguments -s : \
- $nul_args \
- '*: :_values "FCGI Setting" $fcgi_opts' && ret=0
-}
-
-_managepy-runserver(){
- _arguments -s : \
- '--ipv6[Tells Django to use an IPv6 address.]' \
- '--nothreading[Tells Django to NOT use threading.]' \
- '--noreload[Tells Django to NOT use the auto-reloader.]' \
- '--nostatic[Tells Django to NOT automatically serve static files at STATIC_URL.]' \
- '--insecure[Allows serving static files even if DEBUG is False.]' \
- $nul_args && ret=0
-}
-
-_managepy-shell(){
- _arguments -s : \
- '--plain[Tells Django to use plain Python, not IPython.]' \
- '--no-startup[When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.]' \
- '--interface=-[Specify an interactive interpreter interface.]:INTERFACE:((ipython bpython))' \
- $nul_args && ret=0
-}
-
-_managepy-sql(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-sqlall(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-sqlclear(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-sqlcustom(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-dropindexes(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-sqlflush(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-sqlindexes(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-sqlinitialdata(){
- _arguments -s : \
- $nul_args && ret=0
-}
-
-_managepy-sqlsequencereset(){
- _arguments -s : \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-squashmigrations(){
- _arguments -s : \
- '--no-optimize[Do not try to optimize the squashed operations.]' \
- $noinput_args \
- $nul_args && ret=0
-}
-
-_managepy-startapp(){
- _arguments -s : \
- $start_args \
- $nul_args && ret=0
-}
-_managepy-startproject(){
- _arguments -s : \
- $start_args \
- $nul_args && ret=0
-}
-
-_managepy-syncdb() {
- _arguments -s : \
- $noinput_args \
- $no_init_data_args \
- $db_args \
- $nul_args && ret=0
-}
-
-_managepy-test() {
- _arguments -s : \
- '--failfast[Tells Django to stop running the test suite after first failed test.]' \
- '--testrunner=-[Tells Django to use specified test runner class instead of the one specified by the TEST_RUNNER setting.]' \
- '--liveserver=-[Overrides the default address where the live server (used with LiveServerTestCase) is expected to run from. The default value is localhost:8081.]' \
- '--top-level-directory=-[Top level of project for unittest discovery.]' \
- '--pattern=-[The test matching pattern. Defaults to test*.py.]:' \
- $noinput_args \
- '*::appname:_applist' \
- $nul_args && ret=0
-}
-
-_managepy-testserver() {
- _arguments -s : \
- '--addrport=-[port number or ipaddr:port to run the server on.]' \
- '--ipv6[Tells Django to use an IPv6 address.]' \
- $noinput_args \
- '*::fixture:_files' \
- $nul_args && ret=0
-}
-
-_managepy-validate() {
- _arguments -s : \
- $tag_args \
- $nul_args && ret=0
-}
-
-_managepy-commands() {
- local -a commands
-
- commands=(
- "changepassword:Change a user's password for django.contrib.auth."
- 'check:Checks the entire Django project for potential problems.'
- 'compilemessages:Compiles .po files to .mo files for use with builtin gettext support.'
- 'createcachetable:Creates the table needed to use the SQL cache backend.'
- 'createsuperuser:Used to create a superuser.'
- 'collectstatic:Collect static files in a single location.'
- 'dbshell:Runs the command-line client for the current DATABASE_ENGINE.'
- "diffsettings:Displays differences between the current settings.py and Django's default settings."
- 'dumpdata:Output the contents of the database as a fixture of the given format.'
- 'flush:Executes ``sqlflush`` on the current database.'
- 'help:manage.py help.'
- 'inspectdb:Introspects the database tables in the given database and outputs a Django model module.'
- 'loaddata:Installs the named fixture(s) in the database.'
- 'makemessages:Runs over the entire source tree of the current directory and pulls out all strings marked for translation.'
- 'makemigrations:Creates new migration(s) for apps.'
- 'migrate:Updates database schema. Manages both apps with migrations and those without.'
- 'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,'
- 'runserver:Starts a lightweight Web server for development.'
- 'shell:Runs a Python interactive interpreter.'
- 'showmigrations:Shows all available migrations for the current project.'
- 'sql:Prints the CREATE TABLE SQL statements for the given app name(s).'
- 'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).'
- 'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).'
- 'sqlcustom:Prints the custom table modifying SQL statements for the given app name(s).'
- 'sqldropindexes:Prints the DROP INDEX SQL statements for the given model module name(s).'
- 'sqlflush:Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.'
- 'sqlindexes:Prints the CREATE INDEX SQL statements for the given model module name(s).'
- "sqlinitialdata:RENAMED: see 'sqlcustom'"
- 'sqlsequencereset:Prints the SQL statements for resetting sequences for the given app name(s).'
- 'squashmigrations:Squashes an existing set of migrations (from first until specified) into a single new one.'
- "startapp:Creates a Django app directory structure for the given app name in this project's directory."
- "startproject:Creates a Django project directory structure for the given project name in this current directory."
- "syncdb:Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created."
- 'test:Runs the test suite for the specified applications, or the entire site if no apps are specified.'
- 'testserver:Runs a development server with data from the given fixture(s).'
- 'validate:Validates all installed models.'
- )
-
- _describe -t commands 'manage.py command' commands && ret=0
-}
-
-_applist() {
- local line
- local -a apps
- _call_program help-command "python -c \"import sys; del sys.path[0];\\
- import os.path as op, re, django.conf;\\
- bn=op.basename(op.abspath(op.curdir));[sys\\
- .stdout.write(str(re.sub(r'^%s\.(.*?)$' %
- bn, r'\1', i)) + '\n') for i in django.conf.settings.\\
- INSTALLED_APPS if re.match(r'^%s' % bn, i)]\"" \
- | while read -A line; do apps=($line $apps) done
- _values 'Application' $apps && ret=0
-}
-
-_managepy() {
- local curcontext=$curcontext ret=1
-
- if ((CURRENT == 2)); then
- _managepy-commands
- else
- shift words
- (( CURRENT -- ))
- curcontext="${curcontext%:*:*}:managepy-$words[1]:"
- _call_function ret _managepy-$words[1]
- fi
-}
-
-compdef _managepy manage.py
-compdef _managepy django
-compdef _managepy django-admin
-compdef _managepy django-admin.py
-compdef _managepy django-manage
-
-print -P "%F{yellow}The django plugin is deprecated in favor of Zsh's Django completion.
-%BPlease remove it from your plugins to stop using it.%b%f"
diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh
index 40ec5c46f..46cd4b10a 100644
--- a/plugins/dotenv/dotenv.plugin.zsh
+++ b/plugins/dotenv/dotenv.plugin.zsh
@@ -23,12 +23,12 @@ source_env() {
touch "$ZSH_DOTENV_DISALLOWED_LIST"
# early return if disallowed
- if command grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then
+ if command grep -Fx -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then
return
fi
# check if current directory's .env file is allowed or ask for confirmation
- if ! command grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then
+ if ! command grep -Fx -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then
# get cursor column and print new line before prompt if not at line beginning
local column
echo -ne "\e[6n" > /dev/tty
@@ -52,7 +52,10 @@ source_env() {
fi
# test .env syntax
- zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
+ zsh -fn $ZSH_DOTENV_FILE || {
+ echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
+ return 1
+ }
setopt localoptions allexport
source $ZSH_DOTENV_FILE
diff --git a/plugins/fd/README.md b/plugins/fd/README.md
index cf9f7815d..f3341612f 100644
--- a/plugins/fd/README.md
+++ b/plugins/fd/README.md
@@ -7,7 +7,3 @@ To use it, add `fd` to the plugins array in your zshrc file:
```zsh
plugins=(... fd)
```
-
-Completion is taken from the fd release [`8.2.1`](https://github.com/sharkdp/fd/releases/tag/v8.2.1).
-
-Updated on April 1st, 2021.
diff --git a/plugins/fd/_fd b/plugins/fd/_fd
index f5d9e01d2..45b8ca477 100644
--- a/plugins/fd/_fd
+++ b/plugins/fd/_fd
@@ -1,4 +1,4 @@
-#compdef fd fdfind
+#compdef fd
##
# zsh completion function for fd
@@ -57,6 +57,7 @@ _fd() {
+ no-ignore-partial # some ignore files
"(no-ignore-full --no-ignore-vcs)--no-ignore-vcs[don't respect .gitignore files]"
"!(no-ignore-full --no-global-ignore-file)--no-global-ignore-file[don't respect the global ignore file]"
+ $no'(no-ignore-full --no-ignore-parent)--no-ignore-parent[]'
+ '(case)' # case-sensitivity
{-s,--case-sensitive}'[perform a case-sensitive search]'
@@ -138,6 +139,7 @@ _fd() {
+ '(exec-cmds)' # execute command
'(long-listing max-results)'{-x+,--exec=}'[execute command for each search result]:command: _command_names -e:*\;::program arguments: _normal'
'(long-listing max-results)'{-X+,--exec-batch=}'[execute command for all search results at once]:command: _command_names -e:*\;::program arguments: _normal'
+ '(long-listing max-results)--batch-size=[max number of args for each -X call]:size'
+ other
'!(--max-buffer-time)--max-buffer-time=[set amount of time to buffer before showing output]:time (ms)'
@@ -153,6 +155,9 @@ _fd() {
$no'(--base-directory)--base-directory=[change the current working directory to the given path]:directory:_files -/'
$no'(*)*--search-path=[set search path (instead of positional <path> arguments)]:directory:_files -/'
+ + strip-cwd-prefix
+ $no'(strip-cwd-prefix exec-cmds)--strip-cwd-prefix[Strip ./ prefix when output is redirected]'
+
+ args # positional arguments
'1: :_guard "^-*" pattern'
'(--search-path)*:directory:_files -/'
@@ -220,7 +225,7 @@ _fd() {
_fd "$@"
# ------------------------------------------------------------------------------
-# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users
+# Copyright (c) 2011 GitHub zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/plugins/fig/README.md b/plugins/fig/README.md
new file mode 100644
index 000000000..3861958d6
--- /dev/null
+++ b/plugins/fig/README.md
@@ -0,0 +1,9 @@
+# Fig plugin
+
+This plugin sets up completion for [Fig](https://fig.io/).
+
+To use it, add `fig` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... fig)
+```
diff --git a/plugins/fig/fig.plugin.zsh b/plugins/fig/fig.plugin.zsh
new file mode 100644
index 000000000..cddb6c7c0
--- /dev/null
+++ b/plugins/fig/fig.plugin.zsh
@@ -0,0 +1,13 @@
+if ! (( $+commands[fig] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `fig`. Otherwise, compinit will have already done that
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_fig" ]]; then
+ autoload -Uz _fig
+ typeset -g -A _comps
+ _comps[fig]=_fig
+fi
+
+fig completion zsh >| "$ZSH_CACHE_DIR/completions/_fig" &|
diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh
index e22588792..044e16a04 100644
--- a/plugins/fnm/fnm.plugin.zsh
+++ b/plugins/fnm/fnm.plugin.zsh
@@ -18,7 +18,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `fnm`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then
- declare -A _comps
+ typeset -g -A _comps
autoload -Uz _fnm
_comps[fnm]=_fnm
fi
diff --git a/plugins/fossil/fossil.plugin.zsh b/plugins/fossil/fossil.plugin.zsh
index dfad73d36..a2123f415 100644
--- a/plugins/fossil/fossil.plugin.zsh
+++ b/plugins/fossil/fossil.plugin.zsh
@@ -13,23 +13,25 @@ ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖"
ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔"
function fossil_prompt_info() {
- local _OUTPUT=`fossil branch 2>&1`
- local _STATUS=`echo $_OUTPUT | grep "use --repo"`
- if [ "$_STATUS" = "" ]; then
- local _EDITED=`fossil changes`
- local _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
- local _BRANCH=`echo $_OUTPUT | grep "* " | sed 's/* //g'`
-
- if [ "$_EDITED" != "" ]; then
- _EDITED_SYM="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
- fi
+ local info=$(fossil branch 2>&1)
+
+ # if we're not in a fossil repo, don't show anything
+ ! command grep -q "use --repo" <<< "$info" || return
- echo "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
- "$_BRANCH" \
- "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
- "$_EDITED_SYM"\
- "%{$reset_color%}"
+ local branch=$(echo $info | grep "* " | sed 's/* //g')
+ local changes=$(fossil changes)
+ local dirty="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
+
+ if [[ -n "$changes" ]]; then
+ dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
fi
+
+ printf '%s %s %s %s %s' \
+ "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
+ "${branch:gs/%/%%}" \
+ "$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
+ "$dirty" \
+ "%{$reset_color%}"
}
function _fossil_prompt () {
diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
index 437e477b9..7f8d5c90c 100644
--- a/plugins/frontend-search/frontend-search.plugin.zsh
+++ b/plugins/frontend-search/frontend-search.plugin.zsh
@@ -39,7 +39,7 @@ function frontend() {
emulate -L zsh
# define search context URLS
- typeset -A urls
+ local -A urls
urls=(
angular 'https://angular.io/?search='
angularjs $(_frontend_fallback 'angularjs.org')
@@ -73,25 +73,23 @@ function frontend() {
)
# show help for command list
- if [[ $# -lt 2 ]]
- then
- print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
- print -P ""
- print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
- print -P "and %Ucontext%u is one of the following:"
- print -P ""
- print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
- print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash,"
- print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
- print -P ""
- print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
- print -P ""
- return 1
+ if [[ $# -lt 2 ]]; then
+ print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
+ print -P ""
+ print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
+ print -P "and %Ucontext%u is one of the following:"
+ print -P ""
+ print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, packagephobia"
+ print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash,"
+ print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
+ print -P ""
+ print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
+ print -P ""
+ return 1
fi
# check whether the search context is supported
- if [[ -z "$urls[$1]" ]]
- then
+ if [[ -z "$urls[$1]" ]]; then
echo "Search context \"$1\" currently not supported."
echo ""
echo "Valid contexts are:"
diff --git a/plugins/gh/gh.plugin.zsh b/plugins/gh/gh.plugin.zsh
index 17995e1cf..9263220ca 100644
--- a/plugins/gh/gh.plugin.zsh
+++ b/plugins/gh/gh.plugin.zsh
@@ -19,7 +19,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `gh`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then
- declare -A _comps
+ typeset -g -A _comps
autoload -Uz _gh
_comps[gh]=_gh
fi
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 648fa0a33..8f7e623ec 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -24,9 +24,7 @@ compdef _git _git_log_prettily=git-log
# Warn if the current branch is a WIP
function work_in_progress() {
- if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
- echo "WIP!!"
- fi
+ command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
}
# Check if main exists and use instead of master
diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
index 988f5b1c6..31bf88c1c 100644
--- a/plugins/gitfast/_git
+++ b/plugins/gitfast/_git
@@ -33,8 +33,9 @@ if [ -z "$script" ]; then
bash_completion='/usr/share/bash-completion/completions/'
locations=(
- "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
+ "${${funcsourcetrace[1]%:*}:A:h}"/git-completion.bash
"$HOME/.local/share/bash-completion/completions/git"
+ '/usr/local/share/bash-completion/completions/git'
"$bash_completion/git"
'/etc/bash_completion.d/git' # old debian
)
@@ -51,13 +52,20 @@ functions[complete]="$old_complete"
__gitcompadd ()
{
- compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0
+ compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0
}
__gitcomp ()
{
emulate -L zsh
+ IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }"
+}
+
+__gitcomp_opts ()
+{
+ emulate -L zsh
+
local cur_="${3-$cur}"
[[ "$cur_" == *= ]] && return
@@ -70,7 +78,7 @@ __gitcomp ()
break
fi
- if [[ -z "${4-}" ]]; then
+ if [[ -z "${4+set}" ]]; then
case $c in
*=) c="${c%=}"; sfx="=" ;;
*.) sfx="" ;;
@@ -79,7 +87,7 @@ __gitcomp ()
else
sfx="$4"
fi
- __gitcompadd "$c" "${2-}" "$sfx" -q
+ __gitcompadd "$c" "${2-}" "$sfx"
done
}
@@ -87,7 +95,10 @@ __gitcomp_nl ()
{
emulate -L zsh
- IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
+ # words that don't end up in space
+ compadd -p "${2-}" -S "${4- }" -q -- ${${(f)1}:#*\ } && _ret=0
+ # words that end in space
+ compadd -p "${2-}" -S " ${4- }" -q -- ${${(M)${(f)1}:#*\ }% } && _ret=0
}
__gitcomp_file ()
@@ -107,21 +118,6 @@ __gitcomp_file_direct ()
__gitcomp_file "$1" ""
}
-__gitcomp_nl_append ()
-{
- __gitcomp_nl "$@"
-}
-
-__gitcomp_direct_append ()
-{
- __gitcomp_direct "$@"
-}
-
-_git_zsh ()
-{
- __gitcomp "v1.2"
-}
-
__git_complete_command ()
{
emulate -L zsh
@@ -206,9 +202,7 @@ __git_zsh_main ()
{
local curcontext="$curcontext" state state_descr line
typeset -A opt_args
- local -a orig_words __git_C_args
-
- orig_words=( ${words[@]} )
+ local -a __git_C_args
_arguments -C \
'(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
@@ -245,7 +239,7 @@ __git_zsh_main ()
emulate ksh -c __git_complete_config_variable_name_and_value
;;
(arg)
- local command="${words[1]}" __git_dir
+ local command="${words[1]}" __git_dir __git_cmd_idx=1
if (( $+opt_args[--bare] )); then
__git_dir='.'
@@ -259,7 +253,7 @@ __git_zsh_main ()
(( $+opt_args[--help] )) && command='help'
- words=( ${orig_words[@]} )
+ words=( git ${words[@]} )
__git_zsh_bash_func $command
;;
@@ -269,7 +263,7 @@ __git_zsh_main ()
_git ()
{
local _ret=1
- local cur cword prev
+ local cur cword prev __git_cmd_idx=0
cur=${words[CURRENT]}
prev=${words[CURRENT-1]}
diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
index f7b09b2c1..2603ba7bb 100644
--- a/plugins/gitfast/git-completion.bash
+++ b/plugins/gitfast/git-completion.bash
@@ -29,6 +29,15 @@
# tell the completion to use commit completion. This also works with aliases
# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
#
+# If you have a command that is not part of git, but you would still
+# like completion, you can use __git_complete:
+#
+# __git_complete gl git_log
+#
+# Or if it's a main command (i.e. git or gitk):
+#
+# __git_complete gk gitk
+#
# Compatible with bash 3.2.57.
#
# You can set the following environment variables to influence the behavior of
@@ -45,6 +54,145 @@
# When set to "1" suggest all options, including options which are
# typically hidden (e.g. '--allow-empty' for 'git commit').
+# The following functions are meant to modify COMPREPLY, which should not be
+# modified directly. The purpose is to localize the modifications so it's
+# easier to emulate it in Zsh. Every time a new __gitcomp* function is added,
+# the corresponding function should be added to Zsh.
+
+__gitcompadd ()
+{
+ local x i=${#COMPREPLY[@]}
+ for x in $1; do
+ if [[ "$x" == "$3"* ]]; then
+ COMPREPLY[i++]="$2$x$4"
+ fi
+ done
+}
+
+# Creates completion replies.
+# It accepts 1 to 4 arguments:
+# 1: List of possible completion words.
+# 2: A prefix to be added to each possible completion word (optional).
+# 3: Generate possible completion matches for this word (optional).
+# 4: A suffix to be appended to each possible completion word (optional).
+__gitcomp ()
+{
+ local IFS=$' \t\n'
+ __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
+}
+
+# Generates completion reply from newline-separated possible completion words
+# by appending a space to all of them. The result is appended to COMPREPLY.
+# It accepts 1 to 4 arguments:
+# 1: List of possible completion words, separated by a single newline.
+# 2: A prefix to be added to each possible completion word (optional).
+# 3: Generate possible completion matches for this word (optional).
+# 4: A suffix to be appended to each possible completion word instead of
+# the default space (optional). If specified but empty, nothing is
+# appended.
+__gitcomp_nl ()
+{
+ local IFS=$'\n'
+ __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
+}
+
+# Appends prefiltered words to COMPREPLY without any additional processing.
+# Callers must take care of providing only words that match the current word
+# to be completed and adding any prefix and/or suffix (trailing space!), if
+# necessary.
+# 1: List of newline-separated matching completion words, complete with
+# prefix and suffix.
+__gitcomp_direct ()
+{
+ local IFS=$'\n'
+
+ COMPREPLY+=($1)
+}
+
+# Generates completion reply with compgen from newline-separated possible
+# completion filenames.
+# It accepts 1 to 3 arguments:
+# 1: List of possible completion filenames, separated by a single newline.
+# 2: A directory prefix to be added to each possible completion filename
+# (optional).
+# 3: Generate possible completion matches for this word (optional).
+__gitcomp_file ()
+{
+ local IFS=$'\n'
+
+ # XXX does not work when the directory prefix contains a tilde,
+ # since tilde expansion is not applied.
+ # This means that COMPREPLY will be empty and Bash default
+ # completion will be used.
+ __gitcompadd "$1" "${2-}" "${3-$cur}" ""
+
+ # use a hack to enable file mode in bash < 4
+ compopt -o filenames +o nospace 2>/dev/null ||
+ compgen -f /non-existing-dir/ >/dev/null ||
+ true
+}
+
+# Fills the COMPREPLY array with prefiltered paths without any additional
+# processing.
+# Callers must take care of providing only paths that match the current path
+# to be completed and adding any prefix path components, if necessary.
+# 1: List of newline-separated matching paths, complete with all prefix
+# path components.
+__gitcomp_file_direct ()
+{
+ local IFS=$'\n'
+
+ COMPREPLY+=($1)
+
+ # use a hack to enable file mode in bash < 4
+ compopt -o filenames +o nospace 2>/dev/null ||
+ compgen -f /non-existing-dir/ >/dev/null ||
+ true
+}
+
+# Creates completion replies, reorganizing options and adding suffixes as needed.
+# It accepts 1 to 4 arguments:
+# 1: List of possible completion words.
+# 2: A prefix to be added to each possible completion word (optional).
+# 3: Generate possible completion matches for this word (optional).
+# 4: A suffix to be appended to each possible completion word (optional).
+__gitcomp_opts ()
+{
+ local cur_="${3-$cur}"
+
+ if [[ "$cur_" == *= ]]; then
+ return
+ fi
+
+ local c i=0 IFS=$' \t\n' sfx
+ for c in $1; do
+ if [[ $c == "--" ]]; then
+ if [[ "$cur_" == --no-* ]]; then
+ continue
+ fi
+
+ if [[ --no == "$cur_"* ]]; then
+ COMPREPLY[i++]="--no-... "
+ fi
+ break
+ fi
+ if [[ $c == "$cur_"* ]]; then
+ if [[ -z "${4+set}" ]]; then
+ case $c in
+ *=|*.) sfx="" ;;
+ *) sfx=" " ;;
+ esac
+ else
+ sfx="$4"
+ fi
+ COMPREPLY[i++]="${2-}$c$sfx"
+ fi
+ done
+}
+
+# __gitcomp functions end here
+# ==============================================================================
+
# Discovers the path to the git repository taking any '--git-dir=<path>' and
# '-C <path>' options into account and stores it in the $__git_repo_path
# variable.
@@ -63,7 +211,7 @@ __git_find_repo_path ()
test -d "$__git_dir" &&
__git_repo_path="$__git_dir"
elif [ -n "${GIT_DIR-}" ]; then
- test -d "${GIT_DIR-}" &&
+ test -d "$GIT_DIR" &&
__git_repo_path="$GIT_DIR"
elif [ -d .git ]; then
__git_repo_path=.git
@@ -159,230 +307,6 @@ __git_dequote ()
done
}
-# The following function is based on code from:
-#
-# bash_completion - programmable completion functions for bash 3.2+
-#
-# Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
-# © 2009-2010, Bash Completion Maintainers
-# <bash-completion-devel@lists.alioth.debian.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# The latest version of this software can be obtained here:
-#
-# http://bash-completion.alioth.debian.org/
-#
-# RELEASE: 2.x
-
-# This function can be used to access a tokenized list of words
-# on the command line:
-#
-# __git_reassemble_comp_words_by_ref '=:'
-# if test "${words_[cword_-1]}" = -w
-# then
-# ...
-# fi
-#
-# The argument should be a collection of characters from the list of
-# word completion separators (COMP_WORDBREAKS) to treat as ordinary
-# characters.
-#
-# This is roughly equivalent to going back in time and setting
-# COMP_WORDBREAKS to exclude those characters. The intent is to
-# make option types like --date=<type> and <rev>:<path> easy to
-# recognize by treating each shell word as a single token.
-#
-# It is best not to set COMP_WORDBREAKS directly because the value is
-# shared with other completion scripts. By the time the completion
-# function gets called, COMP_WORDS has already been populated so local
-# changes to COMP_WORDBREAKS have no effect.
-#
-# Output: words_, cword_, cur_.
-
-__git_reassemble_comp_words_by_ref()
-{
- local exclude i j first
- # Which word separators to exclude?
- exclude="${1//[^$COMP_WORDBREAKS]}"
- cword_=$COMP_CWORD
- if [ -z "$exclude" ]; then
- words_=("${COMP_WORDS[@]}")
- return
- fi
- # List of word completion separators has shrunk;
- # re-assemble words to complete.
- for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
- # Append each nonempty word consisting of just
- # word separator characters to the current word.
- first=t
- while
- [ $i -gt 0 ] &&
- [ -n "${COMP_WORDS[$i]}" ] &&
- # word consists of excluded word separators
- [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
- do
- # Attach to the previous token,
- # unless the previous token is the command name.
- if [ $j -ge 2 ] && [ -n "$first" ]; then
- ((j--))
- fi
- first=
- words_[$j]=${words_[j]}${COMP_WORDS[i]}
- if [ $i = $COMP_CWORD ]; then
- cword_=$j
- fi
- if (($i < ${#COMP_WORDS[@]} - 1)); then
- ((i++))
- else
- # Done.
- return
- fi
- done
- words_[$j]=${words_[j]}${COMP_WORDS[i]}
- if [ $i = $COMP_CWORD ]; then
- cword_=$j
- fi
- done
-}
-
-if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
-_get_comp_words_by_ref ()
-{
- local exclude cur_ words_ cword_
- if [ "$1" = "-n" ]; then
- exclude=$2
- shift 2
- fi
- __git_reassemble_comp_words_by_ref "$exclude"
- cur_=${words_[cword_]}
- while [ $# -gt 0 ]; do
- case "$1" in
- cur)
- cur=$cur_
- ;;
- prev)
- prev=${words_[$cword_-1]}
- ;;
- words)
- words=("${words_[@]}")
- ;;
- cword)
- cword=$cword_
- ;;
- esac
- shift
- done
-}
-fi
-
-# Fills the COMPREPLY array with prefiltered words without any additional
-# processing.
-# Callers must take care of providing only words that match the current word
-# to be completed and adding any prefix and/or suffix (trailing space!), if
-# necessary.
-# 1: List of newline-separated matching completion words, complete with
-# prefix and suffix.
-__gitcomp_direct ()
-{
- local IFS=$'\n'
-
- COMPREPLY=($1)
-}
-
-# Similar to __gitcomp_direct, but appends to COMPREPLY instead.
-# Callers must take care of providing only words that match the current word
-# to be completed and adding any prefix and/or suffix (trailing space!), if
-# necessary.
-# 1: List of newline-separated matching completion words, complete with
-# prefix and suffix.
-__gitcomp_direct_append ()
-{
- local IFS=$'\n'
-
- COMPREPLY+=($1)
-}
-
-__gitcompappend ()
-{
- local x i=${#COMPREPLY[@]}
- for x in $1; do
- if [[ "$x" == "$3"* ]]; then
- COMPREPLY[i++]="$2$x$4"
- fi
- done
-}
-
-__gitcompadd ()
-{
- COMPREPLY=()
- __gitcompappend "$@"
-}
-
-# Generates completion reply, appending a space to possible completion words,
-# if necessary.
-# It accepts 1 to 4 arguments:
-# 1: List of possible completion words.
-# 2: A prefix to be added to each possible completion word (optional).
-# 3: Generate possible completion matches for this word (optional).
-# 4: A suffix to be appended to each possible completion word (optional).
-__gitcomp ()
-{
- local cur_="${3-$cur}"
-
- case "$cur_" in
- *=)
- ;;
- --no-*)
- local c i=0 IFS=$' \t\n'
- for c in $1; do
- if [[ $c == "--" ]]; then
- continue
- fi
- c="$c${4-}"
- if [[ $c == "$cur_"* ]]; then
- case $c in
- --*=|*.) ;;
- *) c="$c " ;;
- esac
- COMPREPLY[i++]="${2-}$c"
- fi
- done
- ;;
- *)
- local c i=0 IFS=$' \t\n'
- for c in $1; do
- if [[ $c == "--" ]]; then
- c="--no-...${4-}"
- if [[ $c == "$cur_"* ]]; then
- COMPREPLY[i++]="${2-}$c "
- fi
- break
- fi
- c="$c${4-}"
- if [[ $c == "$cur_"* ]]; then
- case $c in
- *=|*.) ;;
- *) c="$c " ;;
- esac
- COMPREPLY[i++]="${2-}$c"
- fi
- done
- ;;
- esac
-}
-
# Clear the variables caching builtins' options when (re-)sourcing
# the completion script.
if [[ -n ${ZSH_VERSION-} ]]; then
@@ -391,107 +315,108 @@ else
unset $(compgen -v __gitcomp_builtin_)
fi
-__gitcomp_builtin_add_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
-__gitcomp_builtin_am_default=" --interactive --3way --quiet --signoff --utf8 --keep --keep-non-patch --message-id --keep-cr --no-keep-cr --scissors --whitespace= --ignore-space-change --ignore-whitespace --directory= --exclude= --include= --patch-format= --reject --resolvemsg= --continue --resolved --skip --abort --quit --show-current-patch --committer-date-is-author-date --ignore-date --rerere-autoupdate --gpg-sign -- --no-interactive --no-3way --no-quiet --no-signoff --no-utf8 --no-keep --no-keep-non-patch --no-message-id --no-scissors --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-directory --no-exclude --no-include --no-patch-format --no-reject --no-resolvemsg --no-committer-date-is-author-date --no-ignore-date --no-rerere-autoupdate --no-gpg-sign"
-__gitcomp_builtin_apply_default=" --exclude= --include= --no-add --stat --numstat --summary --check --index --intent-to-add --cached --apply --3way --build-fake-ancestor= --whitespace= --ignore-space-change --ignore-whitespace --reverse --unidiff-zero --reject --allow-overlap --verbose --inaccurate-eof --recount --directory= --add -- --no-stat --no-numstat --no-summary --no-check --no-index --no-intent-to-add --no-cached --no-apply --no-3way --no-build-fake-ancestor --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-reverse --no-unidiff-zero --no-reject --no-allow-overlap --no-verbose --no-inaccurate-eof --no-recount --no-directory"
+__gitcomp_builtin_add_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --sparse --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-sparse --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_am_default=" --interactive --3way --quiet --signoff --utf8 --keep --keep-non-patch --message-id --keep-cr --no-keep-cr --scissors --quoted-cr= --whitespace= --ignore-space-change --ignore-whitespace --directory= --exclude= --include= --patch-format= --reject --resolvemsg= --continue --resolved --skip --abort --quit --show-current-patch --allow-empty --committer-date-is-author-date --ignore-date --rerere-autoupdate --gpg-sign --empty= -- --no-interactive --no-3way --no-quiet --no-signoff --no-utf8 --no-keep --no-keep-non-patch --no-message-id --no-scissors --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-directory --no-exclude --no-include --no-patch-format --no-reject --no-resolvemsg --no-committer-date-is-author-date --no-ignore-date --no-rerere-autoupdate --no-gpg-sign"
+__gitcomp_builtin_apply_default=" --exclude= --include= --no-add --stat --numstat --summary --check --index --intent-to-add --cached --apply --3way --build-fake-ancestor= --whitespace= --ignore-space-change --ignore-whitespace --reverse --unidiff-zero --reject --allow-overlap --verbose --quiet --inaccurate-eof --recount --directory= --allow-empty --add -- --no-stat --no-numstat --no-summary --no-check --no-index --no-intent-to-add --no-cached --no-apply --no-3way --no-build-fake-ancestor --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-reverse --no-unidiff-zero --no-reject --no-allow-overlap --no-verbose --no-quiet --no-inaccurate-eof --no-recount --no-directory --no-allow-empty"
__gitcomp_builtin_archive_default=" --output= --remote= --exec= --no-output -- --no-remote --no-exec"
-__gitcomp_builtin_bisect__helper_default=" --next-all --write-terms --bisect-clean-state --check-expected-revs --bisect-reset --bisect-write --check-and-set-terms --bisect-next-check --bisect-terms --bisect-start --bisect-next --bisect-auto-next --bisect-autostart --no-log --log"
+__gitcomp_builtin_bisect__helper_default=" --bisect-reset --bisect-next-check --bisect-terms --bisect-start --bisect-next --bisect-state --bisect-log --bisect-replay --bisect-skip --bisect-visualize --bisect-run --no-log --log"
__gitcomp_builtin_blame_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev"
-__gitcomp_builtin_branch_default=" --verbose --quiet --track --set-upstream-to= --unset-upstream --color --remotes --contains --no-contains --abbrev --all --delete --move --copy --list --show-current --create-reflog --edit-description --merged --no-merged --column --sort= --points-at= --ignore-case --format= -- --no-verbose --no-quiet --no-track --no-set-upstream-to --no-unset-upstream --no-color --no-remotes --no-abbrev --no-all --no-delete --no-move --no-copy --no-list --no-show-current --no-create-reflog --no-edit-description --no-column --no-points-at --no-ignore-case --no-format"
+__gitcomp_builtin_branch_default=" --verbose --quiet --track --set-upstream-to= --unset-upstream --color --remotes --contains --no-contains --abbrev --all --delete --move --copy --list --show-current --create-reflog --edit-description --merged --no-merged --column --sort= --points-at= --ignore-case --format= -- --no-verbose --no-quiet --no-track --no-set-upstream-to --no-unset-upstream --no-color --no-remotes --no-abbrev --no-all --no-delete --no-move --no-copy --no-list --no-show-current --no-create-reflog --no-edit-description --no-column --no-sort --no-points-at --no-ignore-case --no-format"
__gitcomp_builtin_bugreport_default=" --output-directory= --suffix= --no-output-directory -- --no-suffix"
__gitcomp_builtin_cat_file_default=" --textconv --filters --path= --allow-unknown-type --buffer --batch --batch-check --follow-symlinks --batch-all-objects --unordered --no-path -- --no-allow-unknown-type --no-buffer --no-follow-symlinks --no-batch-all-objects --no-unordered"
__gitcomp_builtin_check_attr_default=" --all --cached --stdin --no-all -- --no-cached --no-stdin"
__gitcomp_builtin_check_ignore_default=" --quiet --verbose --stdin --non-matching --no-index --index -- --no-quiet --no-verbose --no-stdin --no-non-matching"
__gitcomp_builtin_check_mailmap_default=" --stdin --no-stdin"
__gitcomp_builtin_checkout_default=" --guess --overlay --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-guess -- --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_checkout__worker_default=" --prefix= --no-prefix"
__gitcomp_builtin_checkout_index_default=" --all --force --quiet --no-create --index --stdin --temp --prefix= --stage= --create -- --no-all --no-force --no-quiet --no-index --no-stdin --no-temp --no-prefix"
__gitcomp_builtin_cherry_default=" --abbrev --verbose --no-abbrev -- --no-verbose"
__gitcomp_builtin_cherry_pick_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --ff --allow-empty --allow-empty-message --keep-redundant-commits --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign --no-ff --no-allow-empty --no-allow-empty-message --no-keep-redundant-commits"
__gitcomp_builtin_clean_default=" --quiet --dry-run --interactive --exclude= --no-quiet -- --no-dry-run --no-interactive"
-__gitcomp_builtin_clone_default=" --verbose --quiet --progress --no-checkout --bare --mirror --local --no-hardlinks --shared --recurse-submodules --recursive --jobs= --template= --reference= --reference-if-able= --dissociate --origin= --branch= --upload-pack= --depth= --shallow-since= --shallow-exclude= --single-branch --no-tags --shallow-submodules --separate-git-dir= --config= --server-option= --ipv4 --ipv6 --filter= --remote-submodules --sparse --checkout --hardlinks --tags -- --no-verbose --no-quiet --no-progress --no-bare --no-mirror --no-local --no-shared --no-recurse-submodules --no-recursive --no-jobs --no-template --no-reference --no-reference-if-able --no-dissociate --no-origin --no-branch --no-upload-pack --no-depth --no-shallow-since --no-shallow-exclude --no-single-branch --no-shallow-submodules --no-separate-git-dir --no-config --no-server-option --no-ipv4 --no-ipv6 --no-filter --no-remote-submodules --no-sparse"
+__gitcomp_builtin_clone_default=" --verbose --quiet --progress --reject-shallow --no-checkout --bare --mirror --local --no-hardlinks --shared --recurse-submodules --jobs= --template= --reference= --reference-if-able= --dissociate --origin= --branch= --upload-pack= --depth= --shallow-since= --shallow-exclude= --single-branch --no-tags --shallow-submodules --separate-git-dir= --config= --server-option= --ipv4 --ipv6 --filter= --remote-submodules --sparse --checkout --hardlinks --tags -- --no-verbose --no-quiet --no-progress --no-reject-shallow --no-bare --no-mirror --no-local --no-shared --no-recurse-submodules --no-recursive --no-jobs --no-template --no-reference --no-reference-if-able --no-dissociate --no-origin --no-branch --no-upload-pack --no-depth --no-shallow-since --no-shallow-exclude --no-single-branch --no-shallow-submodules --no-separate-git-dir --no-config --no-server-option --no-ipv4 --no-ipv6 --no-filter --no-remote-submodules --no-sparse"
__gitcomp_builtin_column_default=" --command= --mode --raw-mode= --width= --indent= --nl= --padding= --no-command -- --no-mode --no-raw-mode --no-width --no-indent --no-nl --no-padding"
-__gitcomp_builtin_commit_default=" --quiet --verbose --file= --author= --date= --message= --reedit-message= --reuse-message= --fixup= --squash= --reset-author --signoff --template= --edit --cleanup= --status --gpg-sign --all --include --interactive --patch --only --no-verify --dry-run --short --branch --ahead-behind --porcelain --long --null --amend --no-post-rewrite --untracked-files --pathspec-from-file= --pathspec-file-nul --verify --post-rewrite -- --no-quiet --no-verbose --no-file --no-author --no-date --no-message --no-reedit-message --no-reuse-message --no-fixup --no-squash --no-reset-author --no-signoff --no-template --no-edit --no-cleanup --no-status --no-gpg-sign --no-all --no-include --no-interactive --no-patch --no-only --no-dry-run --no-short --no-branch --no-ahead-behind --no-porcelain --no-long --no-null --no-amend --no-untracked-files --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_commit_default=" --quiet --verbose --file= --author= --date= --message= --reedit-message= --reuse-message= --fixup= --squash= --reset-author --trailer= --signoff --template= --edit --cleanup= --status --gpg-sign --all --include --interactive --patch --only --no-verify --dry-run --short --branch --ahead-behind --porcelain --long --null --amend --no-post-rewrite --untracked-files --pathspec-from-file= --pathspec-file-nul --verify --post-rewrite -- --no-quiet --no-verbose --no-file --no-author --no-date --no-message --no-reedit-message --no-reuse-message --no-fixup --no-squash --no-reset-author --no-signoff --no-template --no-edit --no-cleanup --no-status --no-gpg-sign --no-all --no-include --no-interactive --no-patch --no-only --no-dry-run --no-short --no-branch --no-ahead-behind --no-porcelain --no-long --no-null --no-amend --no-untracked-files --no-pathspec-from-file --no-pathspec-file-nul"
__gitcomp_builtin_commit_graph_default=" --object-dir= --no-object-dir"
-__gitcomp_builtin_config_default=" --global --system --local --worktree --file= --blob= --get --get-all --get-regexp --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section --list --edit --get-color --get-colorbool --type= --bool --int --bool-or-int --bool-or-str --path --expiry-date --null --name-only --includes --show-origin --show-scope --default= --no-global -- --no-system --no-local --no-worktree --no-file --no-blob --no-get --no-get-all --no-get-regexp --no-get-urlmatch --no-replace-all --no-add --no-unset --no-unset-all --no-rename-section --no-remove-section --no-list --no-edit --no-get-color --no-get-colorbool --no-type --no-null --no-name-only --no-includes --no-show-origin --no-show-scope --no-default"
+__gitcomp_builtin_config_default=" --global --system --local --worktree --file= --blob= --get --get-all --get-regexp --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section --list --fixed-value --edit --get-color --get-colorbool --type= --bool --int --bool-or-int --bool-or-str --path --expiry-date --null --name-only --includes --show-origin --show-scope --default= --no-global -- --no-system --no-local --no-worktree --no-file --no-blob --no-get --no-get-all --no-get-regexp --no-get-urlmatch --no-replace-all --no-add --no-unset --no-unset-all --no-rename-section --no-remove-section --no-list --no-fixed-value --no-edit --no-get-color --no-get-colorbool --no-type --no-null --no-name-only --no-includes --no-show-origin --no-show-scope --no-default"
__gitcomp_builtin_count_objects_default=" --verbose --human-readable --no-verbose -- --no-human-readable"
__gitcomp_builtin_credential_cache_default=" --timeout= --socket= --no-timeout -- --no-socket"
__gitcomp_builtin_credential_cache__daemon_default=" --debug --no-debug"
__gitcomp_builtin_credential_store_default=" --file= --no-file"
__gitcomp_builtin_describe_default=" --contains --debug --all --tags --long --first-parent --abbrev --exact-match --candidates= --match= --exclude= --always --dirty --broken --no-contains -- --no-debug --no-all --no-tags --no-long --no-first-parent --no-abbrev --no-exact-match --no-candidates --no-match --no-exclude --no-always --no-dirty --no-broken"
-__gitcomp_builtin_difftool_default=" --gui --dir-diff --no-prompt --symlinks --tool= --tool-help --trust-exit-code --extcmd= --no-index -- --no-gui --no-dir-diff --no-symlinks --no-tool --no-tool-help --no-trust-exit-code --no-extcmd"
+__gitcomp_builtin_difftool_default=" --gui --dir-diff --no-prompt --symlinks --tool= --tool-help --trust-exit-code --extcmd= --no-index --index -- --no-gui --no-dir-diff --no-symlinks --no-tool --no-tool-help --no-trust-exit-code --no-extcmd"
__gitcomp_builtin_env__helper_default=" --type= --default= --exit-code --no-default -- --no-exit-code"
__gitcomp_builtin_fast_export_default=" --progress= --signed-tags= --tag-of-filtered-object= --reencode= --export-marks= --import-marks= --import-marks-if-exists= --fake-missing-tagger --full-tree --use-done-feature --no-data --refspec= --anonymize --anonymize-map= --reference-excluded-parents --show-original-ids --mark-tags --data -- --no-progress --no-signed-tags --no-tag-of-filtered-object --no-reencode --no-export-marks --no-import-marks --no-import-marks-if-exists --no-fake-missing-tagger --no-full-tree --no-use-done-feature --no-refspec --no-anonymize --no-reference-excluded-parents --no-show-original-ids --no-mark-tags"
-__gitcomp_builtin_fetch_default=" --verbose --quiet --all --set-upstream --append --upload-pack= --force --multiple --tags --jobs= --prune --prune-tags --recurse-submodules --dry-run --write-fetch-head --keep --update-head-ok --progress --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --filter= --auto-maintenance --auto-gc --show-forced-updates --write-commit-graph --stdin --no-verbose -- --no-quiet --no-all --no-set-upstream --no-append --no-upload-pack --no-force --no-multiple --no-tags --no-jobs --no-prune --no-prune-tags --no-recurse-submodules --no-dry-run --no-write-fetch-head --no-keep --no-update-head-ok --no-progress --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-filter --no-auto-maintenance --no-auto-gc --no-show-forced-updates --no-write-commit-graph --no-stdin"
-__gitcomp_builtin_fmt_merge_msg_default=" --log --message= --file= --no-log -- --no-message --no-file"
-__gitcomp_builtin_for_each_ref_default=" --shell --perl --python --tcl --count= --format= --color --sort= --points-at= --merged --no-merged --contains --no-contains --ignore-case -- --no-shell --no-perl --no-python --no-tcl --no-count --no-format --no-color --no-points-at --no-ignore-case"
-__gitcomp_builtin_format_patch_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
+__gitcomp_builtin_fetch_default=" --verbose --quiet --all --set-upstream --append --atomic --upload-pack= --force --multiple --tags --jobs= --prefetch --prune --prune-tags --recurse-submodules --dry-run --write-fetch-head --keep --update-head-ok --progress --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --negotiate-only --filter= --auto-maintenance --auto-gc --show-forced-updates --write-commit-graph --stdin --no-verbose -- --no-quiet --no-all --no-set-upstream --no-append --no-atomic --no-upload-pack --no-force --no-multiple --no-tags --no-jobs --no-prefetch --no-prune --no-prune-tags --no-recurse-submodules --no-dry-run --no-write-fetch-head --no-keep --no-update-head-ok --no-progress --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-negotiate-only --no-filter --no-auto-maintenance --no-auto-gc --no-show-forced-updates --no-write-commit-graph --no-stdin"
+__gitcomp_builtin_fmt_merge_msg_default=" --log --message= --into-name= --file= --no-log -- --no-message --no-into-name --no-file"
+__gitcomp_builtin_for_each_ref_default=" --shell --perl --python --tcl --count= --format= --color --sort= --points-at= --merged --no-merged --contains --no-contains --ignore-case -- --no-shell --no-perl --no-python --no-tcl --no-count --no-format --no-color --no-sort --no-points-at --no-ignore-case"
+__gitcomp_builtin_for_each_repo_default=" --config= --no-config"
+__gitcomp_builtin_format_patch_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --filename-max-length= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-filename-max-length --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
__gitcomp_builtin_fsck_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects"
__gitcomp_builtin_fsck_objects_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects"
__gitcomp_builtin_gc_default=" --quiet --prune --aggressive --keep-largest-pack --no-quiet -- --no-prune --no-aggressive --no-keep-largest-pack"
__gitcomp_builtin_grep_default=" --cached --no-index --untracked --exclude-standard --recurse-submodules --invert-match --ignore-case --word-regexp --text --textconv --recursive --max-depth= --extended-regexp --basic-regexp --fixed-strings --perl-regexp --line-number --column --full-name --files-with-matches --name-only --files-without-match --only-matching --count --color --break --heading --context= --before-context= --after-context= --threads= --show-function --function-context --and --or --not --quiet --all-match --index -- --no-cached --no-untracked --no-exclude-standard --no-recurse-submodules --no-invert-match --no-ignore-case --no-word-regexp --no-text --no-textconv --no-recursive --no-extended-regexp --no-basic-regexp --no-fixed-strings --no-perl-regexp --no-line-number --no-column --no-full-name --no-files-with-matches --no-name-only --no-files-without-match --no-only-matching --no-count --no-color --no-break --no-heading --no-context --no-before-context --no-after-context --no-threads --no-show-function --no-function-context --no-or --no-quiet --no-all-match"
__gitcomp_builtin_hash_object_default=" --stdin --stdin-paths --no-filters --literally --path= --filters -- --no-stdin --no-stdin-paths --no-literally --no-path"
-__gitcomp_builtin_help_default=" --all --guides --config --man --web --info --verbose --no-all -- --no-guides --no-config --no-man --no-web --no-info --no-verbose"
+__gitcomp_builtin_help_default=" --all --man --web --info --verbose --guides --config --no-man -- --no-web --no-info --no-verbose"
__gitcomp_builtin_init_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format"
__gitcomp_builtin_init_db_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format"
__gitcomp_builtin_interpret_trailers_default=" --in-place --trim-empty --where= --if-exists= --if-missing= --only-trailers --only-input --unfold --parse --no-divider --trailer= --divider -- --no-in-place --no-trim-empty --no-where --no-if-exists --no-if-missing --no-only-trailers --no-only-input --no-unfold --no-trailer"
-__gitcomp_builtin_log_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
-__gitcomp_builtin_ls_files_default=" --cached --deleted --modified --others --ignored --stage --killed --directory --eol --empty-directory --unmerged --resolve-undo --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --full-name --recurse-submodules --error-unmatch --with-tree= --abbrev --debug --no-cached -- --no-deleted --no-modified --no-others --no-ignored --no-stage --no-killed --no-directory --no-eol --no-empty-directory --no-unmerged --no-resolve-undo --no-exclude-per-directory --no-recurse-submodules --no-error-unmatch --no-with-tree --no-abbrev --no-debug"
-__gitcomp_builtin_ls_remote_default=" --quiet --upload-pack= --tags --heads --refs --get-url --sort= --symref --server-option= --no-quiet -- --no-upload-pack --no-tags --no-heads --no-refs --no-get-url --no-symref --no-server-option"
+__gitcomp_builtin_log_default=" --quiet --source --use-mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_ls_files_default=" --cached --deleted --modified --others --ignored --stage --killed --directory --eol --empty-directory --unmerged --resolve-undo --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --full-name --recurse-submodules --error-unmatch --with-tree= --abbrev --debug --deduplicate --sparse --no-cached -- --no-deleted --no-modified --no-others --no-ignored --no-stage --no-killed --no-directory --no-eol --no-empty-directory --no-unmerged --no-resolve-undo --no-exclude-per-directory --no-recurse-submodules --no-error-unmatch --no-with-tree --no-abbrev --no-debug --no-deduplicate --no-sparse"
+__gitcomp_builtin_ls_remote_default=" --quiet --upload-pack= --tags --heads --refs --get-url --sort= --symref --server-option= --no-quiet -- --no-upload-pack --no-tags --no-heads --no-refs --no-get-url --no-sort --no-symref --no-server-option"
__gitcomp_builtin_ls_tree_default=" --long --name-only --name-status --full-name --full-tree --abbrev --no-long -- --no-name-only --no-name-status --no-full-name --no-full-tree --no-abbrev"
-__gitcomp_builtin_merge_default=" --stat --summary --log --squash --commit --edit --cleanup= --ff --ff-only --rerere-autoupdate --verify-signatures --strategy= --strategy-option= --message= --file --verbose --quiet --abort --quit --continue --allow-unrelated-histories --progress --gpg-sign --autostash --overwrite-ignore --signoff --no-verify --verify -- --no-stat --no-summary --no-log --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-rerere-autoupdate --no-verify-signatures --no-strategy --no-strategy-option --no-message --no-verbose --no-quiet --no-abort --no-quit --no-continue --no-allow-unrelated-histories --no-progress --no-gpg-sign --no-autostash --no-overwrite-ignore --no-signoff"
+__gitcomp_builtin_merge_default=" --stat --summary --log --squash --commit --edit --cleanup= --ff --ff-only --rerere-autoupdate --verify-signatures --strategy= --strategy-option= --message= --file --into-name= --verbose --quiet --abort --quit --continue --allow-unrelated-histories --progress --gpg-sign --autostash --overwrite-ignore --signoff --no-verify --verify -- --no-stat --no-summary --no-log --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-rerere-autoupdate --no-verify-signatures --no-strategy --no-strategy-option --no-message --no-into-name --no-verbose --no-quiet --no-abort --no-quit --no-continue --no-allow-unrelated-histories --no-progress --no-gpg-sign --no-autostash --no-overwrite-ignore --no-signoff"
__gitcomp_builtin_merge_base_default=" --all --octopus --independent --is-ancestor --fork-point --no-all"
-__gitcomp_builtin_merge_file_default=" --stdout --diff3 --ours --theirs --union --marker-size= --quiet --no-stdout -- --no-diff3 --no-ours --no-theirs --no-union --no-marker-size --no-quiet"
+__gitcomp_builtin_merge_file_default=" --stdout --diff3 --zdiff3 --ours --theirs --union --marker-size= --quiet --no-stdout -- --no-diff3 --no-zdiff3 --no-ours --no-theirs --no-union --no-marker-size --no-quiet"
__gitcomp_builtin_mktree_default=" --missing --batch --no-missing -- --no-batch"
-__gitcomp_builtin_multi_pack_index_default=" --object-dir= --progress --batch-size= --no-object-dir -- --no-progress"
-__gitcomp_builtin_mv_default=" --verbose --dry-run --no-verbose -- --no-dry-run"
+__gitcomp_builtin_multi_pack_index_default=" --object-dir= --no-object-dir"
+__gitcomp_builtin_mv_default=" --verbose --dry-run --sparse --no-verbose -- --no-dry-run --no-sparse"
__gitcomp_builtin_name_rev_default=" --name-only --tags --refs= --exclude= --all --stdin --undefined --always --no-name-only -- --no-tags --no-refs --no-exclude --no-all --no-stdin --no-undefined --no-always"
__gitcomp_builtin_notes_default=" --ref= --no-ref"
-__gitcomp_builtin_pack_objects_default=" --quiet --progress --all-progress --all-progress-implied --index-version= --max-pack-size= --local --incremental --window= --window-memory= --depth= --reuse-delta --reuse-object --delta-base-offset --threads= --non-empty --revs --unpacked --all --reflog --indexed-objects --stdout --include-tag --keep-unreachable --pack-loose-unreachable --unpack-unreachable --sparse --thin --shallow --honor-pack-keep --keep-pack= --compression= --keep-true-parents --use-bitmap-index --write-bitmap-index --filter= --missing= --exclude-promisor-objects --delta-islands --uri-protocol= --no-quiet -- --no-progress --no-all-progress --no-all-progress-implied --no-local --no-incremental --no-window --no-depth --no-reuse-delta --no-reuse-object --no-delta-base-offset --no-threads --no-non-empty --no-revs --no-stdout --no-include-tag --no-keep-unreachable --no-pack-loose-unreachable --no-unpack-unreachable --no-sparse --no-thin --no-shallow --no-honor-pack-keep --no-keep-pack --no-compression --no-keep-true-parents --no-use-bitmap-index --no-write-bitmap-index --no-filter --no-exclude-promisor-objects --no-delta-islands --no-uri-protocol"
+__gitcomp_builtin_pack_objects_default=" --quiet --progress --all-progress --all-progress-implied --index-version= --max-pack-size= --local --incremental --window= --window-memory= --depth= --reuse-delta --reuse-object --delta-base-offset --threads= --non-empty --revs --unpacked --all --reflog --indexed-objects --stdin-packs --stdout --include-tag --keep-unreachable --pack-loose-unreachable --unpack-unreachable --sparse --thin --shallow --honor-pack-keep --keep-pack= --compression= --keep-true-parents --use-bitmap-index --write-bitmap-index --filter= --missing= --exclude-promisor-objects --delta-islands --uri-protocol= --no-quiet -- --no-progress --no-all-progress --no-all-progress-implied --no-local --no-incremental --no-window --no-depth --no-reuse-delta --no-reuse-object --no-delta-base-offset --no-threads --no-non-empty --no-revs --no-stdin-packs --no-stdout --no-include-tag --no-keep-unreachable --no-pack-loose-unreachable --no-unpack-unreachable --no-sparse --no-thin --no-shallow --no-honor-pack-keep --no-keep-pack --no-compression --no-keep-true-parents --no-use-bitmap-index --no-write-bitmap-index --no-filter --no-exclude-promisor-objects --no-delta-islands --no-uri-protocol"
__gitcomp_builtin_pack_refs_default=" --all --prune --no-all -- --no-prune"
__gitcomp_builtin_pickaxe_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev"
__gitcomp_builtin_prune_default=" --dry-run --verbose --progress --expire= --exclude-promisor-objects --no-dry-run -- --no-verbose --no-progress --no-expire --no-exclude-promisor-objects"
__gitcomp_builtin_prune_packed_default=" --dry-run --quiet --no-dry-run -- --no-quiet"
-__gitcomp_builtin_pull_default=" --verbose --quiet --progress --recurse-submodules --rebase --stat --log --signoff --squash --commit --edit --cleanup= --ff --ff-only --verify-signatures --autostash --strategy= --strategy-option= --gpg-sign --allow-unrelated-histories --all --append --upload-pack= --force --tags --prune --jobs --dry-run --keep --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --show-forced-updates --set-upstream --no-verbose -- --no-quiet --no-progress --no-recurse-submodules --no-rebase --no-stat --no-log --no-signoff --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-verify-signatures --no-autostash --no-strategy --no-strategy-option --no-gpg-sign --no-allow-unrelated-histories --no-all --no-append --no-upload-pack --no-force --no-tags --no-prune --no-jobs --no-dry-run --no-keep --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-show-forced-updates --no-set-upstream"
-__gitcomp_builtin_push_default=" --verbose --quiet --repo= --all --mirror --delete --tags --dry-run --porcelain --force --force-with-lease --recurse-submodules= --receive-pack= --exec= --set-upstream --progress --prune --no-verify --follow-tags --signed --atomic --push-option= --ipv4 --ipv6 --verify -- --no-verbose --no-quiet --no-repo --no-all --no-mirror --no-delete --no-tags --no-dry-run --no-porcelain --no-force --no-force-with-lease --no-recurse-submodules --no-receive-pack --no-exec --no-set-upstream --no-progress --no-prune --no-follow-tags --no-signed --no-atomic --no-push-option --no-ipv4 --no-ipv6"
-__gitcomp_builtin_range_diff_default=" --creation-factor= --no-dual-color --notes --patch --no-patch --unified --function-context --raw --patch-with-raw --patch-with-stat --numstat --shortstat --dirstat --cumulative --dirstat-by-file --check --summary --name-only --name-status --stat --stat-width= --stat-name-width= --stat-graph-width= --stat-count= --compact-summary --binary --full-index --color --ws-error-highlight= --abbrev --src-prefix= --dst-prefix= --line-prefix= --no-prefix --inter-hunk-context= --output-indicator-new= --output-indicator-old= --output-indicator-context= --break-rewrites --find-renames --irreversible-delete --find-copies --find-copies-harder --no-renames --rename-empty --follow --minimal --ignore-all-space --ignore-space-change --ignore-space-at-eol --ignore-cr-at-eol --ignore-blank-lines --indent-heuristic --patience --histogram --diff-algorithm= --anchored= --word-diff --word-diff-regex= --color-words --color-moved --color-moved-ws= --relative --text --exit-code --quiet --ext-diff --textconv --ignore-submodules --submodule --ita-invisible-in-index --ita-visible-in-index --pickaxe-all --pickaxe-regex --find-object= --diff-filter= --output= --dual-color -- --no-creation-factor --no-notes --no-function-context --no-compact-summary --no-full-index --no-color --no-abbrev --no-find-copies-harder --no-rename-empty --no-follow --no-minimal --no-indent-heuristic --no-color-moved --no-color-moved-ws --no-relative --no-text --no-exit-code --no-quiet --no-ext-diff --no-textconv"
+__gitcomp_builtin_pull_default=" --verbose --quiet --progress --recurse-submodules --rebase --stat --log --signoff --squash --commit --edit --cleanup= --ff --ff-only --verify --verify-signatures --autostash --strategy= --strategy-option= --gpg-sign --allow-unrelated-histories --all --append --upload-pack= --force --tags --prune --jobs --dry-run --keep --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --show-forced-updates --set-upstream --no-verbose -- --no-quiet --no-progress --no-recurse-submodules --no-rebase --no-stat --no-log --no-signoff --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-verify --no-verify-signatures --no-autostash --no-strategy --no-strategy-option --no-gpg-sign --no-allow-unrelated-histories --no-all --no-append --no-upload-pack --no-force --no-tags --no-prune --no-jobs --no-dry-run --no-keep --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-show-forced-updates --no-set-upstream"
+__gitcomp_builtin_push_default=" --verbose --quiet --repo= --all --mirror --delete --tags --dry-run --porcelain --force --force-with-lease --force-if-includes --recurse-submodules= --receive-pack= --exec= --set-upstream --progress --prune --no-verify --follow-tags --signed --atomic --push-option= --ipv4 --ipv6 --verify -- --no-verbose --no-quiet --no-repo --no-all --no-mirror --no-delete --no-tags --no-dry-run --no-porcelain --no-force --no-force-with-lease --no-force-if-includes --no-recurse-submodules --no-receive-pack --no-exec --no-set-upstream --no-progress --no-prune --no-follow-tags --no-signed --no-atomic --no-push-option --no-ipv4 --no-ipv6"
+__gitcomp_builtin_range_diff_default=" --creation-factor= --no-dual-color --notes --left-only --right-only --patch --no-patch --unified --function-context --raw --patch-with-raw --patch-with-stat --numstat --shortstat --dirstat --cumulative --dirstat-by-file --check --summary --name-only --name-status --stat --stat-width= --stat-name-width= --stat-graph-width= --stat-count= --compact-summary --binary --full-index --color --ws-error-highlight= --abbrev --src-prefix= --dst-prefix= --line-prefix= --no-prefix --inter-hunk-context= --output-indicator-new= --output-indicator-old= --output-indicator-context= --break-rewrites --find-renames --irreversible-delete --find-copies --find-copies-harder --no-renames --rename-empty --follow --minimal --ignore-all-space --ignore-space-change --ignore-space-at-eol --ignore-cr-at-eol --ignore-blank-lines --ignore-matching-lines= --indent-heuristic --patience --histogram --diff-algorithm= --anchored= --word-diff --word-diff-regex= --color-words --color-moved --color-moved-ws= --relative --text --exit-code --quiet --ext-diff --textconv --ignore-submodules --submodule --ita-invisible-in-index --ita-visible-in-index --pickaxe-all --pickaxe-regex --rotate-to= --skip-to= --find-object= --diff-filter= --output= --dual-color -- --no-creation-factor --no-notes --no-left-only --no-right-only --no-function-context --no-compact-summary --no-full-index --no-color --no-abbrev --no-find-copies-harder --no-rename-empty --no-follow --no-minimal --no-ignore-matching-lines --no-indent-heuristic --no-color-moved --no-color-moved-ws --no-relative --no-text --no-exit-code --no-quiet --no-ext-diff --no-textconv"
__gitcomp_builtin_read_tree_default=" --index-output= --empty --verbose --trivial --aggressive --reset --prefix= --exclude-per-directory= --dry-run --no-sparse-checkout --debug-unpack --recurse-submodules --quiet --sparse-checkout -- --no-empty --no-verbose --no-trivial --no-aggressive --no-reset --no-dry-run --no-debug-unpack --no-recurse-submodules --no-quiet"
__gitcomp_builtin_rebase_default=" --onto= --keep-base --no-verify --quiet --verbose --no-stat --signoff --committer-date-is-author-date --reset-author-date --ignore-whitespace --whitespace= --force-rebase --no-ff --continue --skip --abort --quit --edit-todo --show-current-patch --apply --merge --interactive --rerere-autoupdate --empty= --autosquash --gpg-sign --autostash --exec= --rebase-merges --fork-point --strategy= --strategy-option= --root --reschedule-failed-exec --reapply-cherry-picks --verify --stat --ff -- --no-onto --no-keep-base --no-quiet --no-verbose --no-signoff --no-committer-date-is-author-date --no-reset-author-date --no-ignore-whitespace --no-whitespace --no-force-rebase --no-rerere-autoupdate --no-autosquash --no-gpg-sign --no-autostash --no-exec --no-rebase-merges --no-fork-point --no-strategy --no-strategy-option --no-root --no-reschedule-failed-exec --no-reapply-cherry-picks"
-__gitcomp_builtin_rebase__interactive_default=" --ff --rebase-merges --rebase-cousins --autosquash --signoff --verbose --continue --skip --edit-todo --show-current-patch --shorten-ids --expand-ids --check-todo-list --rearrange-squash --add-exec-commands --onto= --restrict-revision= --squash-onto= --upstream= --head-name= --gpg-sign --strategy= --strategy-opts= --switch-to= --onto-name= --cmd= --rerere-autoupdate --reschedule-failed-exec --no-ff -- --no-rebase-merges --no-rebase-cousins --no-autosquash --no-signoff --no-verbose --no-head-name --no-gpg-sign --no-strategy --no-strategy-opts --no-switch-to --no-onto-name --no-cmd --no-rerere-autoupdate --no-reschedule-failed-exec"
__gitcomp_builtin_receive_pack_default=" --quiet --no-quiet"
-__gitcomp_builtin_reflog_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_reflog_default=" --quiet --source --use-mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
__gitcomp_builtin_remote_default=" --verbose --no-verbose"
-__gitcomp_builtin_repack_default=" --quiet --local --write-bitmap-index --delta-islands --unpack-unreachable= --keep-unreachable --window= --window-memory= --depth= --threads= --max-pack-size= --pack-kept-objects --keep-pack= --no-quiet -- --no-local --no-write-bitmap-index --no-delta-islands --no-unpack-unreachable --no-keep-unreachable --no-window --no-window-memory --no-depth --no-threads --no-max-pack-size --no-pack-kept-objects --no-keep-pack"
+__gitcomp_builtin_repack_default=" --quiet --local --write-bitmap-index --delta-islands --unpack-unreachable= --keep-unreachable --window= --window-memory= --depth= --threads= --max-pack-size= --pack-kept-objects --keep-pack= --geometric= --write-midx --no-quiet -- --no-local --no-write-bitmap-index --no-delta-islands --no-unpack-unreachable --no-keep-unreachable --no-window --no-window-memory --no-depth --no-threads --no-max-pack-size --no-pack-kept-objects --no-keep-pack --no-geometric --no-write-midx"
__gitcomp_builtin_replace_default=" --list --delete --edit --graft --convert-graft-file --raw --format= --no-raw -- --no-format"
__gitcomp_builtin_rerere_default=" --rerere-autoupdate --no-rerere-autoupdate"
__gitcomp_builtin_reset_default=" --quiet --mixed --soft --hard --merge --keep --recurse-submodules --patch --intent-to-add --pathspec-from-file= --pathspec-file-nul --no-quiet -- --no-mixed --no-soft --no-hard --no-merge --no-keep --no-recurse-submodules --no-patch --no-intent-to-add --no-pathspec-from-file --no-pathspec-file-nul"
__gitcomp_builtin_restore_default=" --source= --staged --worktree --ignore-unmerged --overlay --quiet --recurse-submodules --progress --merge --conflict= --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-source -- --no-staged --no-worktree --no-ignore-unmerged --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul"
__gitcomp_builtin_revert_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign"
-__gitcomp_builtin_rm_default=" --dry-run --quiet --cached --ignore-unmatch --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-quiet --no-cached --no-ignore-unmatch --no-pathspec-from-file --no-pathspec-file-nul"
-__gitcomp_builtin_send_pack_default=" --verbose --quiet --receive-pack= --exec= --remote= --all --dry-run --mirror --force --signed --push-option= --progress --thin --atomic --stateless-rpc --stdin --helper-status --force-with-lease --no-verbose -- --no-quiet --no-receive-pack --no-exec --no-remote --no-all --no-dry-run --no-mirror --no-force --no-signed --no-push-option --no-progress --no-thin --no-atomic --no-stateless-rpc --no-stdin --no-helper-status --no-force-with-lease"
+__gitcomp_builtin_rm_default=" --dry-run --quiet --cached --ignore-unmatch --sparse --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-quiet --no-cached --no-ignore-unmatch --no-sparse --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_send_pack_default=" --verbose --quiet --receive-pack= --exec= --remote= --all --dry-run --mirror --force --signed --push-option= --progress --thin --atomic --stateless-rpc --stdin --helper-status --force-with-lease --force-if-includes --no-verbose -- --no-quiet --no-receive-pack --no-exec --no-remote --no-all --no-dry-run --no-mirror --no-force --no-signed --no-push-option --no-progress --no-thin --no-atomic --no-stateless-rpc --no-stdin --no-helper-status --no-force-with-lease --no-force-if-includes"
__gitcomp_builtin_shortlog_default=" --committer --numbered --summary --email --group= --no-committer -- --no-numbered --no-summary --no-email --no-group"
-__gitcomp_builtin_show_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_show_default=" --quiet --source --use-mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
__gitcomp_builtin_show_branch_default=" --all --remotes --color --more --list --no-name --current --sha1-name --merge-base --independent --topo-order --topics --sparse --date-order --reflog --name -- --no-all --no-remotes --no-color --no-more --no-list --no-current --no-sha1-name --no-merge-base --no-independent --no-topo-order --no-topics --no-sparse --no-date-order"
__gitcomp_builtin_show_index_default=" --object-format= --no-object-format"
__gitcomp_builtin_show_ref_default=" --tags --heads --verify --head --dereference --hash --abbrev --quiet --exclude-existing --no-tags -- --no-heads --no-verify --no-head --no-dereference --no-hash --no-abbrev --no-quiet"
__gitcomp_builtin_sparse_checkout_default=""
-__gitcomp_builtin_stage_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
+__gitcomp_builtin_stage_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --sparse --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-sparse --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
__gitcomp_builtin_stash_default=""
__gitcomp_builtin_status_default=" --verbose --short --branch --show-stash --ahead-behind --porcelain --long --null --untracked-files --ignored --ignore-submodules --column --no-renames --find-renames --renames -- --no-verbose --no-short --no-branch --no-show-stash --no-ahead-behind --no-porcelain --no-long --no-null --no-untracked-files --no-ignored --no-ignore-submodules --no-column"
__gitcomp_builtin_stripspace_default=" --strip-comments --comment-lines"
__gitcomp_builtin_switch_default=" --create= --force-create= --guess --discard-changes --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --no-create -- --no-force-create --no-guess --no-discard-changes --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees"
__gitcomp_builtin_symbolic_ref_default=" --quiet --delete --short --no-quiet -- --no-delete --no-short"
-__gitcomp_builtin_tag_default=" --list --delete --verify --annotate --message= --file= --edit --sign --cleanup= --local-user= --force --create-reflog --column --contains --no-contains --merged --no-merged --sort= --points-at --format= --color --ignore-case -- --no-annotate --no-file --no-edit --no-sign --no-cleanup --no-local-user --no-force --no-create-reflog --no-column --no-points-at --no-format --no-color --no-ignore-case"
+__gitcomp_builtin_tag_default=" --list --delete --verify --annotate --message= --file= --edit --sign --cleanup= --local-user= --force --create-reflog --column --contains --no-contains --merged --no-merged --sort= --points-at --format= --color --ignore-case -- --no-annotate --no-file --no-edit --no-sign --no-cleanup --no-local-user --no-force --no-create-reflog --no-column --no-sort --no-points-at --no-format --no-color --no-ignore-case"
__gitcomp_builtin_update_index_default=" --ignore-submodules --add --replace --remove --unmerged --refresh --really-refresh --cacheinfo --chmod= --assume-unchanged --no-assume-unchanged --skip-worktree --no-skip-worktree --ignore-skip-worktree-entries --info-only --force-remove --stdin --index-info --unresolve --again --ignore-missing --verbose --clear-resolve-undo --index-version= --split-index --untracked-cache --test-untracked-cache --force-untracked-cache --force-write-index --fsmonitor --fsmonitor-valid --no-fsmonitor-valid -- --no-ignore-submodules --no-add --no-replace --no-remove --no-unmerged --no-ignore-skip-worktree-entries --no-info-only --no-force-remove --no-ignore-missing --no-verbose --no-index-version --no-split-index --no-untracked-cache --no-test-untracked-cache --no-force-untracked-cache --no-force-write-index --no-fsmonitor"
__gitcomp_builtin_update_ref_default=" --no-deref --stdin --create-reflog --deref -- --no-stdin --no-create-reflog"
__gitcomp_builtin_update_server_info_default=" --force --no-force"
-__gitcomp_builtin_upload_pack_default=" --stateless-rpc --advertise-refs --strict --timeout= --no-stateless-rpc -- --no-advertise-refs --no-strict --no-timeout"
+__gitcomp_builtin_upload_pack_default=" --stateless-rpc --strict --timeout= --no-stateless-rpc -- --no-strict --no-timeout"
__gitcomp_builtin_verify_commit_default=" --verbose --raw --no-verbose -- --no-raw"
__gitcomp_builtin_verify_pack_default=" --verbose --stat-only --object-format= --no-verbose -- --no-stat-only --no-object-format"
__gitcomp_builtin_verify_tag_default=" --verbose --raw --format= --no-verbose -- --no-raw --no-format"
__gitcomp_builtin_version_default=" --build-options --no-build-options"
-__gitcomp_builtin_whatchanged_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
+__gitcomp_builtin_whatchanged_default=" --quiet --source --use-mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
__gitcomp_builtin_write_tree_default=" --missing-ok --prefix= --no-missing-ok -- --no-prefix"
-__gitcomp_builtin_send_email_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
+__gitcomp_builtin_send_email_default="--cc= --smtp-server= --identity= --smtp-ssl --sender= --from= --cc-cover --no-to-cover --sendmail-cmd= --signed-off-cc --signed-off-by-cc --in-reply-to= --no-cc --confirm= --no-bcc --to= --annotate --smtp-encryption= --relogin-delay= --to-cmd= --smtp-domain= --smtp-auth= --bcc= --quiet --subject= --chain-reply-to --cc-cmd= --no-format-patch --transfer-encoding= --smtp-user= --reply-to= --force --dry-run --no-identity --no-validate --8bit-encoding= --to-cover --compose --thread --format-patch --no-thread --smtp-server-option= --compose-encoding= --smtp-server-port= --no-smtp-auth --no-signed-off-cc --no-signed-off-by-cc --smtp-debug= --no-suppress-from --suppress-from --no-to --dump-aliases --xmailer --no-annotate --no-cc-cover --smtp-pass= --smtp-ssl-cert-path= --no-chain-reply-to --suppress-cc= --validate --batch-size= --envelope-sender= --no-xmailer --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --filename-max-length= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --from --attach --inline --signature= --base= --signature-file= --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-filename-max-length --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-from --no-in-reply-to --no-attach --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
__gitcomp_builtin_get_default ()
{
@@ -500,7 +425,7 @@ __gitcomp_builtin_get_default ()
# This function is equivalent to
#
-# __gitcomp "$(git xxx --git-completion-helper) ..."
+# __gitcomp_opts "$(git xxx --git-completion-helper) ..."
#
# except that the output is cached. Accept 1-3 arguments:
# 1: the git command to execute, this is also the cache key
@@ -520,7 +445,7 @@ __gitcomp_builtin ()
if [ -z "$options" ]; then
local completion_helper
- if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then
+ if [ "${GIT_COMPLETION_SHOW_ALL-}" = "1" ]; then
completion_helper="--git-completion-helper-all"
else
completion_helper="--git-completion-helper"
@@ -537,71 +462,7 @@ __gitcomp_builtin ()
eval "$var=\"$options\""
fi
- __gitcomp "$options"
-}
-
-# Variation of __gitcomp_nl () that appends to the existing list of
-# completion candidates, COMPREPLY.
-__gitcomp_nl_append ()
-{
- local IFS=$'\n'
- __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
-}
-
-# Generates completion reply from newline-separated possible completion words
-# by appending a space to all of them.
-# It accepts 1 to 4 arguments:
-# 1: List of possible completion words, separated by a single newline.
-# 2: A prefix to be added to each possible completion word (optional).
-# 3: Generate possible completion matches for this word (optional).
-# 4: A suffix to be appended to each possible completion word instead of
-# the default space (optional). If specified but empty, nothing is
-# appended.
-__gitcomp_nl ()
-{
- COMPREPLY=()
- __gitcomp_nl_append "$@"
-}
-
-# Fills the COMPREPLY array with prefiltered paths without any additional
-# processing.
-# Callers must take care of providing only paths that match the current path
-# to be completed and adding any prefix path components, if necessary.
-# 1: List of newline-separated matching paths, complete with all prefix
-# path components.
-__gitcomp_file_direct ()
-{
- local IFS=$'\n'
-
- COMPREPLY=($1)
-
- # use a hack to enable file mode in bash < 4
- compopt -o filenames +o nospace 2>/dev/null ||
- compgen -f /non-existing-dir/ >/dev/null ||
- true
-}
-
-# Generates completion reply with compgen from newline-separated possible
-# completion filenames.
-# It accepts 1 to 3 arguments:
-# 1: List of possible completion filenames, separated by a single newline.
-# 2: A directory prefix to be added to each possible completion filename
-# (optional).
-# 3: Generate possible completion matches for this word (optional).
-__gitcomp_file ()
-{
- local IFS=$'\n'
-
- # XXX does not work when the directory prefix contains a tilde,
- # since tilde expansion is not applied.
- # This means that COMPREPLY will be empty and Bash default
- # completion will be used.
- __gitcompadd "$1" "${2-}" "${3-$cur}" ""
-
- # use a hack to enable file mode in bash < 4
- compopt -o filenames +o nospace 2>/dev/null ||
- compgen -f /non-existing-dir/ >/dev/null ||
- true
+ __gitcomp_opts "$options"
}
# Execute 'git ls-files', unless the --committable option is specified, in
@@ -610,7 +471,7 @@ __gitcomp_file ()
# argument, and using the options specified in the second argument.
__git_ls_files_helper ()
{
- if [ "$2" == "--committable" ]; then
+ if [ "$2" = "--committable" ]; then
__git -C "$1" -c core.quotePath=false diff-index \
--name-only --relative HEAD -- "${3//\\/\\\\}*"
else
@@ -839,7 +700,7 @@ __git_refs ()
track=""
;;
*)
- for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
+ for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD; do
case "$i" in
$match*)
if [ -e "$dir/$i" ]; then
@@ -947,7 +808,7 @@ __git_complete_refs ()
# Append DWIM remote branch names if requested
if [ "$dwim" = "yes" ]; then
- __gitcomp_direct_append "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")"
+ __gitcomp_direct "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")"
fi
}
@@ -1103,8 +964,8 @@ __git_complete_revlist ()
__git_complete_remote_or_refspec ()
{
- local cur_="$cur" cmd="${words[1]}"
- local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
+ local cur_="$cur" cmd="${words[__git_cmd_idx]}"
+ local i c=$((__git_cmd_idx+1)) remote="" pfx="" lhs=1 no_complete_refspec=0
if [ "$cmd" = "remote" ]; then
((c++))
fi
@@ -1184,7 +1045,7 @@ __git_complete_strategy ()
return 0
;;
-X)
- __gitcomp "$__git_merge_strategy_options"
+ __gitcomp_opts "$__git_merge_strategy_options"
return 0
;;
esac
@@ -1194,7 +1055,7 @@ __git_complete_strategy ()
return 0
;;
--strategy-option=*)
- __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
+ __gitcomp_opts "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
return 0
;;
esac
@@ -1226,7 +1087,7 @@ __git_pretty_aliases ()
# __git_aliased_command requires 1 argument
__git_aliased_command ()
{
- local cur=$1 last list word cmdline
+ local cur=$1 last list= word cmdline
while [[ -n "$cur" ]]; do
if [[ "$list" == *" $cur "* ]]; then
@@ -1273,7 +1134,7 @@ __git_aliased_command ()
# --show-idx: Optionally show the index of the found word in the $words array.
__git_find_on_cmdline ()
{
- local word c=1 show_idx
+ local word c="$__git_cmd_idx" show_idx
while test $# -gt 1; do
case "$1" in
@@ -1318,7 +1179,7 @@ __git_find_last_on_cmdline ()
done
local wordlist="$1"
- while [ $c -gt 1 ]; do
+ while [ $c -gt "$__git_cmd_idx" ]; do
((c--))
for word in $wordlist; do
if [ "$word" = "${words[c]}" ]; then
@@ -1403,7 +1264,7 @@ __git_count_arguments ()
local word i c=0
# Skip "git" (first argument)
- for ((i=1; i < ${#words[@]}; i++)); do
+ for ((i=$__git_cmd_idx; i < ${#words[@]}; i++)); do
word="${words[i]}"
case "$word" in
@@ -1430,12 +1291,13 @@ __git_whitespacelist="nowarn warn error error-all fix"
__git_patchformat="mbox stgit stgit-series hg mboxrd"
__git_showcurrentpatch="diff raw"
__git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
+__git_quoted_cr="nowarn warn strip"
_git_am ()
{
__git_find_repo_path
if [ -d "$__git_repo_path"/rebase-apply ]; then
- __gitcomp "$__git_am_inprogress_options"
+ __gitcomp_opts "$__git_am_inprogress_options"
return
fi
case "$cur" in
@@ -1451,6 +1313,10 @@ _git_am ()
__gitcomp "$__git_showcurrentpatch" "" "${cur##--show-current-patch=}"
return
;;
+ --quoted-cr=*)
+ __gitcomp "$__git_quoted_cr" "" "${cur##--quoted-cr=}"
+ return
+ ;;
--*)
__gitcomp_builtin am "" \
"$__git_am_inprogress_options"
@@ -1495,7 +1361,7 @@ _git_archive ()
{
case "$cur" in
--format=*)
- __gitcomp "$(git archive --list)" "" "${cur##--format=}"
+ __gitcomp_nl "$(git archive --list)" "" "${cur##--format=}"
return
;;
--remote=*)
@@ -1539,13 +1405,15 @@ __git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD
_git_branch ()
{
- local i c=1 only_local_ref="n" has_r="n"
+ local i c="$__git_cmd_idx" only_local_ref="n" has_r="n"
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
- -d|--delete|-m|--move) only_local_ref="y" ;;
- -r|--remotes) has_r="y" ;;
+ -d|-D|--delete|-m|-M|--move|-c|-C|--copy)
+ only_local_ref="y" ;;
+ -r|--remotes)
+ has_r="y" ;;
esac
((c++))
done
@@ -1569,12 +1437,12 @@ _git_branch ()
_git_bundle ()
{
- local cmd="${words[2]}"
+ local cmd="${words[__git_cmd_idx+1]}"
case "$cword" in
- 2)
+ $((__git_cmd_idx+1)))
__gitcomp "create list-heads verify unbundle"
;;
- 3)
+ $((__git_cmd_idx+2)))
# looking for a file
;;
*)
@@ -1590,14 +1458,15 @@ _git_bundle ()
# Helper function to decide whether or not we should enable DWIM logic for
# git-switch and git-checkout.
#
-# To decide between the following rules in priority order
-# 1) the last provided of "--guess" or "--no-guess" explicitly enable or
-# disable completion of DWIM logic respectively.
-# 2) If the --no-track option is provided, take this as a hint to disable the
-# DWIM completion logic
-# 3) If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
-# logic, as requested by the user.
-# 4) Enable DWIM logic otherwise.
+# To decide between the following rules in decreasing priority order:
+# - the last provided of "--guess" or "--no-guess" explicitly enable or
+# disable completion of DWIM logic respectively.
+# - If checkout.guess is false, disable completion of DWIM logic.
+# - If the --no-track option is provided, take this as a hint to disable the
+# DWIM completion logic
+# - If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
+# logic, as requested by the user.
+# - Enable DWIM logic otherwise.
#
__git_checkout_default_dwim_mode ()
{
@@ -1608,11 +1477,17 @@ __git_checkout_default_dwim_mode ()
fi
# --no-track disables DWIM, but with lower priority than
- # --guess/--no-guess
+ # --guess/--no-guess/checkout.guess
if [ -n "$(__git_find_on_cmdline "--no-track")" ]; then
dwim_opt=""
fi
+ # checkout.guess = false disables DWIM, but with lower priority than
+ # --guess/--no-guess
+ if [ "$(__git config --type=bool checkout.guess)" = "false" ]; then
+ dwim_opt=""
+ fi
+
# Find the last provided --guess or --no-guess
last_option="$(__git_find_last_on_cmdline "--guess --no-guess")"
case "$last_option" in
@@ -1649,7 +1524,7 @@ _git_checkout ()
case "$cur" in
--conflict=*)
- __gitcomp "diff3 merge" "" "${cur##--conflict=}"
+ __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}"
;;
--*)
__gitcomp_builtin checkout
@@ -1682,7 +1557,7 @@ _git_cherry_pick ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
- __gitcomp "$__git_cherry_pick_inprogress_options"
+ __gitcomp_opts "$__git_cherry_pick_inprogress_options"
return
fi
@@ -1811,8 +1686,14 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--submodule --submodule= --ignore-submodules
--indent-heuristic --no-indent-heuristic
--textconv --no-textconv
+ --patch --no-patch
+ --anchored=
"
+__git_diff_difftool_options="--cached --staged --pickaxe-all --pickaxe-regex
+ --base --ours --theirs --no-index --relative --merge-base
+ $__git_diff_common_options"
+
_git_diff ()
{
__git_has_doubledash && return
@@ -1835,10 +1716,7 @@ _git_diff ()
return
;;
--*)
- __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
- --base --ours --theirs --no-index
- $__git_diff_common_options
- "
+ __gitcomp_opts "$__git_diff_difftool_options"
return
;;
esac
@@ -1860,11 +1738,7 @@ _git_difftool ()
return
;;
--*)
- __gitcomp_builtin difftool "$__git_diff_common_options
- --base --cached --ours --theirs
- --pickaxe-all --pickaxe-regex
- --relative --staged
- "
+ __gitcomp_builtin difftool "$__git_diff_difftool_options"
return
;;
esac
@@ -1901,9 +1775,7 @@ _git_format_patch ()
{
case "$cur" in
--thread=*)
- __gitcomp "
- deep shallow
- " "" "${cur##--thread=}"
+ __gitcomp "deep shallow" "" "${cur##--thread=}"
return
;;
--base=*|--interdiff=*|--range-diff=*)
@@ -1930,7 +1802,7 @@ _git_fsck ()
_git_gitk ()
{
- _gitk
+ __gitk_main
}
# Lists matching symbol names from a tag (as in ctags) file.
@@ -1984,7 +1856,7 @@ _git_grep ()
esac
case "$cword,$prev" in
- 2,*|*,-*)
+ $((__git_cmd_idx+1)),*|*,-*)
__git_complete_symbol && return
;;
esac
@@ -2000,7 +1872,7 @@ _git_help ()
return
;;
esac
- if test -n "$GIT_TESTING_ALL_COMMAND_LIST"
+ if test -n "${GIT_TESTING_ALL_COMMAND_LIST-}"
then
__gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
else
@@ -2085,7 +1957,7 @@ __git_log_shortlog_options="
"
__git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
-__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:"
+__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:"
_git_log ()
{
@@ -2136,7 +2008,7 @@ _git_log ()
return
;;
--*)
- __gitcomp "
+ __gitcomp_opts "
$__git_log_common_options
$__git_log_shortlog_options
$__git_log_gitk_options
@@ -2154,11 +2026,9 @@ _git_log ()
--no-walk --no-walk= --do-walk
--parents --children
--expand-tabs --expand-tabs= --no-expand-tabs
- --patch
$merge
$__git_diff_common_options
--pickaxe-all --pickaxe-regex
- --patch --no-patch
"
return
;;
@@ -2201,7 +2071,7 @@ _git_mergetool ()
return
;;
--*)
- __gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
+ __gitcomp_opts "--tool= --prompt --no-prompt --gui --no-gui"
return
;;
esac
@@ -2349,7 +2219,7 @@ _git_range_diff ()
{
case "$cur" in
--*)
- __gitcomp "
+ __gitcomp_opts "
--creation-factor= --no-dual-color
$__git_diff_common_options
"
@@ -2366,11 +2236,11 @@ _git_rebase ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
- __gitcomp "$__git_rebase_interactive_inprogress_options"
+ __gitcomp_opts "$__git_rebase_interactive_inprogress_options"
return
elif [ -d "$__git_repo_path"/rebase-apply ] || \
[ -d "$__git_repo_path"/rebase-merge ]; then
- __gitcomp "$__git_rebase_inprogress_options"
+ __gitcomp_opts "$__git_rebase_inprogress_options"
return
fi
__git_complete_strategy && return
@@ -2404,6 +2274,7 @@ _git_reflog ()
fi
}
+__git_send_email_options="--no-cc-cover --cc= --no-bcc --force --relogin-delay= --to= --suppress-cc= --no-annotate --no-chain-reply-to --sendmail-cmd= --no-identity --transfer-encoding= --validate --no-smtp-auth --confirm= --no-format-patch --reply-to= --smtp-pass= --smtp-server= --annotate --envelope-sender= --no-validate --dry-run --no-thread --smtp-debug= --no-to --thread --no-xmailer --identity= --no-signed-off-cc --no-signed-off-by-cc --smtp-domain= --to-cover --8bit-encoding= --bcc= --smtp-ssl-cert-path= --smtp-user= --cc-cmd= --to-cmd= --no-cc --smtp-server-option= --in-reply-to= --subject= --batch-size= --smtp-auth= --compose --smtp-server-port= --xmailer --no-to-cover --chain-reply-to --smtp-encryption= --dump-aliases --quiet --smtp-ssl --signed-off-cc --signed-off-by-cc --suppress-from --compose-encoding= --no-suppress-from --sender= --from= --format-patch --cc-cover --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --filename-max-length= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --from --attach --inline --signature= --base= --signature-file= --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-filename-max-length --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-from --no-in-reply-to --no-attach --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
__git_send_email_confirm_options="always never auto cc compose"
__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
@@ -2411,7 +2282,7 @@ _git_send_email ()
{
case "$prev" in
--to|--cc|--bcc|--from)
- __gitcomp "$(__git send-email --dump-aliases)"
+ __gitcomp_nl "$(__git send-email --dump-aliases)"
return
;;
esac
@@ -2435,9 +2306,7 @@ _git_send_email ()
return
;;
--thread=*)
- __gitcomp "
- deep shallow
- " "" "${cur##--thread=}"
+ __gitcomp "deep shallow" "" "${cur##--thread=}"
return
;;
--to=*|--cc=*|--bcc=*|--from=*)
@@ -2445,16 +2314,7 @@ _git_send_email ()
return
;;
--*)
- __gitcomp_builtin send-email "--annotate --bcc --cc --cc-cmd --chain-reply-to
- --compose --confirm= --dry-run --envelope-sender
- --from --identity
- --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
- --no-suppress-from --no-thread --quiet --reply-to
- --signed-off-by-cc --smtp-pass --smtp-server
- --smtp-server-port --smtp-encryption= --smtp-user
- --subject --suppress-cc= --suppress-from --thread --to
- --validate --no-validate
- $__git_format_patch_extra_options"
+ __gitcomp_builtin send-email "$__git_send_email_options $__git_format_patch_extra_options"
return
;;
esac
@@ -2532,7 +2392,7 @@ _git_switch ()
case "$cur" in
--conflict=*)
- __gitcomp "diff3 merge" "" "${cur##--conflict=}"
+ __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}"
;;
--*)
__gitcomp_builtin switch
@@ -2566,7 +2426,7 @@ _git_switch ()
__git_config_get_set_variables ()
{
local prevword word config_file= c=$cword
- while [ $c -gt 1 ]; do
+ while [ $c -gt "$__git_cmd_idx" ]; do
word="${words[c]}"
case "$word" in
--system|--global|--local|--file=*)
@@ -2629,7 +2489,7 @@ __git_complete_config_variable_value ()
return
;;
branch.*.rebase)
- __gitcomp "false true merges preserve interactive" "" "$cur_"
+ __gitcomp "false true merges interactive" "" "$cur_"
return
;;
remote.pushdefault)
@@ -2717,7 +2577,7 @@ __git_complete_config_variable_value ()
# subsections) instead of the default space.
__git_complete_config_variable_name ()
{
- local cur_="$cur" sfx
+ local cur_="$cur" sfx=" "
while test $# != 0; do
case "$1" in
@@ -2739,7 +2599,7 @@ __git_complete_config_variable_name ()
local pfx="${cur_%.*}."
cur_="${cur_#*.}"
__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
- __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx:- }"
+ __gitcomp "autoSetupMerge autoSetupRebase" "$pfx" "$cur_" "$sfx"
return
;;
guitool.*.*)
@@ -2773,7 +2633,7 @@ __git_complete_config_variable_name ()
local pfx="${cur_%.*}."
cur_="${cur_#*.}"
__git_compute_all_commands
- __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }"
+ __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "$sfx"
return
;;
remote.*.*)
@@ -2789,7 +2649,7 @@ __git_complete_config_variable_name ()
local pfx="${cur_%.*}."
cur_="${cur_#*.}"
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
- __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx:- }"
+ __gitcomp "pushDefault" "$pfx" "$cur_" "$sfx"
return
;;
url.*.*)
@@ -2804,7 +2664,7 @@ __git_complete_config_variable_name ()
;;
*)
__git_compute_config_vars
- __gitcomp "$(echo "$__git_config_vars" |
+ __gitcomp_nl "$(echo "$__git_config_vars" |
awk -F . '{
sections[$1] = 1
}
@@ -2812,7 +2672,7 @@ __git_complete_config_variable_name ()
for (s in sections)
print s "."
}
- ')" "" "$cur_"
+ ')" "" "$cur_" ""
;;
esac
}
@@ -2906,7 +2766,7 @@ _git_remote ()
__gitcomp_builtin remote_update
;;
update,*)
- __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")"
+ __gitcomp_nl "$(__git_remotes) $(__git_get_config_variables "remotes")"
;;
set-url,--*)
__gitcomp_builtin remote_set-url
@@ -2973,7 +2833,7 @@ _git_restore ()
case "$cur" in
--conflict=*)
- __gitcomp "diff3 merge" "" "${cur##--conflict=}"
+ __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}"
;;
--source=*)
__git_complete_refs --cur="${cur##--source=}"
@@ -2990,7 +2850,7 @@ _git_revert ()
{
__git_find_repo_path
if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
- __gitcomp "$__git_revert_inprogress_options"
+ __gitcomp_opts "$__git_revert_inprogress_options"
return
fi
__git_complete_strategy && return
@@ -3022,7 +2882,7 @@ _git_shortlog ()
case "$cur" in
--*)
- __gitcomp "
+ __gitcomp_opts "
$__git_log_common_options
$__git_log_shortlog_options
--numbered --summary --email
@@ -3060,8 +2920,8 @@ _git_show ()
return
;;
--*)
- __gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
- --oneline --show-signature --patch
+ __gitcomp_opts "--pretty= --format= --abbrev-commit --no-abbrev-commit
+ --oneline --show-signature
--expand-tabs --expand-tabs= --no-expand-tabs
$__git_diff_common_options
"
@@ -3093,10 +2953,10 @@ _git_sparse_checkout ()
case "$subcommand,$cur" in
init,--*)
- __gitcomp "--cone"
+ __gitcomp_opts "--cone"
;;
set,--*)
- __gitcomp "--stdin"
+ __gitcomp_opts "--stdin"
;;
*)
;;
@@ -3105,63 +2965,48 @@ _git_sparse_checkout ()
_git_stash ()
{
- local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
local subcommands='push list show apply clear drop pop create branch'
local subcommand="$(__git_find_on_cmdline "$subcommands save")"
- if [ -z "$subcommand" -a -n "$(__git_find_on_cmdline "-p")" ]; then
- subcommand="push"
- fi
+
if [ -z "$subcommand" ]; then
- case "$cur" in
- --*)
- __gitcomp "$save_opts"
+ case "$((cword - __git_cmd_idx)),$cur" in
+ *,--*)
+ __gitcomp_builtin stash_push
;;
- sa*)
- if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
- __gitcomp "save"
- fi
+ 1,sa*)
+ __gitcomp "save"
;;
- *)
- if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
- __gitcomp "$subcommands"
- fi
+ 1,*)
+ __gitcomp "$subcommands"
;;
esac
- else
- case "$subcommand,$cur" in
- push,--*)
- __gitcomp "$save_opts --message"
- ;;
- save,--*)
- __gitcomp "$save_opts"
- ;;
- apply,--*|pop,--*)
- __gitcomp "--index --quiet"
- ;;
- drop,--*)
- __gitcomp "--quiet"
- ;;
- list,--*)
- __gitcomp "--name-status --oneline --patch-with-stat"
- ;;
- show,--*|branch,--*)
- ;;
- branch,*)
- if [ $cword -eq 3 ]; then
- __git_complete_refs
- else
- __gitcomp_nl "$(__git stash list \
- | sed -n -e 's/:.*//p')"
- fi
- ;;
- show,*|apply,*|drop,*|pop,*)
+ return
+ fi
+
+ case "$subcommand,$cur" in
+ list,--*)
+ # NEEDSWORK: can we somehow unify this with the options in _git_log() and _git_show()
+ __gitcomp_builtin stash_list "$__git_log_common_options $__git_diff_common_options"
+ ;;
+ show,--*)
+ __gitcomp_builtin stash_show "$__git_diff_common_options"
+ ;;
+ *,--*)
+ __gitcomp_builtin "stash_$subcommand"
+ ;;
+ branch,*)
+ if [ $cword -eq $((__git_cmd_idx+2)) ]; then
+ __git_complete_refs
+ else
__gitcomp_nl "$(__git stash list \
| sed -n -e 's/:.*//p')"
- ;;
- *)
- ;;
- esac
- fi
+ fi
+ ;;
+ show,*|apply,*|drop,*|pop,*)
+ __gitcomp_nl "$(__git stash list \
+ | sed -n -e 's/:.*//p')"
+ ;;
+ esac
}
_git_submodule ()
@@ -3173,7 +3018,7 @@ _git_submodule ()
if [ -z "$subcommand" ]; then
case "$cur" in
--*)
- __gitcomp "--quiet"
+ __gitcomp_opts "--quiet"
;;
*)
__gitcomp "$subcommands"
@@ -3184,29 +3029,29 @@ _git_submodule ()
case "$subcommand,$cur" in
add,--*)
- __gitcomp "--branch --force --name --reference --depth"
+ __gitcomp_opts "--branch --force --name --reference --depth"
;;
status,--*)
- __gitcomp "--cached --recursive"
+ __gitcomp_opts "--cached --recursive"
;;
deinit,--*)
- __gitcomp "--force --all"
+ __gitcomp_opts "--force --all"
;;
update,--*)
- __gitcomp "
+ __gitcomp_opts "
--init --remote --no-fetch
--recommend-shallow --no-recommend-shallow
--force --rebase --merge --reference --depth --recursive --jobs
"
;;
set-branch,--*)
- __gitcomp "--default --branch"
+ __gitcomp_opts "--default --branch"
;;
summary,--*)
- __gitcomp "--cached --files --summary-limit"
+ __gitcomp_opts "--cached --files --summary-limit"
;;
foreach,--*|sync,--*)
- __gitcomp "--recursive"
+ __gitcomp_opts "--recursive"
;;
*)
;;
@@ -3247,64 +3092,64 @@ _git_svn ()
case "$subcommand,$cur" in
fetch,--*)
- __gitcomp "--revision= --fetch-all $fc_opts"
+ __gitcomp_opts "--revision= --fetch-all $fc_opts"
;;
clone,--*)
- __gitcomp "--revision= $fc_opts $init_opts"
+ __gitcomp_opts "--revision= $fc_opts $init_opts"
;;
init,--*)
- __gitcomp "$init_opts"
+ __gitcomp_opts "$init_opts"
;;
dcommit,--*)
- __gitcomp "
+ __gitcomp_opts "
--merge --strategy= --verbose --dry-run
--fetch-all --no-rebase --commit-url
--revision --interactive $cmt_opts $fc_opts
"
;;
set-tree,--*)
- __gitcomp "--stdin $cmt_opts $fc_opts"
+ __gitcomp_opts "--stdin $cmt_opts $fc_opts"
;;
create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
show-externals,--*|mkdirs,--*)
- __gitcomp "--revision="
+ __gitcomp_opts "--revision="
;;
log,--*)
- __gitcomp "
+ __gitcomp_opts "
--limit= --revision= --verbose --incremental
--oneline --show-commit --non-recursive
--authors-file= --color
"
;;
rebase,--*)
- __gitcomp "
+ __gitcomp_opts "
--merge --verbose --strategy= --local
--fetch-all --dry-run $fc_opts
"
;;
commit-diff,--*)
- __gitcomp "--message= --file= --revision= $cmt_opts"
+ __gitcomp_opts "--message= --file= --revision= $cmt_opts"
;;
info,--*)
- __gitcomp "--url"
+ __gitcomp_opts "--url"
;;
branch,--*)
- __gitcomp "--dry-run --message --tag"
+ __gitcomp_opts "--dry-run --message --tag"
;;
tag,--*)
- __gitcomp "--dry-run --message"
+ __gitcomp_opts "--dry-run --message"
;;
blame,--*)
- __gitcomp "--git-format"
+ __gitcomp_opts "--git-format"
;;
migrate,--*)
- __gitcomp "
+ __gitcomp_opts "
--config-dir= --ignore-paths= --minimize
--no-auth-cache --username=
"
;;
reset,--*)
- __gitcomp "--revision= --parent"
+ __gitcomp_opts "--revision= --parent"
;;
*)
;;
@@ -3314,7 +3159,7 @@ _git_svn ()
_git_tag ()
{
- local i c=1 f=0
+ local i c="$__git_cmd_idx" f=0
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
@@ -3357,9 +3202,10 @@ _git_whatchanged ()
__git_complete_worktree_paths ()
{
local IFS=$'\n'
+ # Generate completion reply from worktree list skipping the first
+ # entry: it's the path of the main worktree, which can't be moved,
+ # removed, locked, etc.
__gitcomp_nl "$(git worktree list --porcelain |
- # Skip the first entry: it's the path of the main worktree,
- # which can't be moved, removed, locked, etc.
sed -n -e '2,$ s/^worktree //p')"
}
@@ -3458,15 +3304,19 @@ __git_support_parseopt_helper () {
esac
}
+__git_have_func () {
+ declare -f -- "$1" >/dev/null 2>&1
+}
+
__git_complete_command () {
local command="$1"
local completion_func="_git_${command//-/_}"
- if ! declare -f $completion_func >/dev/null 2>/dev/null &&
- declare -f _completion_loader >/dev/null 2>/dev/null
+ if ! __git_have_func $completion_func &&
+ __git_have_func _completion_loader
then
_completion_loader "git-$command"
fi
- if declare -f $completion_func >/dev/null 2>/dev/null
+ if __git_have_func $completion_func
then
$completion_func
return 0
@@ -3483,21 +3333,40 @@ __git_main ()
{
local i c=1 command __git_dir __git_repo_path
local __git_C_args C_args_count=0
+ local __git_cmd_idx
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
- --git-dir=*) __git_dir="${i#--git-dir=}" ;;
- --git-dir) ((c++)) ; __git_dir="${words[c]}" ;;
- --bare) __git_dir="." ;;
- --help) command="help"; break ;;
- -c|--work-tree|--namespace) ((c++)) ;;
- -C) __git_C_args[C_args_count++]=-C
+ --git-dir=*)
+ __git_dir="${i#--git-dir=}"
+ ;;
+ --git-dir)
+ ((c++))
+ __git_dir="${words[c]}"
+ ;;
+ --bare)
+ __git_dir="."
+ ;;
+ --help)
+ command="help"
+ break
+ ;;
+ -c|--work-tree|--namespace)
+ ((c++))
+ ;;
+ -C)
+ __git_C_args[C_args_count++]=-C
((c++))
__git_C_args[C_args_count++]="${words[c]}"
;;
- -*) ;;
- *) command="$i"; break ;;
+ -*)
+ ;;
+ *)
+ command="$i"
+ __git_cmd_idx="$c"
+ break
+ ;;
esac
((c++))
done
@@ -3519,7 +3388,8 @@ __git_main ()
;;
esac
case "$cur" in
- --*) __gitcomp "
+ --*)
+ __gitcomp_opts "
--paginate
--no-pager
--git-dir=
@@ -3541,7 +3411,7 @@ __git_main ()
then
__gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
else
- __gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
+ __gitcomp_nl "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
fi
;;
esac
@@ -3570,7 +3440,7 @@ __gitk_main ()
fi
case "$cur" in
--*)
- __gitcomp "
+ __gitcomp_opts "
$__git_log_common_options
$__git_log_gitk_options
$merge
@@ -3586,17 +3456,106 @@ if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then
return
fi
+# The following function is based on code from:
+#
+# bash_completion - programmable completion functions for bash 3.2+
+#
+# Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
+# © 2009-2010, Bash Completion Maintainers
+# <bash-completion-devel@lists.alioth.debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# The latest version of this software can be obtained here:
+#
+# http://bash-completion.alioth.debian.org/
+#
+# RELEASE: 2.x
+
+# This function reorganizes the words on the command line to be processed by
+# the rest of the script.
+#
+# This is roughly equivalent to going back in time and setting
+# COMP_WORDBREAKS to exclude '=' and ':'. The intent is to
+# make option types like --date=<type> and <rev>:<path> easy to
+# recognize by treating each shell word as a single token.
+#
+# It is best not to set COMP_WORDBREAKS directly because the value is
+# shared with other completion scripts. By the time the completion
+# function gets called, COMP_WORDS has already been populated so local
+# changes to COMP_WORDBREAKS have no effect.
+
+if ! type __git_get_comp_words_by_ref >/dev/null 2>&1; then
+__git_get_comp_words_by_ref ()
+{
+ local exclude i j first
+
+ # Which word separators to exclude?
+ exclude="${COMP_WORDBREAKS//[^=:]}"
+ cword=$COMP_CWORD
+ if [ -n "$exclude" ]; then
+ # List of word completion separators has shrunk;
+ # re-assemble words to complete.
+ for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
+ # Append each nonempty word consisting of just
+ # word separator characters to the current word.
+ first=t
+ while
+ [ $i -gt 0 ] &&
+ [ -n "${COMP_WORDS[$i]}" ] &&
+ # word consists of excluded word separators
+ [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
+ do
+ # Attach to the previous token,
+ # unless the previous token is the command name.
+ if [ $j -ge 2 ] && [ -n "$first" ]; then
+ ((j--))
+ fi
+ first=
+ words[$j]=${words[j]}${COMP_WORDS[i]}
+ if [ $i = $COMP_CWORD ]; then
+ cword=$j
+ fi
+ if (($i < ${#COMP_WORDS[@]} - 1)); then
+ ((i++))
+ else
+ # Done.
+ break 2
+ fi
+ done
+ words[$j]=${words[j]}${COMP_WORDS[i]}
+ if [ $i = $COMP_CWORD ]; then
+ cword=$j
+ fi
+ done
+ else
+ words=("${COMP_WORDS[@]}")
+ fi
+
+ cur=${words[cword]}
+ prev=${words[cword-1]}
+}
+fi
+
__git_func_wrap ()
{
- local cur words cword prev
- _get_comp_words_by_ref -n =: cur words cword prev
+ local cur words cword prev __git_cmd_idx=0
+ __git_get_comp_words_by_ref
$1
}
-# Setup completion for certain functions defined above by setting common
-# variables and workarounds.
-# This is NOT a public function; use at your own risk.
-__git_complete ()
+___git_complete ()
{
local wrapper="__git_wrap${2}"
eval "$wrapper () { __git_func_wrap $2 ; }"
@@ -3604,15 +3563,35 @@ __git_complete ()
|| complete -o default -o nospace -F $wrapper $1
}
+# Setup the completion for git commands
+# 1: command or alias
+# 2: function to call (e.g. `git`, `gitk`, `git_fetch`)
+__git_complete ()
+{
+ local func
+
+ if __git_have_func $2; then
+ func=$2
+ elif __git_have_func __$2_main; then
+ func=__$2_main
+ elif __git_have_func _$2; then
+ func=_$2
+ else
+ echo "ERROR: could not find function '$2'" 1>&2
+ return 1
+ fi
+ ___git_complete $1 $func
+}
+
if ! git --list-cmds=main >/dev/null 2>&1; then
declare -A __git_cmds
__git_cmds[list-complete]="apply blame cherry config difftool fsck help instaweb mergetool prune reflog remote repack replace request-pull send-email show-branch stage whatchanged"
- __git_cmds[list-guide]="attributes cli core-tutorial credentials cvs-migration diffcore everyday faq glossary hooks ignore modules namespaces remote-helpers repository-layout revisions submodules tutorial-2 tutorial workflows"
- __git_cmds[list-mainporcelain]="add am archive bisect branch bundle checkout cherry-pick citool clean clone commit describe diff fetch format-patch gc grep gui init gitk log maintenance merge mv notes pull push range-diff rebase reset restore revert rm shortlog show sparse-checkout stash status submodule switch tag worktree"
- __git_cmds[main]="add add--interactive am annotate apply archimport archive bisect bisect--helper blame branch bugreport bundle cat-file check-attr check-ignore check-mailmap check-ref-format checkout checkout-index cherry cherry-pick citool clean clone column commit commit-graph commit-tree config count-objects credential credential-cache credential-cache--daemon credential-gnome-keyring credential-libsecret credential-store cvsexportcommit cvsimport cvsserver daemon describe diff diff-files diff-index diff-tree difftool difftool--helper env--helper fast-export fast-import fetch fetch-pack filter-branch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc get-tar-commit-id grep gui gui--askpass hash-object help http-backend http-fetch http-push imap-send index-pack init init-db instaweb interpret-trailers log ls-files ls-remote ls-tree mailinfo mailsplit maintenance merge merge-base merge-file merge-index merge-octopus merge-one-file merge-ours merge-recursive merge-recursive-ours merge-recursive-theirs merge-resolve merge-subtree merge-tree mergetool mktag mktree multi-pack-index mv mw name-rev notes p4 pack-objects pack-redundant pack-refs patch-id pickaxe prune prune-packed pull push quiltimport range-diff read-tree rebase rebase--interactive receive-pack reflog remote remote-ext remote-fd remote-ftp remote-ftps remote-http remote-https remote-mediawiki repack replace request-pull rerere reset restore rev-list rev-parse revert rm send-email send-pack sh-i18n--envsubst shell shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace submodule submodule--helper subtree svn switch symbolic-ref tag unpack-file unpack-objects update-index update-ref update-server-info upload-archive upload-archive--writer upload-pack var verify-commit verify-pack verify-tag version web--browse whatchanged worktree write-tree"
- __git_cmds[others]="compare reintegrate related remote-hg remote-sync send-series smartlist"
- __git_cmds[parseopt]="add am apply archive bisect--helper blame branch bugreport cat-file check-attr check-ignore check-mailmap checkout checkout-index cherry cherry-pick clean clone column commit commit-graph config count-objects credential-cache credential-cache--daemon credential-store describe difftool env--helper fast-export fetch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc grep hash-object help init init-db interpret-trailers log ls-files ls-remote ls-tree merge merge-base merge-file mktree multi-pack-index mv name-rev notes pack-objects pack-refs pickaxe prune prune-packed pull push range-diff read-tree rebase rebase--interactive receive-pack reflog remote repack replace rerere reset restore revert rm send-pack shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace switch symbolic-ref tag update-index update-ref update-server-info upload-pack verify-commit verify-pack verify-tag version whatchanged write-tree "
+ __git_cmds[list-guide]="attributes cli core-tutorial credentials cvs-migration diffcore everyday faq glossary hooks ignore mailmap modules namespaces remote-helpers repository-layout revisions submodules tutorial tutorial-2 workflows"
+ __git_cmds[list-mainporcelain]="add am archive bisect branch bundle checkout cherry-pick citool clean clone commit describe diff fetch format-patch gc grep gui init log maintenance merge mv notes pull push range-diff rebase reset restore revert rm shortlog show sparse-checkout stash status submodule switch tag worktree gitk"
+ __git_cmds[main]="add add--interactive am annotate apply archimport archive bisect bisect--helper blame branch bugreport bundle cat-file check-attr check-ignore check-mailmap check-ref-format checkout checkout--worker checkout-index cherry cherry-pick citool clean clone column commit commit-graph commit-tree config count-objects credential credential-cache credential-cache--daemon credential-gnome-keyring credential-libsecret credential-store cvsexportcommit cvsimport cvsserver daemon describe diff diff-files diff-index diff-tree difftool difftool--helper env--helper fast-export fast-import fetch fetch-pack filter-branch fmt-merge-msg for-each-ref for-each-repo format-patch fsck fsck-objects gc get-tar-commit-id grep gui gui--askpass hash-object help http-backend http-fetch http-push imap-send index-pack init init-db instaweb interpret-trailers log ls-files ls-remote ls-tree mailinfo mailsplit maintenance merge merge-base merge-file merge-index merge-octopus merge-one-file merge-ours merge-recursive merge-recursive-ours merge-recursive-theirs merge-resolve merge-subtree merge-tree mergetool mktag mktree multi-pack-index mv mw name-rev notes p4 pack-objects pack-redundant pack-refs patch-id pickaxe prune prune-packed pull push quiltimport range-diff read-tree rebase receive-pack reflog remote remote-ext remote-fd remote-ftp remote-ftps remote-http remote-https remote-mediawiki repack replace request-pull rerere reset restore rev-list rev-parse revert rm send-email send-pack sh-i18n--envsubst shell shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace submodule submodule--helper subtree svn switch symbolic-ref tag unpack-file unpack-objects update-index update-ref update-server-info upload-archive upload-archive--writer upload-pack var verify-commit verify-pack verify-tag version web--browse whatchanged worktree write-tree"
+ __git_cmds[others]=""
+ __git_cmds[parseopt]="add am apply archive bisect--helper blame branch bugreport cat-file check-attr check-ignore check-mailmap checkout checkout--worker checkout-index cherry cherry-pick clean clone column commit commit-graph config count-objects credential-cache credential-cache--daemon credential-store describe difftool env--helper fast-export fetch fmt-merge-msg for-each-ref for-each-repo format-patch fsck fsck-objects gc grep hash-object help init init-db interpret-trailers log ls-files ls-remote ls-tree merge merge-base merge-file mktree multi-pack-index mv name-rev notes pack-objects pack-refs pickaxe prune prune-packed pull push range-diff read-tree rebase receive-pack reflog remote repack replace rerere reset restore revert rm send-pack shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace switch symbolic-ref tag update-index update-ref update-server-info upload-pack verify-commit verify-pack verify-tag version whatchanged write-tree "
# Override __git
__git ()
@@ -3641,13 +3620,13 @@ if ! git --list-cmds=main >/dev/null 2>&1; then
fi
-__git_complete git __git_main
-__git_complete gitk __gitk_main
+___git_complete git __git_main
+___git_complete gitk __gitk_main
# The following are necessary only for Cygwin, and only are needed
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
if [ "$OSTYPE" = cygwin ]; then
- __git_complete git.exe __git_main
+ ___git_complete git.exe __git_main
fi
diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
index 54e123d63..db7c0068f 100644
--- a/plugins/gitfast/git-prompt.sh
+++ b/plugins/gitfast/git-prompt.sh
@@ -138,6 +138,7 @@ __git_ps1_show_upstream ()
done <<< "$output"
# parse configuration values
+ local option
for option in ${GIT_PS1_SHOWUPSTREAM}; do
case "$option" in
git|svn) upstream="$option" ;;
@@ -432,8 +433,8 @@ __git_ps1 ()
fi
local sparse=""
- if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
- [ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
+ if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
+ [ -z "${GIT_PS1_OMITSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
sparse="|SPARSE"
fi
@@ -542,7 +543,7 @@ __git_ps1 ()
u="%${ZSH_VERSION+%}"
fi
- if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
+ if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
h="?"
fi
diff --git a/plugins/gitfast/update b/plugins/gitfast/update
index 5311065a1..5ebaaef3d 100755
--- a/plugins/gitfast/update
+++ b/plugins/gitfast/update
@@ -1,7 +1,7 @@
#!/bin/sh
url="https://raw.githubusercontent.com/felipec/git-completion"
-version="1.2"
+version="1.3.6"
curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&
diff --git a/plugins/helm/helm.plugin.zsh b/plugins/helm/helm.plugin.zsh
index 472c1c9dd..cadfa551a 100644
--- a/plugins/helm/helm.plugin.zsh
+++ b/plugins/helm/helm.plugin.zsh
@@ -11,12 +11,12 @@ command rm -f "${ZSH_CACHE_DIR}/helm_completion"
command mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
-# If the completion file doesn't exist yet, we need to autoload it and
-# bind it to `helm`. Otherwise, compinit will have already done that.
+# If the completion file does not exist, generate it and then source it
+# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then
- declare -A _comps
- autoload -Uz _helm
- _comps[helm]=_helm
+ helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm"
+ source "$ZSH_CACHE_DIR/completions/_helm"
+else
+ source "$ZSH_CACHE_DIR/completions/_helm"
+ helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm" &|
fi
-
-helm completion zsh >| "$ZSH_CACHE_DIR/completions/_helm" &|
diff --git a/plugins/jenv/jenv.plugin.zsh b/plugins/jenv/jenv.plugin.zsh
index 946ce18a5..240102604 100644
--- a/plugins/jenv/jenv.plugin.zsh
+++ b/plugins/jenv/jenv.plugin.zsh
@@ -18,13 +18,19 @@ if [[ $FOUND_JENV -eq 1 ]]; then
(( $+commands[jenv] )) || export PATH="${jenvdir}/bin:$PATH"
eval "$(jenv init - zsh)"
- function jenv_prompt_info() { jenv version-name 2>/dev/null }
+ function jenv_prompt_info() {
+ local version="$(jenv version-name 2>/dev/null)"
+ echo "${version:gs/%/%%}"
+ }
if [[ -d "${jenvdir}/versions" ]]; then
export JENV_ROOT=$jenvdir
fi
else
- function jenv_prompt_info() { echo "system: $(java -version 2>&1 | cut -f 2 -d ' ')" }
+ function jenv_prompt_info() {
+ local version="$(java -version 2>&1 | cut -d' ' -f2)"
+ echo "system: ${version:gs/%/%%}"
+ }
fi
unset jenvdir jenvdirs FOUND_JENV
diff --git a/plugins/juju/README.md b/plugins/juju/README.md
index 49f8b0d47..f0c65309c 100644
--- a/plugins/juju/README.md
+++ b/plugins/juju/README.md
@@ -15,34 +15,46 @@ Naming convention:
- `!` suffix: `--force --no-wait -y`.
- `ds` suffix: `--destroy-storage`.
+- `jsh` prefix means `juju show-*`.
### General
-| Alias | Command | Description |
-|--------|---------------------------------------------|--------------------------------------------------------|
-| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
-| `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
-| `jh` | `juju help` | Show help on a command or other topic |
-| `jssl` | `juju juju show-status-log` | Output past statuses for the specified entity |
-| `jstj` | `juju status --format=json` | Show status in json format (more detailed) |
-| `jst` | `juju status --relations --storage --color` | Show status, including relations and storage, in color |
+| Alias | Command | Description |
+|---------|---------------------------------------------|--------------------------------------------------------|
+| `j` | `juju` | The juju command |
+| `jcld` | `juju clouds` | Lists all clouds with registered credentials |
+| `jclda` | `juju clouds --all` | Lists all clouds available to Juju |
+| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
+| `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
+| `jh` | `juju help` | Show help on a command or other topic |
+| `jshsl` | `juju show-status-log` | Output past statuses for the specified entity |
+| `jstj` | `juju status --format=json` | Show status in json format (more detailed) |
+| `jst` | `juju status --relations --color` | Show status, including relations, in color |
+| `jsts` | `juju status --relations --storage --color` | Show status, including relations and storage, in color |
### Bootstrap
-| Alias | Command | Description |
-|-------|---------------------------|-------------------------------------------|
-| `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
-| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment |
+| Alias | Command | Description |
+|---------|-------------------------------------|-------------------------------------------------------|
+| `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
+| `jbng` | `juju bootstrap --no-gui` | Initializing a Juju cloud environment without GUI |
+| `jbl` | `juju bootstrap localhost` | Initializing an lxd cloud environment |
+| `jblng` | `juju bootstrap --no-gui localhost` | Initializing an lxd cloud environment without GUI |
+| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment |
+| `jbmng` | `juju bootstrap --no-gui microk8s` | Initializing a MicroK8s cloud environment without GUI |
### Controller
| Alias | Command | Description |
|----------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------|
+| `jctl` | `juju controllers` | List all controllers |
+| `jctlr` | `juju controllers --refresh` | List all controllers (download latest details) |
| `jdc` | `juju destroy-controller --destroy-all-models` | Destroy a controller |
| `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | Destroy a controller |
| `jdcds` | `juju destroy-controller --destroy-all-models --destroy-storage` | Destroy a controller and associated storage |
| `jdcds!` | `juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y` | Destroy a controller and associated storage |
| `jkc` | `juju kill-controller -y -t 0` | Forcibly terminate all associated resources for a Juju controller |
+| `jshc` | `juju show-controller` | Shows detailed information of a controller |
| `jsw` | `juju switch` | Select or identify the current controller and model |
### Model
@@ -74,9 +86,9 @@ Naming convention:
| `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage |
| `jrp` | `juju refresh --path` | Upgrade charm from local charm file |
| `jsa` | `juju scale-application` | Set the desired number of application units |
-| `jsh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target |
-| `jshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
-| `jsu` | `juju show-unit` | Displays information about a unit |
+| `jssh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target |
+| `jsshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
+| `jshu` | `juju show-unit` | Displays information about a unit |
### Storage
@@ -113,5 +125,6 @@ Naming convention:
- `jaddr <app_name> [unit_num]`: display app or unit IP address.
- `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data.
+- `jclean`: destroy all controllers
- `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval
(default: 5s); you may pass additional arguments to `watch`.
diff --git a/plugins/juju/juju.plugin.zsh b/plugins/juju/juju.plugin.zsh
index 07f15b392..be8a2c7ae 100644
--- a/plugins/juju/juju.plugin.zsh
+++ b/plugins/juju/juju.plugin.zsh
@@ -16,12 +16,22 @@ unset completion_file
# Generally, #
# - `!` means --force --no-wait -y #
# - `ds` suffix means --destroy-storage #
+# - `jsh` prefix means juju show-* #
# ---------------------------------------------------------- #
+alias j="juju"
alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\
--config update-status-hook-interval=\"60m\""
alias jb='juju bootstrap'
+alias jbng='juju bootstrap --no-gui'
+alias jbl='juju bootstrap localhost'
+alias jblng='juju bootstrap --no-gui localhost'
alias jbm='juju bootstrap microk8s'
+alias jbmng='juju bootstrap --no-gui microk8s'
alias jc='juju config'
+alias jcld='juju clouds'
+alias jclda='juju clouds --all'
+alias jctl='juju controllers'
+alias jctlr='juju controllers --refresh'
alias jdc='juju destroy-controller --destroy-all-models'
alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y'
alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage'
@@ -56,13 +66,16 @@ alias jrp='juju refresh --path'
alias jrs='juju remove-storage'
alias 'jrs!'='juju remove-storage --force'
alias jsa='juju scale-application'
-alias jsh='juju ssh'
-alias jshc='juju ssh --container'
+alias jsha='juju show-application'
+alias jshc='juju show-controller'
alias jshm='juju show-model'
-alias jssl='juju show-status-log'
+alias jshsl='juju show-status-log'
+alias jshu='juju show-unit'
+alias jssh='juju ssh'
+alias jsshc='juju ssh --container'
alias jstj='juju status --format=json'
-alias jst='juju status --relations --storage --color'
-alias jsu='juju show-unit'
+alias jst='juju status --relations --color'
+alias jsts='juju status --relations --storage --color'
alias jsw='juju switch'
# ---------------------------------------------------------- #
@@ -95,6 +108,37 @@ jaddr() {
fi
}
+# Destroy all controllers
+jclean() {
+ if (( ! ${+commands[jq]} )); then
+ echo "jq is required but could not be found." >&2
+ return 1
+ fi
+
+ local controllers=$(juju controllers --format=json | jq -r '.controllers | keys[]' 2>/dev/null)
+ if [[ -z "$controllers" ]]; then
+ echo "No controllers registered"
+ return 0
+ fi
+
+ echo "This will forcefully destroy all storages, models and controllers."
+ echo "Controllers to be destroyed:"
+ echo "$controllers"
+
+ if ! read -q '?Are you sure (y/n)? '; then
+ echo
+ echo "Aborted."
+ return 0
+ fi
+
+ echo
+ for controller in ${=controllers}; do
+ timeout 2m juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y $controller
+ timeout 2m juju kill-controller -y -t 0 $controller 2>/dev/null
+ timeout 10s juju unregister $controller 2>/dev/null
+ done
+}
+
# Display app and unit relation data
jreld() {
# $1 = relation name
@@ -123,5 +167,6 @@ jreld() {
wjst() {
local interval="${1:-5}"
shift $(( $# > 0 ))
- watch -n "$interval" --color juju status --relations --storage --color "$@"
+ watch -n "$interval" --color juju status --relations --color "$@"
}
+
diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
index 3630facaa..eed5727d1 100644
--- a/plugins/kubectl/kubectl.plugin.zsh
+++ b/plugins/kubectl/kubectl.plugin.zsh
@@ -1,13 +1,22 @@
if (( $+commands[kubectl] )); then
- __KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
-
- if [[ ! -f $__KUBECTL_COMPLETION_FILE || ! -s $__KUBECTL_COMPLETION_FILE ]]; then
- kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
- fi
-
- [[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE
-
- unset __KUBECTL_COMPLETION_FILE
+ # TODO: 2022-01-05: remove this block
+ # remove old generated files
+ command rm -f "$ZSH_CACHE_DIR/kubectl_completion"
+
+ # TODO: 2022-01-05: remove this bit of code as it exists in oh-my-zsh.sh
+ # Add completions folder in $ZSH_CACHE_DIR
+ command mkdir -p "$ZSH_CACHE_DIR/completions"
+ (( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
+
+ # If the completion file does not exist, generate it and then source it
+ # Otherwise, source it and regenerate in the background
+ if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then
+ kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl"
+ source "$ZSH_CACHE_DIR/completions/_kubectl"
+ else
+ source "$ZSH_CACHE_DIR/completions/_kubectl"
+ kubectl completion zsh >| "$ZSH_CACHE_DIR/completions/_kubectl" &|
+ fi
fi
# This command is used a LOT both below and in daily life
@@ -20,7 +29,7 @@ alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca'
alias kaf='kubectl apply -f'
# Drop into an interactive terminal on a container
-alias keti='kubectl exec -ti'
+alias keti='kubectl exec -t -i'
# Manage configuration quickly to switch contexts between local, dev ad staging.
alias kcuc='kubectl config use-context'
@@ -97,8 +106,9 @@ alias kdd='kubectl describe deployment'
alias kdeld='kubectl delete deployment'
alias ksd='kubectl scale deployment'
alias krsd='kubectl rollout status deployment'
-kres(){
- kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S)
+
+function kres(){
+ kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S)
}
# Rollout management.
@@ -170,9 +180,9 @@ alias kdelcj='kubectl delete cronjob'
# Only run if the user actually has kubectl installed
if (( ${+_comps[kubectl]} )); then
- kj() { kubectl "$@" -o json | jq; }
- kjx() { kubectl "$@" -o json | fx; }
- ky() { kubectl "$@" -o yaml | yh; }
+ function kj() { kubectl "$@" -o json | jq; }
+ function kjx() { kubectl "$@" -o json | fx; }
+ function ky() { kubectl "$@" -o yaml | yh; }
compdef kj=kubectl
compdef kjx=kubectl
diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh
index abbdc254b..6096feeae 100644
--- a/plugins/kubectx/kubectx.plugin.zsh
+++ b/plugins/kubectx/kubectx.plugin.zsh
@@ -1,9 +1,13 @@
-typeset -A kubectx_mapping
+typeset -g -A kubectx_mapping
function kubectx_prompt_info() {
- if [ $commands[kubectl] ]; then
- local current_ctx=`kubectl config current-context`
- # use value in associative array if it exists, otherwise fall back to the context name
- echo "${kubectx_mapping[$current_ctx]:-$current_ctx}"
- fi
+ (( $+commands[kubectl] )) || return
+
+ local current_ctx=$(kubectl config current-context 2> /dev/null)
+
+ [[ -n "$current_ctx" ]] || return
+
+ # use value in associative array if it exists
+ # otherwise fall back to the context name
+ echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}"
}
diff --git a/plugins/multipass/README.md b/plugins/multipass/README.md
new file mode 100644
index 000000000..f6b2d76f4
--- /dev/null
+++ b/plugins/multipass/README.md
@@ -0,0 +1,22 @@
+# multipass
+
+This plugin provides completion for [multipass](https://multipass.run), as well as aliases
+for multipass commands.
+
+To use it, add `multipass` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... multipass)
+```
+
+## Aliases
+
+| Alias | Command |
+| ------ | ------------------------------------------------------------------- |
+| `mp` | `multipass` |
+| `mpl` | `multipass list` |
+| `mpla` | `multipass launch` |
+| `mpln` | `multipass launch --network en0 --network name=bridge0,mode=manual` |
+| `mps` | `multipass shell` |
+| `mpsp` | `multipass stop` |
+| `mpst` | `multipass start` |
diff --git a/plugins/multipass/_multipass b/plugins/multipass/_multipass
new file mode 100644
index 000000000..c742df650
--- /dev/null
+++ b/plugins/multipass/_multipass
@@ -0,0 +1,73 @@
+#compdef multipass
+
+_multipass_get_command_list () {
+ # Sample output:
+ # $ multipass --help
+ # ...
+ # Options:
+ # -h, --help Display this help
+ # -v, --verbose Increase logging verbosity. Repeat the 'v' in the short option
+ # for more detail. Maximum verbosity is obtained with 4 (or more)
+ # v's, i.e. -vvvv.
+ # ...
+ # Available commands:
+ # alias Create an alias
+ # aliases List available aliases
+ # ...
+ #
+ $_comp_command1 --help | sed '1,/Available commands/d' | awk '/^[ \t]*[a-z]+/ { print $1 }'
+}
+
+_multipass_get_args_list () {
+ # Sample output:
+ # $ multpass help stop
+ # ...
+ # Options:
+ # -h, --help Display this help
+ # -v, --verbose Increase logging verbosity. Repeat the 'v' in the short
+ # option for more detail. Maximum verbosity is obtained with
+ # 4 (or more) v's, i.e. -vvvv.
+ # --all Stop all instances
+ # -t, --time <time> Time from now, in minutes, to delay shutdown of the
+ # instance
+ # -c, --cancel Cancel a pending delayed shutdown
+ #
+ # Arguments:
+ # name Names of instances to stop. If omitted, and without the
+ # --all option, 'primary' will be assumed.
+ #
+ local arg_name=$($_comp_command1 help ${words[2]} | sed '1,/Arguments/d' | awk '/^[ \t]*[a-z]+/ { print $1; exit }')
+
+ case $arg_name in
+ name)
+ # Sample output:
+ # $ multipass list
+ # Name State IPv4 Image
+ # workable-poacher Running 10.2.0.28 Ubuntu openHAB Home Appliance
+ #
+ $_comp_command1 list | sed '1d' | awk '/^[ \t]*[^ ]+/ { print $1 }'
+ ;;
+ command)
+ _multipass_get_command_list
+ ;;
+ esac
+}
+
+_multipass () {
+ typeset -A opt_args
+
+ _arguments \
+ '1: :->command'\
+ '*: :->args'
+
+ case $state in
+ command)
+ compadd $(_multipass_get_command_list)
+ ;;
+ *)
+ compadd $(_multipass_get_args_list)
+ ;;
+ esac
+}
+
+_multipass "$@"
diff --git a/plugins/multipass/multipass.plugin.zsh b/plugins/multipass/multipass.plugin.zsh
new file mode 100644
index 000000000..95025b2ad
--- /dev/null
+++ b/plugins/multipass/multipass.plugin.zsh
@@ -0,0 +1,7 @@
+alias mp="multipass"
+alias mpl="multipass list"
+alias mpla="multipass launch"
+alias mpln="multipass launch --network en0 --network name=bridge0,mode=manual"
+alias mps="multipass shell"
+alias mpsp="multipass stop"
+alias mpst="multipass start"
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index e32729aa6..1b9141f21 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -117,7 +117,7 @@ function listMavenCompletions {
done
# List modules
- modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|'))
+ modules=($(print -l **/pom.xml(-.N:h) | grep -v '/target/classes/META-INF/'))
reply=(
# common lifecycle
diff --git a/plugins/npx/README.md b/plugins/npx/README.md
index 41e4c1352..4b2aba8f0 100644
--- a/plugins/npx/README.md
+++ b/plugins/npx/README.md
@@ -1,27 +1,4 @@
-# NPX Plugin
-
-> npx(1) -- execute npm package binaries. ([more info](https://github.com/npm/npx))
-
-This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`.
-
-To use it, add `npx` to the plugins array in your zshrc file:
-
-```zsh
-plugins=(.... npx)
-```
-
-## Note
-
-The shell auto-fallback doesn't auto-install plain packages. In order to get it to install something, you need to add `@`:
-
-```
-➜ jasmine@latest # or just `jasmine@`
-npx: installed 13 in 1.896s
-Randomized with seed 54385
-Started
-```
-
-It does it this way so folks using the fallback don't accidentally try to install regular typoes.
+# npx plugin
## Deprecation
diff --git a/plugins/npx/npx.plugin.zsh b/plugins/npx/npx.plugin.zsh
index 32bb67377..c1e2eca98 100644
--- a/plugins/npx/npx.plugin.zsh
+++ b/plugins/npx/npx.plugin.zsh
@@ -1,7 +1,12 @@
-# NPX Plugin
-# https://www.npmjs.com/package/npx
-# Maintainer: Pooya Parsa <pooya@pi0.ir>
+if (( ! $+commands[npx] )); then
+ return
+fi
-(( $+commands[npx] )) && {
- source <(npx --shell-auto-fallback zsh)
-}
+if ! npx_fallback_script="$(npx --shell-auto-fallback zsh 2>/dev/null)"; then
+ print -u2 ${(%):-"%F{yellow}This \`npx\` version ($(npx --version)) is not supported.%f"}
+else
+ source <(<<< "$npx_fallback_script")
+fi
+
+print -u2 ${(%):-"%F{yellow}The \`npx\` plugin is deprecated and will be removed soon. %BPlease disable it%b.%f"}
+unset npx_fallback_script
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index 9304e7f32..3b0935981 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -1,5 +1,5 @@
-print ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'}
-print ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'}
+print -u2 ${(%):-'%F{yellow}The `osx` plugin is deprecated and has been renamed to `macos`.'}
+print -u2 ${(%):-'Please update your .zshrc to use the `%Bmacos%b` plugin instead.%f'}
(( ${fpath[(Ie)$ZSH/plugins/macos]} )) || fpath=("$ZSH/plugins/macos" $fpath)
source "$ZSH/plugins/macos/macos.plugin.zsh"
diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh
index e36d49204..431576f4b 100644
--- a/plugins/pj/pj.plugin.zsh
+++ b/plugins/pj/pj.plugin.zsh
@@ -1,37 +1,34 @@
alias pjo="pj open"
-pj () {
- emulate -L zsh
-
- cmd="cd"
- project=$1
-
- if [[ "open" == "$project" ]]; then
- shift
- project=$*
- cmd=${=EDITOR}
- else
- project=$*
+function pj() {
+ local cmd="cd"
+ local project="$1"
+
+ if [[ "open" == "$project" ]]; then
+ shift
+ project=$*
+ cmd=${=EDITOR}
+ else
+ project=$*
+ fi
+
+ for basedir ($PROJECT_PATHS); do
+ if [[ -d "$basedir/$project" ]]; then
+ $cmd "$basedir/$project"
+ return
fi
+ done
- for basedir ($PROJECT_PATHS); do
- if [[ -d "$basedir/$project" ]]; then
- $cmd "$basedir/$project"
- return
- fi
- done
-
- echo "No such project '${project}'."
+ echo "No such project '${project}'."
}
_pj () {
- emulate -L zsh
+ local -a projects
+ for basedir ($PROJECT_PATHS); do
+ projects+=(${basedir}/*(/N))
+ done
- typeset -a projects
- for basedir ($PROJECT_PATHS); do
- projects+=(${basedir}/*(/N))
- done
-
- compadd ${projects:t}
+ compadd ${projects:t}
}
+
compdef _pj pj
diff --git a/plugins/poetry/README.md b/plugins/poetry/README.md
new file mode 100644
index 000000000..51780cbed
--- /dev/null
+++ b/plugins/poetry/README.md
@@ -0,0 +1,9 @@
+# Poetry Plugin
+
+This plugin automatically installs [Poetry](https://python-poetry.org/)'s completions for you, and keeps them up to date as your Poetry version changes.
+
+To use it, add `poetry` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... poetry)
+```
diff --git a/plugins/poetry/poetry.plugin.zsh b/plugins/poetry/poetry.plugin.zsh
new file mode 100644
index 000000000..cebcb46c4
--- /dev/null
+++ b/plugins/poetry/poetry.plugin.zsh
@@ -0,0 +1,14 @@
+# Return immediately if poetry is not found
+if (( ! $+commands[poetry] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `poetry`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_poetry" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _poetry
+ _comps[poetry]=_poetry
+fi
+
+poetry completions zsh >| "$ZSH_CACHE_DIR/completions/_poetry" &|
diff --git a/plugins/postgres/postgres.plugin.zsh b/plugins/postgres/postgres.plugin.zsh
index c2dbef244..b6d365d8a 100644
--- a/plugins/postgres/postgres.plugin.zsh
+++ b/plugins/postgres/postgres.plugin.zsh
@@ -1,8 +1,13 @@
# Aliases to control Postgres
# Paths noted below are for Postgres installed via Homebrew on OSX
+if (( ! $+commands[brew] )); then
+ return
+fi
-alias startpost='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
-alias stoppost='pg_ctl -D /usr/local/var/postgres stop -s -m fast'
-alias restartpost='stoppost && sleep 1 && startpost'
-alias reloadpost='pg_ctl reload -D /usr/local/var/postgres -s'
-alias statuspost='pg_ctl status -D /usr/local/var/postgres -s' \ No newline at end of file
+local PG_BREW_DIR=$(brew --prefix)/var/postgres
+
+alias startpost="pg_ctl -D $PG_BREW_DIR -l $PG_BREW_DIR/server.log start"
+alias stoppost="pg_ctl -D $PG_BREW_DIR stop -s -m fast"
+alias restartpost="stoppost && sleep 1 && startpost"
+alias reloadpost="pg_ctl reload -D $PG_BREW_DIR -s"
+alias statuspost="pg_ctl status -D $PG_BREW_DIR -s"
diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh
index 39897ed16..ebb1a708a 100644
--- a/plugins/pyenv/pyenv.plugin.zsh
+++ b/plugins/pyenv/pyenv.plugin.zsh
@@ -83,12 +83,14 @@ if [[ $FOUND_PYENV -eq 1 ]]; then
fi
function pyenv_prompt_info() {
- echo "$(pyenv version-name)"
+ local version="$(pyenv version-name)"
+ echo "${version:gs/%/%%}"
}
else
# Fall back to system python
function pyenv_prompt_info() {
- echo "system: $(python -V 2>&1 | cut -f 2 -d ' ')"
+ local version="$(python -V 2>&1 | cut -d' ' -f2)"
+ echo "system: ${version:gs/%/%%}"
}
fi
diff --git a/plugins/rbw/README.md b/plugins/rbw/README.md
index 87d073d24..cae36cead 100644
--- a/plugins/rbw/README.md
+++ b/plugins/rbw/README.md
@@ -9,4 +9,14 @@ To use it, add `rbw` to the plugins array in your zshrc file:
plugins=(... rbw)
```
+## `rbwpw`
+
+The `rbwpw` function is a wrapper around `rbw`. It copies the password in the
+clipboard for the service you ask for and clears the clipboard 20s later.
+The usage is as follows:
+
+```zsh
+rbwpw <service>
+```
+
This plugin does not add any aliases.
diff --git a/plugins/rbw/rbw.plugin.zsh b/plugins/rbw/rbw.plugin.zsh
index 3825be7a6..523e35aff 100644
--- a/plugins/rbw/rbw.plugin.zsh
+++ b/plugins/rbw/rbw.plugin.zsh
@@ -11,9 +11,39 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `rbw`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
- declare -A _comps
+ typeset -g -A _comps
autoload -Uz _rbw
_comps[rbw]=_rbw
fi
rbw gen-completions zsh >| "$ZSH_CACHE_DIR/completions/_rbw" &|
+
+# rbwpw function copies the password of a service to the clipboard
+# and clears it after 20 seconds
+function rbwpw {
+ if [[ $# -ne 1 ]]; then
+ echo "usage: rbwpw <service>"
+ return 1
+ fi
+ local service=$1
+ if ! rbw unlock; then
+ echo "rbw is locked"
+ return 1
+ fi
+ local pw=$(rbw get $service 2>/dev/null)
+ if [[ -z $pw ]]; then
+ echo "$service not found"
+ return 1
+ fi
+ echo -n $pw | clipcopy
+ echo "password for $service copied!"
+ {sleep 20 && clipcopy </dev/null 2>/dev/null} &|
+}
+
+function _rbwpw {
+ local -a services
+ services=("${(@f)$(rbw ls 2>/dev/null)}")
+ [[ -n "$services" ]] && compadd -a -- services
+}
+
+compdef _rbwpw rbwpw
diff --git a/plugins/ripgrep/README.md b/plugins/ripgrep/README.md
index a26f45823..ab9d04116 100644
--- a/plugins/ripgrep/README.md
+++ b/plugins/ripgrep/README.md
@@ -7,7 +7,3 @@ To use it, add `ripgrep` to the plugins array in your zshrc file:
```zsh
plugins=(... ripgrep)
```
-
-Completion is taken from the ripgrep release [`12.1.1`](https://github.com/BurntSushi/ripgrep/releases/tag/12.1.1).
-
-Updated on April 1st, 2021.
diff --git a/plugins/ripgrep/_ripgrep b/plugins/ripgrep/_ripgrep
index 828a6e601..31bc697c7 100644
--- a/plugins/ripgrep/_ripgrep
+++ b/plugins/ripgrep/_ripgrep
@@ -121,7 +121,7 @@ _rg() {
"(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"
+ '(hidden)' # Hidden-file options
- '--hidden[search hidden files and directories]'
+ {-.,--hidden}'[search hidden files and directories]'
$no"--no-hidden[don't search hidden files and directories]"
+ '(hybrid)' # hybrid regex options
@@ -303,6 +303,8 @@ _rg() {
'--context-separator=[specify string used to separate non-continuous context lines in output]:separator'
$no"--no-context-separator[don't print context separators]"
'--debug[show debug messages]'
+ '--field-context-separator[set string to delimit fields in context lines]'
+ '--field-match-separator[set string to delimit fields in matching lines]'
'--trace[show more verbose debug messages]'
'--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)'
"(1 stats)--files[show each file that would be searched (but don't search)]"
diff --git a/plugins/rust/rust.plugin.zsh b/plugins/rust/rust.plugin.zsh
index 014c73b3b..db6ca9e74 100644
--- a/plugins/rust/rust.plugin.zsh
+++ b/plugins/rust/rust.plugin.zsh
@@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
# bind it to `cargo`. Otherwise, compinit will have already done that
if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then
autoload -Uz _cargo
- declare -A _comps
+ typeset -g -A _comps
_comps[cargo]=_cargo
fi
@@ -19,7 +19,7 @@ fi
# bind it to `rustup`. Otherwise, compinit will have already done that
if [[ ! -f "$ZSH_CACHE_DIR/completions/_rustup" ]]; then
autoload -Uz _rustup
- declare -A _comps
+ typeset -g -A _comps
_comps[rustup]=_rustup
fi
@@ -27,5 +27,5 @@ fi
rustup completions zsh >| "$ZSH_CACHE_DIR/completions/_rustup" &|
cat >| "$ZSH_CACHE_DIR/completions/_cargo" <<'EOF'
#compdef cargo
-source $(rustc +${${(z)$(rustup default)}[1]} --print sysroot)/share/zsh/site-functions/_cargo
+source "$(rustc +${${(z)$(rustup default)}[1]} --print sysroot)"/share/zsh/site-functions/_cargo
EOF
diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh
index 4ba885563..864389ba8 100644
--- a/plugins/rvm/rvm.plugin.zsh
+++ b/plugins/rvm/rvm.plugin.zsh
@@ -1,7 +1,7 @@
# Completion
fpath+=("${rvm_path}/scripts/zsh/Completion")
-declare -A _comps
+typeset -g -A _comps
autoload -Uz _rvm
_comps[rvm]=_rvm
diff --git a/plugins/sudo/README.md b/plugins/sudo/README.md
index 012fc5325..27cd20c18 100644
--- a/plugins/sudo/README.md
+++ b/plugins/sudo/README.md
@@ -24,6 +24,20 @@ By pressing the <kbd>esc</kbd> key twice, you will have the same command with `s
$ sudo apt-get install build-essential
```
+The same happens for editing files with your default editor (defined in `$SUDO_EDITOR`, `$VISUAL` or `$EDITOR`, in that order):
+
+If the editor defined were `vim`:
+
+```console
+$ vim /etc/hosts
+```
+
+By pressing the <kbd>esc</kbd> key twice, you will have the same command with `sudo -e` instead of the editor, that would open that editor with root privileges:
+
+```console
+$ sudo -e /etc/hosts
+```
+
### Previous executed commands
Say you want to delete a system file and denied:
@@ -44,6 +58,8 @@ Password:
$
```
+The same happens for file editing, as told before.
+
## Key binding
By default, the `sudo` plugin uses <kbd>Esc</kbd><kbd>Esc</kbd> as the trigger.
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
index e02f88a87..2a0b3bfc4 100644
--- a/plugins/sudo/sudo.plugin.zsh
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -2,7 +2,7 @@
# Description
# -----------
#
-# sudo or sudoedit will be inserted before the command
+# sudo or sudo -e (replacement for sudoedit) will be inserted before the command
#
# ------------------------------------------------------------------------------
# Authors
@@ -11,14 +11,19 @@
# * Dongweiming <ciici123@gmail.com>
# * Subhaditya Nath <github.com/subnut>
# * Marc Cornellà <github.com/mcornella>
+# * Carlo Sala <carlosalag@protonmail.com>
#
# ------------------------------------------------------------------------------
__sudo-replace-buffer() {
local old=$1 new=$2 space=${2:+ }
- if [[ ${#LBUFFER} -le ${#old} ]]; then
- RBUFFER="${space}${BUFFER#$old }"
- LBUFFER="${new}"
+
+ # if the cursor is positioned in the $old part of the text, make
+ # the substitution and leave the cursor after the $new text
+ if [[ $CURSOR -le ${#old} ]]; then
+ BUFFER="${new}${space}${BUFFER#$old }"
+ CURSOR=${#new}
+ # otherwise just replace $old with $new in the text before the cursor
else
LBUFFER="${new}${space}${LBUFFER#$old }"
fi
@@ -35,14 +40,21 @@ sudo-command-line() {
LBUFFER="${LBUFFER:1}"
fi
- # If $EDITOR is not set, just toggle the sudo prefix on and off
- if [[ -z "$EDITOR" ]]; then
- case "$BUFFER" in
- sudoedit\ *) __sudo-replace-buffer "sudoedit" "" ;;
- sudo\ *) __sudo-replace-buffer "sudo" "" ;;
- *) LBUFFER="sudo $LBUFFER" ;;
- esac
- else
+ {
+ # If $SUDO_EDITOR or $VISUAL are defined, then use that as $EDITOR
+ # Else use the default $EDITOR
+ local EDITOR=${SUDO_EDITOR:-${VISUAL:-$EDITOR}}
+
+ # If $EDITOR is not set, just toggle the sudo prefix on and off
+ if [[ -z "$EDITOR" ]]; then
+ case "$BUFFER" in
+ sudo\ -e\ *) __sudo-replace-buffer "sudo -e" "" ;;
+ sudo\ *) __sudo-replace-buffer "sudo" "" ;;
+ *) LBUFFER="sudo $LBUFFER" ;;
+ esac
+ return
+ fi
+
# Check if the typed command is really an alias to $EDITOR
# Get the first part of the typed command
@@ -67,24 +79,25 @@ sudo-command-line() {
if [[ "$realcmd" = (\$EDITOR|$editorcmd|${editorcmd:c}) \
|| "${realcmd:c}" = ($editorcmd|${editorcmd:c}) ]] \
|| builtin which -a "$realcmd" | command grep -Fx -q "$editorcmd"; then
- editorcmd="$cmd" # replace $editorcmd with the typed command so it matches below
+ __sudo-replace-buffer "$cmd" "sudo -e"
+ return
fi
# Check for editor commands in the typed command and replace accordingly
case "$BUFFER" in
- $editorcmd\ *) __sudo-replace-buffer "$editorcmd" "sudoedit" ;;
- \$EDITOR\ *) __sudo-replace-buffer '$EDITOR' "sudoedit" ;;
- sudoedit\ *) __sudo-replace-buffer "sudoedit" "$EDITOR" ;;
+ $editorcmd\ *) __sudo-replace-buffer "$editorcmd" "sudo -e" ;;
+ \$EDITOR\ *) __sudo-replace-buffer '$EDITOR' "sudo -e" ;;
+ sudo\ -e\ *) __sudo-replace-buffer "sudo -e" "$EDITOR" ;;
sudo\ *) __sudo-replace-buffer "sudo" "" ;;
*) LBUFFER="sudo $LBUFFER" ;;
esac
- fi
-
- # Preserve beginning space
- LBUFFER="${WHITESPACE}${LBUFFER}"
+ } always {
+ # Preserve beginning space
+ LBUFFER="${WHITESPACE}${LBUFFER}"
- # Redisplay edit buffer (compatibility with zsh-syntax-highlighting)
- zle redisplay
+ # Redisplay edit buffer (compatibility with zsh-syntax-highlighting)
+ zle redisplay
+ }
}
zle -N sudo-command-line
diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
index f40a59685..46dd5cb0c 100644
--- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh
+++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh
@@ -1,6 +1,6 @@
function svn_prompt_info() {
local info
- info=$(svn info 2>&1) || return 1 # capture stdout and stderr
+ info=$(LANG= svn info 2>&1) || return 1 # capture stdout and stderr
local repo_need_upgrade=$(svn_repo_need_upgrade $info)
if [[ -n $repo_need_upgrade ]]; then
@@ -20,7 +20,7 @@ function svn_prompt_info() {
"$ZSH_PROMPT_BASE_COLOR" \
\
"$ZSH_THEME_BRANCH_NAME_COLOR" \
- "$(svn_current_branch_name $info)" \
+ "${$(svn_current_branch_name $info):gs/%/%%}" \
"$ZSH_PROMPT_BASE_COLOR" \
\
"$(svn_current_revision $info)" \
@@ -31,42 +31,44 @@ function svn_prompt_info() {
}
function svn_repo_need_upgrade() {
- grep -q "E155036" <<< "${1:-$(svn info 2> /dev/null)}" && \
+ command grep -q "E155036" <<< "${1:-$(LANG= svn info 2>/dev/null)}" && \
echo "E155036: upgrade repo with svn upgrade"
}
function svn_current_branch_name() {
- grep '^URL:' <<< "${1:-$(svn info 2> /dev/null)}" | egrep -o '(tags|branches)/[^/]+|trunk'
+ omz_urldecode "$(
+ command grep '^URL:' <<< "${1:-$(svn info 2>/dev/null)}" | command grep -Eo '(tags|branches)/[^/]+|trunk'
+ )"
}
function svn_repo_root_name() {
- grep '^Repository\ Root:' <<< "${1:-$(svn info 2> /dev/null)}" | sed 's#.*/##'
+ command grep '^Repository\ Root:' <<< "${1:-$(LANG= svn info 2>/dev/null)}" | sed 's#.*/##'
}
function svn_current_revision() {
- echo "${1:-$(svn info 2> /dev/null)}" | sed -n 's/Revision: //p'
+ echo "${1:-$(LANG= svn info 2>/dev/null)}" | sed -n 's/Revision: //p'
}
function svn_status_info() {
local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
- local svn_status="$(svn status 2> /dev/null)";
- if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then
- svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"
+ local svn_status="$(svn status 2>/dev/null)";
+ if command grep -E '^\s*A' &>/dev/null <<< "$svn_status"; then
+ svn_status_string+="${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"
fi
- if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then
- svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"
+ if command grep -E '^\s*D' &>/dev/null <<< "$svn_status"; then
+ svn_status_string+="${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"
fi
- if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then
- svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"
+ if command grep -E '^\s*M' &>/dev/null <<< "$svn_status"; then
+ svn_status_string+="${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"
fi
- if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then
- svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"
+ if command grep -E '^\s*[R~]' &>/dev/null <<< "$svn_status"; then
+ svn_status_string+="${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"
fi
- if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then
- svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"
+ if command grep -E '^\s*\?' &>/dev/null <<< "$svn_status"; then
+ svn_status_string+="${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"
fi
- if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then
- svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DIRTY:-!}"
+ if command grep -E '^\s*[CI!L]' &>/dev/null <<< "$svn_status"; then
+ svn_status_string+="${ZSH_THEME_SVN_PROMPT_DIRTY:-!}"
fi
echo $svn_status_string
}
diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
index fbc9ee538..22b07b4ec 100644
--- a/plugins/svn/svn.plugin.zsh
+++ b/plugins/svn/svn.plugin.zsh
@@ -1,72 +1,76 @@
svn_prompt_info() {
- local _DISPLAY
- if in_svn; then
- if [[ "$SVN_SHOW_BRANCH" = true ]]; then
- unset SVN_SHOW_BRANCH
- _DISPLAY=$(svn_get_branch_name)
- else
- _DISPLAY=$(svn_get_repo_name)
- _DISPLAY=$(omz_urldecode "${_DISPLAY}")
- fi
- echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
-$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR"
+ local info display
+ info="$(LANG= svn info 2>/dev/null)" || return 1
+
+ if [[ "$SVN_SHOW_BRANCH" = true ]]; then
+ display="$(svn_get_branch_name "$info")"
+ else
+ display="$(svn_get_repo_name "$info")"
fi
-}
+ printf '%s%s%s%s%s%s%s%s%s%s' \
+ "$ZSH_PROMPT_BASE_COLOR" \
+ "$ZSH_THEME_SVN_PROMPT_PREFIX" \
+ "$ZSH_THEME_REPO_NAME_COLOR" \
+ "${display:gs/%/%%}" \
+ "$ZSH_PROMPT_BASE_COLOR" \
+ "$ZSH_THEME_SVN_PROMPT_SUFFIX" \
+ "$ZSH_PROMPT_BASE_COLOR" \
+ "$(svn_dirty $info)" \
+ "$(svn_dirty_pwd)" \
+ "$ZSH_PROMPT_BASE_COLOR"
+}
in_svn() {
- svn info >/dev/null 2>&1
+ svn info &>/dev/null
}
svn_get_repo_name() {
- if in_svn; then
- LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT
- LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p"
- fi
+ local info name
+ info="${1:-$(LANG= svn info 2>/dev/null)}"
+ name="$(sed -n 's/^Repository\ Root:\ .*\///p' <<< "$info")"
+ omz_urldecode "$name"
}
svn_get_branch_name() {
- local _DISPLAY=$(
- LANG=C svn info 2> /dev/null | \
- awk -F/ \
- '/^URL:/ { \
- for (i=0; i<=NF; i++) { \
- if ($i == "branches" || $i == "tags" ) { \
- print $(i+1); \
- break;\
- }; \
- if ($i == "trunk") { print $i; break; } \
- } \
- }'
+ local info branch
+ info="${1:-$(LANG= svn info 2>/dev/null)}"
+ branch=$(
+ awk -F/ '/^URL:/ {
+ for (i=0; i<=NF; i++) {
+ if ($i == "branches" || $i == "tags" ) {
+ print $(i+1)
+ break
+ };
+ if ($i == "trunk") {
+ print $i
+ break
+ }
+ }
+ }' <<< "$info"
)
+ branch="$(omz_urldecode "$branch")"
- if [[ -z "$_DISPLAY" ]]; then
- svn_get_repo_name
- else
- echo $_DISPLAY
- fi
+ echo "${branch:-$(svn_get_repo_name "$info")}"
}
svn_get_rev_nr() {
- if in_svn; then
- LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p'
- fi
+ sed -n 's/Revision:\ //p' <<<"${1:-$(LANG= svn info 2>/dev/null)}"
}
svn_dirty() {
- svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
+ svn_dirty_choose "${1:-$(LANG= svn info 2>/dev/null)}" $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
}
svn_dirty_choose() {
- if in_svn; then
- local root=$(LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p')
- if svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
- # Grep exits with 0 when "One or more lines were selected", return "dirty".
- echo $1
- else
- # Otherwise, no lines were found, or an error occurred. Return clean.
- echo $2
- fi
+ local root
+ root=$(sed -n 's/^Working Copy Root Path: //p' <<< "${1:-$(LANG= svn info 2>/dev/null)}")
+ if LANG= svn status "$root" 2>/dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
+ # Grep exits with 0 when "One or more lines were selected", return "dirty".
+ echo $2
+ else
+ # Otherwise, no lines were found, or an error occurred. Return clean.
+ echo $3
fi
}
@@ -75,13 +79,11 @@ svn_dirty_pwd () {
}
svn_dirty_choose_pwd () {
- if in_svn; then
- if svn status "$PWD" 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
- # Grep exits with 0 when "One or more lines were selected", return "dirty".
- echo $1
- else
- # Otherwise, no lines were found, or an error occurred. Return clean.
- echo $2
- fi
+ if LANG= svn status "$PWD" 2>/dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
+ # Grep exits with 0 when "One or more lines were selected", return "dirty".
+ echo $1
+ else
+ # Otherwise, no lines were found, or an error occurred. Return clean.
+ echo $2
fi
}
diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md
index 551814a39..7348f77c9 100644
--- a/plugins/tmux/README.md
+++ b/plugins/tmux/README.md
@@ -15,20 +15,21 @@ The plugin also supports the following:
## Aliases
-| Alias | Command | Description |
-| ------ | -----------------------|---------------------------------------------------------- |
-| `ta` | tmux attach -t | Attach new tmux session to already running named session |
-| `tad` | tmux attach -d -t | Detach named tmux session |
-| `ts` | tmux new-session -s | Create a new named tmux session |
-| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
-| `tksv` | tmux kill-server | Terminate all running tmux sessions |
-| `tkss` | tmux kill-session -t | Terminate named running tmux session |
-| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
+| Alias | Command | Description |
+| ---------- | -------------------------- | -------------------------------------------------------- |
+| `ta` | tmux attach -t | Attach new tmux session to already running named session |
+| `tad` | tmux attach -d -t | Detach named tmux session |
+| `ts` | tmux new-session -s | Create a new named tmux session |
+| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
+| `tksv` | tmux kill-server | Terminate all running tmux sessions |
+| `tkss` | tmux kill-session -t | Terminate named running tmux session |
+| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
+| `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
## Configuration Variables
| Variable | Description |
-|-------------------------------------|-------------------------------------------------------------------------------|
+| ----------------------------------- | ----------------------------------------------------------------------------- |
| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
index 5474c3522..b9bb66d59 100644
--- a/plugins/tmux/tmux.plugin.zsh
+++ b/plugins/tmux/tmux.plugin.zsh
@@ -3,15 +3,6 @@ if ! (( $+commands[tmux] )); then
return 1
fi
-# ALIASES
-
-alias ta='tmux attach -t'
-alias tad='tmux attach -d -t'
-alias ts='tmux new-session -s'
-alias tl='tmux list-sessions'
-alias tksv='tmux kill-server'
-alias tkss='tmux kill-session -t'
-
# CONFIGURATION VARIABLES
# Automatically start tmux
: ${ZSH_TMUX_AUTOSTART:=false}
@@ -39,6 +30,16 @@ alias tkss='tmux kill-session -t'
# Set -u option to support unicode
: ${ZSH_TMUX_UNICODE:=false}
+# ALIASES
+
+alias ta='tmux attach -t'
+alias tad='tmux attach -d -t'
+alias ts='tmux new-session -s'
+alias tl='tmux list-sessions'
+alias tksv='tmux kill-server'
+alias tkss='tmux kill-session -t'
+alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'
+
# Determine if the terminal supports 256 colors
if [[ $terminfo[colors] == 256 ]]; then
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh
index 989ffd1ff..7b765a406 100644
--- a/plugins/ubuntu/ubuntu.plugin.zsh
+++ b/plugins/ubuntu/ubuntu.plugin.zsh
@@ -53,7 +53,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
# Usage: aar ppa:xxxxxx/xxxxxx [packagename]
# If packagename is not given as 2nd argument the function will ask for it and guess the default by taking
# the part after the / from the ppa name which is sometimes the right name for the package you want to install
-aar() {
+function aar() {
if [ -n "$2" ]; then
PACKAGE=$2
else
@@ -76,7 +76,7 @@ aar() {
# apt-history rollback
# apt-history list
# Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
-apt-history () {
+function apt-history() {
case "$1" in
install)
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
@@ -105,7 +105,7 @@ apt-history () {
}
# Kernel-package building shortcut
-kerndeb () {
+function kerndeb() {
# temporarily unset MAKEFLAGS ( '-j3' will fail )
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
index a1d6bc6b0..476666bf6 100644
--- a/plugins/vi-mode/README.md
+++ b/plugins/vi-mode/README.md
@@ -30,10 +30,10 @@ plugins=(... vi-mode)
```
- `MODE_INDICATOR`: controls the string displayed when the shell is in normal mode.
- See [Mode indicator](#mode-indicator) for details.
+ See [Mode indicators](#mode-indicators) for details.
- `INSERT_MODE_INDICATOR`: controls the string displayed when the shell is in insert mode.
- See [Mode indicator](#mode-indicator) for details.
+ See [Mode indicators](#mode-indicators) for details.
## Mode indicators
diff --git a/plugins/virtualenv/virtualenv.plugin.zsh b/plugins/virtualenv/virtualenv.plugin.zsh
index 3041475ed..56707bb98 100644
--- a/plugins/virtualenv/virtualenv.plugin.zsh
+++ b/plugins/virtualenv/virtualenv.plugin.zsh
@@ -1,6 +1,6 @@
function virtualenv_prompt_info(){
[[ -n ${VIRTUAL_ENV} ]] || return
- echo "${ZSH_THEME_VIRTUALENV_PREFIX=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX=]}"
+ echo "${ZSH_THEME_VIRTUALENV_PREFIX=[}${VIRTUAL_ENV:t:gs/%/%%}${ZSH_THEME_VIRTUALENV_SUFFIX=]}"
}
# disables prompt mangling in virtual_env/bin/activate
diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
index c30216f51..d359e0c21 100644
--- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
+++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
@@ -56,7 +56,13 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_VIRTUAL_ENV" ]]; then
# We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
- deactivate && unset CD_VIRTUAL_ENV
+ if [[ -n "$VIRTUAL_ENV" ]]; then
+ # Only deactivate if VIRTUAL_ENV was set
+ # User may have deactivated manually or via another mechanism
+ deactivate
+ fi
+ # clean up regardless
+ unset CD_VIRTUAL_ENV
fi
if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active
diff --git a/plugins/volta/volta.plugin.zsh b/plugins/volta/volta.plugin.zsh
index 756dc84b3..79319394c 100644
--- a/plugins/volta/volta.plugin.zsh
+++ b/plugins/volta/volta.plugin.zsh
@@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions"
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `deno`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_volta" ]]; then
- declare -A _comps
+ typeset -g -A _comps
autoload -Uz _volta
_comps[volta]=_volta
fi
diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md
index 9a0d1708d..9c16ff2c3 100644
--- a/plugins/yarn/README.md
+++ b/plugins/yarn/README.md
@@ -9,6 +9,15 @@ To use it, add `yarn` to the plugins array in your zshrc file:
plugins=(... yarn)
```
+## Global scripts directory
+
+It also adds `yarn` global scripts dir (commonly `~/.yarn/bin`) to the `$PATH`.
+To disable this feature, set the following style in your `.zshrc`:
+
+```zsh
+zstyle ':omz:plugins:yarn' global-path false
+```
+
## Aliases
| Alias | Command | Description |
diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn
index 9db02602e..1237ba672 100644
--- a/plugins/yarn/_yarn
+++ b/plugins/yarn/_yarn
@@ -116,7 +116,7 @@ _yarn_commands_scripts() {
fi
if [[ -n $packageJson ]]; then
- scripts=($(cat "$packageJson" | perl -0777 -MJSON::PP -n -E '%r=decode_json($_); say for sort keys %{$r->{scripts}}'))
+ scripts=($(cat "$packageJson" | perl -0777 -MJSON::PP -n -E '$r=decode_json($_); do{($k=$_)=~s/:/\\:/g;say $k}for sort keys %{$r->{scripts}}'))
fi
_describe 'command or script' _commands -- _global_commands -- scripts -- binaries
@@ -144,7 +144,7 @@ _yarn_scripts() {
fi
if [[ -n $packageJson ]]; then
- scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E '%r=%{decode_json($_)->{scripts}}; printf "$_:$r{$_}\n" for sort keys %r')}")
+ scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E '%r=%{decode_json($_)->{scripts}}; do{$k=$_;($e=$k)=~s/:/\\:/g; printf "$e:$r{$k}\n"} for sort keys %r')}")
fi
commands=('env' $scripts $binaries)
diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh
index 9ba24420a..bcb8661cf 100644
--- a/plugins/yarn/yarn.plugin.zsh
+++ b/plugins/yarn/yarn.plugin.zsh
@@ -1,12 +1,14 @@
-# Skip yarn call if default global bin dir exists
-[[ -d "$HOME/.yarn/bin" ]] && bindir="$HOME/.yarn/bin" || bindir="$(yarn global bin 2>/dev/null)"
+if zstyle -T ':omz:plugins:yarn' global-path; then
+ # Skip yarn call if default global bin dir exists
+ [[ -d "$HOME/.yarn/bin" ]] && bindir="$HOME/.yarn/bin" || bindir="$(yarn global bin 2>/dev/null)"
-# Add yarn bin directory to $PATH if it exists and not already in $PATH
-[[ $? -eq 0 ]] \
- && [[ -d "$bindir" ]] \
- && (( ! ${path[(Ie)$bindir]} )) \
- && path+=("$bindir")
-unset bindir
+ # Add yarn bin directory to $PATH if it exists and not already in $PATH
+ [[ $? -eq 0 ]] \
+ && [[ -d "$bindir" ]] \
+ && (( ! ${path[(Ie)$bindir]} )) \
+ && path+=("$bindir")
+ unset bindir
+fi
alias y="yarn"
alias ya="yarn add"
diff --git a/plugins/zsh_reload/README.md b/plugins/zsh_reload/README.md
deleted file mode 100644
index 0b2e2a775..000000000
--- a/plugins/zsh_reload/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# zsh_reload plugin
-
-**This plugin is deprecated.** Use `omz reload` or `exec zsh` instead.
diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh
deleted file mode 100644
index 6a058ec5e..000000000
--- a/plugins/zsh_reload/zsh_reload.plugin.zsh
+++ /dev/null
@@ -1,7 +0,0 @@
-print ${(%):-"%F{yellow}The \`zsh_reload\` plugin is deprecated and will be removed."}
-print ${(%):-"Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f"}
-
-src() {
- print ${(%):-"%F{yellow}$0 is deprecated. Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f\n"}
- omz reload
-}
diff --git a/themes/Soliah.zsh-theme b/themes/Soliah.zsh-theme
index 070c54981..c3dd6af89 100644
--- a/themes/Soliah.zsh-theme
+++ b/themes/Soliah.zsh-theme
@@ -45,9 +45,7 @@ function rvm_gemset() {
function git_time_since_commit() {
if git rev-parse --git-dir > /dev/null 2>&1; then
# Only proceed if there is actually a commit.
- if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
- # Get the last commit.
- last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
+ if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then
now=`date +%s`
seconds_since_last_commit=$((now-last_commit))
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index 4949aa83a..96190993a 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -135,7 +135,7 @@ prompt_git() {
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info
- echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
+ echo -n "${${ref:gs/%/%%}/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
fi
}
@@ -153,7 +153,7 @@ prompt_bzr() {
if bzr_status=$(bzr status 2>&1); then
status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
- revision=$(bzr log -r-1 --log-format line | cut -d: -f1)
+ revision=${$(bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
if [[ $status_mod -gt 0 ]] ; then
prompt_segment yellow black "bzr@$revision ✚"
else
@@ -183,7 +183,7 @@ prompt_hg() {
# if working copy is clean
prompt_segment green $CURRENT_FG
fi
- echo -n $(hg prompt "☿ {rev}@{branch}") $st
+ echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
else
st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
@@ -197,7 +197,7 @@ prompt_hg() {
else
prompt_segment green $CURRENT_FG
fi
- echo -n "☿ $rev@$branch" $st
+ echo -n "☿ ${rev:gs/%/%%}@${branch:gs/%/%%}" $st
fi
fi
}
@@ -209,9 +209,8 @@ prompt_dir() {
# Virtualenv: current working virtualenv
prompt_virtualenv() {
- local virtualenv_path="$VIRTUAL_ENV"
- if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
- prompt_segment blue black "(`basename $virtualenv_path`)"
+ if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then
+ prompt_segment blue black "(${VIRTUAL_ENV:t:gs/%/%%})"
fi
}
@@ -246,8 +245,8 @@ prompt_cabal_sandbox() {
prompt_aws() {
[[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return
case "$AWS_PROFILE" in
- *-prod|*production*) prompt_segment red yellow "AWS: $AWS_PROFILE" ;;
- *) prompt_segment green black "AWS: $AWS_PROFILE" ;;
+ *-prod|*production*) prompt_segment red yellow "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
+ *) prompt_segment green black "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
esac
}
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index 1e20d8f9f..f90ba331b 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -31,7 +31,7 @@ function _git_time_since_commit() {
local last_commit now seconds_since_last_commit
local minutes hours days years commit_age
# Only proceed if there is actually a commit.
- if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
+ if last_commit=$(command git -c log.showSignature=false log --format='%at' -1 2>/dev/null); then
now=$(date +%s)
seconds_since_last_commit=$((now-last_commit))
diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme
index 3b3bdc80f..698aa2ff8 100644
--- a/themes/bureau.zsh-theme
+++ b/themes/bureau.zsh-theme
@@ -16,65 +16,73 @@ ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
-bureau_git_branch () {
+bureau_git_info () {
+ local ref
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
echo "${ref#refs/heads/}"
}
bureau_git_status() {
- _STATUS=""
+ local result gitstatus
+ gitstatus="$(command git status --porcelain -b 2>/dev/null)"
# check status of files
- _INDEX=$(command git status --porcelain 2> /dev/null)
- if [[ -n "$_INDEX" ]]; then
- if $(echo "$_INDEX" | command grep -q '^[AMRD]. '); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
+ local gitfiles="$(tail -n +2 <<< "$gitstatus")"
+ if [[ -n "$gitfiles" ]]; then
+ if [[ "$gitfiles" =~ $'(^|\n)[AMRD]. ' ]]; then
+ result+="$ZSH_THEME_GIT_PROMPT_STAGED"
fi
- if $(echo "$_INDEX" | command grep -q '^.[MTD] '); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
+ if [[ "$gitfiles" =~ $'(^|\n).[MTD] ' ]]; then
+ result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi
- if $(echo "$_INDEX" | command grep -q -E '^\?\? '); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
+ if [[ "$gitfiles" =~ $'(^|\n)\\?\\? ' ]]; then
+ result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi
- if $(echo "$_INDEX" | command grep -q '^UU '); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
+ if [[ "$gitfiles" =~ $'(^|\n)UU ' ]]; then
+ result+="$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi
else
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
+ result+="$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
# check status of local repository
- _INDEX=$(command git status --porcelain -b 2> /dev/null)
- if $(echo "$_INDEX" | command grep -q '^## .*ahead'); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
+ local gitbranch="$(head -n 1 <<< "$gitstatus")"
+ if [[ "$gitbranch" =~ '^## .*ahead' ]]; then
+ result+="$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
- if $(echo "$_INDEX" | command grep -q '^## .*behind'); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
+ if [[ "$gitbranch" =~ '^## .*behind' ]]; then
+ result+="$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
- if $(echo "$_INDEX" | command grep -q '^## .*diverged'); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
+ if [[ "$gitbranch" =~ '^## .*diverged' ]]; then
+ result+="$ZSH_THEME_GIT_PROMPT_DIVERGED"
fi
- if $(command git rev-parse --verify refs/stash &> /dev/null); then
- _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
+ # check if there are stashed changes
+ if command git rev-parse --verify refs/stash &> /dev/null; then
+ result+="$ZSH_THEME_GIT_PROMPT_STASHED"
fi
- echo $_STATUS
+ echo $result
}
-bureau_git_prompt () {
- local _branch=$(bureau_git_branch)
- local _status=$(bureau_git_status)
- local _result=""
- if [[ "${_branch}x" != "x" ]]; then
- _result="$ZSH_THEME_GIT_PROMPT_PREFIX$_branch"
- if [[ "${_status}x" != "x" ]]; then
- _result="$_result $_status"
- fi
- _result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX"
+bureau_git_prompt() {
+ # check git information
+ local gitinfo=$(bureau_git_info)
+ if [[ -z "$gitinfo" ]]; then
+ return
+ fi
+
+ # quote % in git information
+ local output="${gitinfo:gs/%/%%}"
+
+ # check git status
+ local gitstatus=$(bureau_git_status)
+ if [[ -n "$gitstatus" ]]; then
+ output+=" $gitstatus"
fi
- echo $_result
+
+ echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${output}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
@@ -95,19 +103,14 @@ get_space () {
local STR=$1$2
local zero='%([BSUbfksu]|([FB]|){*})'
local LENGTH=${#${(S%%)STR//$~zero/}}
- local SPACES=""
- (( LENGTH = ${COLUMNS} - $LENGTH - 1))
-
- for i in {0..$LENGTH}
- do
- SPACES="$SPACES "
- done
+ local SPACES=$(( COLUMNS - LENGTH - ${ZLE_RPROMPT_INDENT:-1} ))
- echo $SPACES
+ (( SPACES > 0 )) || return
+ printf ' %.0s' {1..$SPACES}
}
_1LEFT="$_USERNAME $_PATH"
-_1RIGHT="[%*] "
+_1RIGHT="[%*]"
bureau_precmd () {
_1SPACES=`get_space $_1LEFT $_1RIGHT`
diff --git a/themes/candy-kingdom.zsh-theme b/themes/candy-kingdom.zsh-theme
index ad03cc320..31e63df15 100644
--- a/themes/candy-kingdom.zsh-theme
+++ b/themes/candy-kingdom.zsh-theme
@@ -11,7 +11,9 @@ patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset
fi
function box_name {
- [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
+ local box="${SHORT_HOST:-$HOST}"
+ [[ -f ~/.box-name ]] && box="$(< ~/.box-name)"
+ echo "${box:gs/%/%%}"
}
PROMPT='
diff --git a/themes/dieter.zsh-theme b/themes/dieter.zsh-theme
index 58d9f88a9..83f2dcc7c 100644
--- a/themes/dieter.zsh-theme
+++ b/themes/dieter.zsh-theme
@@ -6,7 +6,7 @@
# The exit code visual cues will only display once.
# (i.e. they will be reset, even if you hit enter a few times on empty command prompts)
-typeset -A host_repr
+typeset -g -A host_repr
# translate hostnames into shortened, colorcoded strings
host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4")
diff --git a/themes/dogenpunk.zsh-theme b/themes/dogenpunk.zsh-theme
index 6a9921288..923ca74bc 100644
--- a/themes/dogenpunk.zsh-theme
+++ b/themes/dogenpunk.zsh-theme
@@ -37,9 +37,7 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
function git_time_since_commit() {
if git rev-parse --git-dir > /dev/null 2>&1; then
# Only proceed if there is actually a commit.
- if git log -n 1 > /dev/null 2>&1; then
- # Get the last commit.
- last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
+ if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then
now=`date +%s`
seconds_since_last_commit=$((now-last_commit))
diff --git a/themes/emotty.zsh-theme b/themes/emotty.zsh-theme
index 044b317e8..ba0840950 100644
--- a/themes/emotty.zsh-theme
+++ b/themes/emotty.zsh-theme
@@ -46,6 +46,16 @@
# is shown (see vcs_action_glyph variable, default: chevron).
# ------------------------------------------------------------------------------
+(( ${+functions[emotty]} )) || {
+ echo "error: the emotty theme requires the emotty plugin" >&2
+ return 1
+}
+
+(( ${+emoji} )) || {
+ echo "error: the emotty theme requires the emoji plugin" >&2
+ return 1
+}
+
user_prompt="$(emotty)"
root_prompt="$emoji[skull]"
warn_prompt="$emoji[collision_symbol]"
diff --git a/themes/fino-time.zsh-theme b/themes/fino-time.zsh-theme
index 57c47db02..c7e2d965e 100644
--- a/themes/fino-time.zsh-theme
+++ b/themes/fino-time.zsh-theme
@@ -21,10 +21,11 @@ function prompt_char {
}
function box_name {
- [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
+ local box="${SHORT_HOST:-$HOST}"
+ [[ -f ~/.box-name ]] && box="$(< ~/.box-name)"
+ echo "${box:gs/%/%%}"
}
-
PROMPT="╭─%{$FG[040]%}%n%{$reset_color%} %{$FG[239]%}at%{$reset_color%} %{$FG[033]%}$(box_name)%{$reset_color%} %{$FG[239]%}in%{$reset_color%} %{$terminfo[bold]$FG[226]%}%~%{$reset_color%}\$(git_prompt_info)\$(ruby_prompt_info) %D - %*
╰─\$(virtualenv_info)\$(prompt_char) "
diff --git a/themes/fino.zsh-theme b/themes/fino.zsh-theme
index 2523c1776..9365a3c42 100644
--- a/themes/fino.zsh-theme
+++ b/themes/fino.zsh-theme
@@ -21,7 +21,9 @@ function prompt_char {
}
function box_name {
- [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
+ local box="${SHORT_HOST:-$HOST}"
+ [[ -f ~/.box-name ]] && box="$(< ~/.box-name)"
+ echo "${box:gs/%/%%}"
}
local ruby_env='$(ruby_prompt_info)'
diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme
index 11d799a84..e8c490884 100644
--- a/themes/jonathan.zsh-theme
+++ b/themes/jonathan.zsh-theme
@@ -66,7 +66,7 @@ if [[ "${langinfo[CODESET]}" = UTF-8 ]]; then
PR_LRCORNER="┘"
PR_URCORNER="┐"
else
- typeset -A altchar
+ typeset -g -A altchar
set -A altchar ${(s..)terminfo[acsc]}
# Some stuff to help us draw nice lines
PR_SET_CHARSET="%{$terminfo[enacs]%}"
diff --git a/themes/rkj-repos.zsh-theme b/themes/rkj-repos.zsh-theme
index 65a075456..3cb452335 100644
--- a/themes/rkj-repos.zsh-theme
+++ b/themes/rkj-repos.zsh-theme
@@ -30,6 +30,6 @@ function mygit() {
function retcode() {}
# alternate prompt with git & hg
-PROMPT=$'%{$fg_bold[blue]%}┌─[%{$fg_bold[green]%}%n%b%{$fg[black]%}@%{$fg[cyan]%}%m%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%{$fg_bold[white]%}%~%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%b%{$fg[yellow]%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{$fg_bold[blue]%}]
+PROMPT=$'%{$fg_bold[blue]%}┌─[%{$fg_bold[green]%}%n%b%{$fg[black]%}@%{$fg[cyan]%}%m%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%{$fg_bold[default]%}%~%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%b%{$fg[yellow]%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{$fg_bold[blue]%}]
%{$fg_bold[blue]%}└─[%{$fg_bold[magenta]%}%?$(retcode)%{$fg_bold[blue]%}] <$(mygit)$(hg_prompt_info)>%{$reset_color%} '
PS2=$' \e[0;34m%}%B>%{\e[0m%}%b '
diff --git a/themes/simple.zsh-theme b/themes/simple.zsh-theme
index 8d0070ba7..bcdecc1a5 100644
--- a/themes/simple.zsh-theme
+++ b/themes/simple.zsh-theme
@@ -1,6 +1,6 @@
-PROMPT='%(!.%{$fg[red]%}.%{$fg[green]%})%~%{$fg_bold[blue]%}$(git_prompt_info)%{$reset_color%} '
+PROMPT='%(!.%{$fg[red]%}.%{$fg[green]%})%~$(git_prompt_info)%{$reset_color%} '
-ZSH_THEME_GIT_PROMPT_PREFIX="("
-ZSH_THEME_GIT_PROMPT_SUFFIX=")"
-ZSH_THEME_GIT_PROMPT_DIRTY=" ✗"
-ZSH_THEME_GIT_PROMPT_CLEAN=" ✔"
+ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[blue]%}("
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
+ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗"
+ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔"
diff --git a/themes/smt.zsh-theme b/themes/smt.zsh-theme
index 7f54472c6..52e6d9a21 100644
--- a/themes/smt.zsh-theme
+++ b/themes/smt.zsh-theme
@@ -40,7 +40,7 @@ function git_time_since_commit() {
local last_commit seconds_since_last_commit
# Only proceed if there is actually a commit
- if ! last_commit=$(command git log --pretty=format:'%at' -1 2>/dev/null); then
+ if ! last_commit=$(command git -c log.showSignature=false log --pretty=format:'%at' -1 2>/dev/null); then
echo "[$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL~%{$reset_color%}]"
return
fi
diff --git a/themes/trapd00r.zsh-theme b/themes/trapd00r.zsh-theme
index 4e3238393..849daf30b 100644
--- a/themes/trapd00r.zsh-theme
+++ b/themes/trapd00r.zsh-theme
@@ -38,6 +38,8 @@ local c13=$'\e[38;5;196m\e[1m'
zsh_path() {
+ setopt localoptions nopromptsubst
+
local colors
colors=$(echoti colors)
diff --git a/themes/wedisagree.zsh-theme b/themes/wedisagree.zsh-theme
index 07006ecd9..e9e9d6ef8 100644
--- a/themes/wedisagree.zsh-theme
+++ b/themes/wedisagree.zsh-theme
@@ -69,9 +69,7 @@ function rvm_gemset() {
function git_time_since_commit() {
if git rev-parse --git-dir > /dev/null 2>&1; then
# Only proceed if there is actually a commit.
- if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
- # Get the last commit.
- last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
+ if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then
now=`date +%s`
seconds_since_last_commit=$((now-last_commit))
diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme
index 45bbae2d1..4c3c56ffc 100644
--- a/themes/ys.zsh-theme
+++ b/themes/ys.zsh-theme
@@ -19,6 +19,13 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
ZSH_THEME_GIT_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY"
ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN"
+# SVN info
+local svn_info='$(svn_prompt_info)'
+ZSH_THEME_SVN_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}svn${YS_VCS_PROMPT_PREFIX2}"
+ZSH_THEME_SVN_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX"
+ZSH_THEME_SVN_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY"
+ZSH_THEME_SVN_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN"
+
# HG info
local hg_info='$(ys_hg_prompt_info)'
ys_hg_prompt_info() {
@@ -42,7 +49,7 @@ local venv_info='$(virtenv_prompt)'
YS_THEME_VIRTUALENV_PROMPT_PREFIX=" %{$fg[green]%}"
YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%"
virtenv_prompt() {
- [[ -n ${VIRTUAL_ENV} ]] || return
+ [[ -n "${VIRTUAL_ENV:-}" ]] || return
echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}"
}
@@ -66,6 +73,7 @@ PROMPT="
%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
${hg_info}\
${git_info}\
+${svn_info}\
${venv_info}\
\
[%*] $exit_code
diff --git a/tools/changelog.sh b/tools/changelog.sh
index 664f34608..6489a3cb2 100755
--- a/tools/changelog.sh
+++ b/tools/changelog.sh
@@ -23,8 +23,7 @@ TYPES=(
test "Testing"
)
-#* Types that will be displayed in their own section,
-#* in the order specified here.
+#* Types that will be displayed in their own section, in the order specified here.
local -a MAIN_TYPES
MAIN_TYPES=(feat fix perf docs)
@@ -34,7 +33,8 @@ OTHER_TYPES=(refactor style other)
#* Commit types that don't appear in $MAIN_TYPES nor $OTHER_TYPES
#* will not be displayed and will simply be ignored.
-
+local -a IGNORED_TYPES
+IGNORED_TYPES=(${${${(@k)TYPES}:|MAIN_TYPES}:|OTHER_TYPES})
############################
# COMMIT PARSING UTILITIES #
@@ -139,7 +139,7 @@ function parse-commit {
# [BREAKING CHANGE: warning]
# commits holds the commit type
- commits[$hash]="$(commit:type "$subject")"
+ types[$hash]="$(commit:type "$subject")"
# scopes holds the commit scope
scopes[$hash]="$(commit:scope "$subject")"
# subjects holds the commit subject
@@ -164,26 +164,32 @@ function parse-commit {
function display-release {
# This function uses the following globals: output, version,
- # commits (A), subjects (A), scopes (A), breaking (A) and reverts (A).
+ # types (A), subjects (A), scopes (A), breaking (A) and reverts (A).
#
# - output is the output format to use when formatting (raw|text|md)
# - version is the version in which the commits are made
- # - commits, subjects, scopes, breaking, and reverts are associative arrays
+ # - types, subjects, scopes, breaking, and reverts are associative arrays
# with commit hashes as keys
# Remove commits that were reverted
local hash rhash
for hash rhash in ${(kv)reverts}; do
- if (( ${+commits[$rhash]} )); then
+ if (( ${+types[$rhash]} )); then
# Remove revert commit
- unset "commits[$hash]" "subjects[$hash]" "scopes[$hash]" "breaking[$hash]"
+ unset "types[$hash]" "subjects[$hash]" "scopes[$hash]" "breaking[$hash]"
# Remove reverted commit
- unset "commits[$rhash]" "subjects[$rhash]" "scopes[$rhash]" "breaking[$rhash]"
+ unset "types[$rhash]" "subjects[$rhash]" "scopes[$rhash]" "breaking[$rhash]"
fi
done
+ # Remove commits from ignored types unless it has breaking change information
+ for hash in ${(k)types[(R)${(j:|:)IGNORED_TYPES}]}; do
+ (( ! ${+breaking[$hash]} )) || continue
+ unset "types[$hash]" "subjects[$hash]" "scopes[$hash]"
+ done
+
# If no commits left skip displaying the release
- if (( $#commits == 0 )); then
+ if (( $#types == 0 )); then
return
fi
@@ -313,7 +319,7 @@ function display-release {
local hash type="$1"
local -a hashes
- hashes=(${(k)commits[(R)$type]})
+ hashes=(${(k)types[(R)$type]})
# If no commits found of type $type, go to next type
(( $#hashes != 0 )) || return 0
@@ -330,7 +336,7 @@ function display-release {
# Commits made under types considered other changes
local -A changes
- changes=(${(kv)commits[(R)${(j:|:)OTHER_TYPES}]})
+ changes=(${(kv)types[(R)${(j:|:)OTHER_TYPES}]})
# If no commits found under "other" types, don't display anything
(( $#changes != 0 )) || return 0
@@ -388,19 +394,19 @@ function main {
fi
# Commit classification arrays
- local -A commits subjects scopes breaking reverts
+ local -A types subjects scopes breaking reverts
local truncate=0 read_commits=0
local version tag
local hash refs subject body
# Get the first version name:
# 1) try tag-like version, or
- # 2) try name-rev, or
- # 3) try branch name, or
+ # 2) try branch name, or
+ # 3) try name-rev, or
# 4) try short hash
version=$(command git describe --tags $until 2>/dev/null) \
- || version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" $until 2>/dev/null) \
|| version=$(command git symbolic-ref --quiet --short $until 2>/dev/null) \
+ || version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" $until 2>/dev/null) \
|| version=$(command git rev-parse --short $until 2>/dev/null)
# Get commit list from $until commit until $since commit, or until root commit if $since is unset
@@ -414,7 +420,7 @@ function main {
# --first-parent: commits from merged branches are omitted
local SEP="0mZmAgIcSeP"
local -a raw_commits
- raw_commits=(${(0)"$(command git log -z \
+ raw_commits=(${(0)"$(command git -c log.showSignature=false log -z \
--format="%h${SEP}%D${SEP}%s${SEP}%b" --abbrev=7 \
--no-merges --first-parent $range)"})
@@ -441,7 +447,7 @@ function main {
# Output previous release
display-release
# Reinitialize commit storage
- commits=()
+ types=()
subjects=()
scopes=()
breaking=()
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index 293f48edf..a36aecb84 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -10,11 +10,13 @@ fi
# - auto: the update is performed automatically when it's time
# - reminder: a reminder is shown to the user when it's time to update
# - disabled: automatic update is turned off
-zstyle -s ':omz:update' mode update_mode || update_mode=prompt
+zstyle -s ':omz:update' mode update_mode || {
+ update_mode=prompt
-# Support old-style settings
-[[ "$DISABLE_UPDATE_PROMPT" != true ]] || update_mode=auto
-[[ "$DISABLE_AUTO_UPDATE" != true ]] || update_mode=disabled
+ # If the mode zstyle setting is not set, support old-style settings
+ [[ "$DISABLE_UPDATE_PROMPT" != true ]] || update_mode=auto
+ [[ "$DISABLE_AUTO_UPDATE" != true ]] || update_mode=disabled
+}
# Cancel update if:
# - the automatic update is disabled.
@@ -34,11 +36,11 @@ function current_epoch() {
function is_update_available() {
local branch
- branch=${"$(cd "$ZSH"; git config --local oh-my-zsh.branch)":-master}
+ branch=${"$(cd -q "$ZSH"; git config --local oh-my-zsh.branch)":-master}
local remote remote_url remote_repo
- remote=${"$(cd "$ZSH"; git config --local oh-my-zsh.remote)":-origin}
- remote_url=$(cd "$ZSH"; git config remote.$remote.url)
+ remote=${"$(cd -q "$ZSH"; git config --local oh-my-zsh.remote)":-origin}
+ remote_url=$(cd -q "$ZSH"; git config remote.$remote.url)
local repo
case "$remote_url" in
@@ -56,7 +58,7 @@ function is_update_available() {
# Get local HEAD. If this fails assume there are updates
local local_head
- local_head=$(cd "$ZSH"; git rev-parse $branch 2>/dev/null) || return 0
+ local_head=$(cd -q "$ZSH"; git rev-parse $branch 2>/dev/null) || return 0
# Get remote HEAD. If no suitable command is found assume there are updates
# On any other error, skip the update (connection may be down)
@@ -87,6 +89,31 @@ function update_ohmyzsh() {
fi
}
+function has_typed_input() {
+ # Created by Philippe Troin <phil@fifi.org>
+ # https://zsh.org/mla/users/2022/msg00062.html
+ emulate -L zsh
+ zmodload zsh/zselect
+
+ # Back up stty settings prior to disabling canonical mode
+ # Consider that no input can be typed if stty fails
+ # (this might happen if stdin is not a terminal)
+ local termios
+ termios=$(stty --save 2>/dev/null) || return 1
+ {
+ # Disable canonical mode so that typed input counts
+ # regardless of whether Enter was pressed
+ stty -icanon
+
+ # Poll stdin (fd 0) for data ready to be read
+ zselect -t 0 -r 0
+ return $?
+ } always {
+ # Restore stty settings
+ stty $termios
+ }
+}
+
() {
emulate -L zsh
@@ -134,7 +161,7 @@ function update_ohmyzsh() {
fi
# Test if Oh My Zsh directory is a git repository
- if ! (cd "$ZSH" && LANG= git rev-parse &>/dev/null); then
+ if ! (cd -q "$ZSH" && LANG= git rev-parse &>/dev/null); then
echo >&2 "[oh-my-zsh] Can't update: not a git repository."
return
fi
@@ -144,26 +171,35 @@ function update_ohmyzsh() {
return
fi
- # Ask for confirmation before updating unless in auto mode
+ # Don't ask for confirmation before updating if in auto mode
if [[ "$update_mode" = auto ]]; then
update_ohmyzsh
- elif [[ "$update_mode" = reminder ]]; then
+ return $?
+ fi
+
+ # If in reminder mode show reminder and exit
+ if [[ "$update_mode" = reminder ]]; then
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
- else
- # input sink to swallow all characters typed before the prompt
- # and add a newline if there wasn't one after characters typed
- while read -t -k 1 option; do true; done
- [[ "$option" != ($'\n'|"") ]] && echo
-
- echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
- read -r -k 1 option
- [[ "$option" != $'\n' ]] && echo
- case "$option" in
- [yY$'\n']) update_ohmyzsh ;;
- [nN]) update_last_updated_file ;&
- *) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
- esac
+ return 0
fi
+
+ # If user has typed input, show reminder and exit
+ if has_typed_input; then
+ echo
+ echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
+ return 0
+ fi
+
+ # Ask for confirmation and only update on 'y', 'Y' or Enter
+ # Otherwise just show a reminder for how to update
+ echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
+ read -r -k 1 option
+ [[ "$option" = $'\n' ]] || echo
+ case "$option" in
+ [yY$'\n']) update_ohmyzsh ;;
+ [nN]) update_last_updated_file ;&
+ *) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
+ esac
}
unset update_mode
diff --git a/tools/install.sh b/tools/install.sh
index 731d89a29..e64e39063 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -37,6 +37,13 @@
#
set -e
+# Make sure important variables exist if not already defined
+#
+# $USER is defined by login(1) which is not always executed (e.g. containers)
+# POSIX: https://pubs.opengroup.org/onlinepubs/009695299/utilities/id.html
+USER=${USER:-$(id -u -n)}
+
+
# Track if $ZSH was provided
custom_zsh=${ZSH:+yes}
@@ -56,6 +63,30 @@ command_exists() {
command -v "$@" >/dev/null 2>&1
}
+user_can_sudo() {
+ # Check if sudo is installed
+ command_exists sudo || return 1
+ # The following command has 3 parts:
+ #
+ # 1. Run `sudo` with `-v`. Does the following:
+ # • with privilege: asks for a password immediately.
+ # • without privilege: exits with error code 1 and prints the message:
+ # Sorry, user <username> may not run sudo on <hostname>
+ #
+ # 2. Pass `-n` to `sudo` to tell it to not ask for a password. If the
+ # password is not required, the command will finish with exit code 0.
+ # If one is required, sudo will exit with error code 1 and print the
+ # message:
+ # sudo: a password is required
+ #
+ # 3. Check for the words "may not run sudo" in the output to really tell
+ # whether the user has privileges or not. For that we have to make sure
+ # to run `sudo` in the default locale (with `LANG=`) so that the message
+ # stays consistent regardless of the user's locale.
+ #
+ ! LANG= sudo -n -v 2>&1 | grep -q "may not run sudo"
+}
+
# The [ -t 1 ] check only works when the function is not called from
# a subshell (like in `$(...)` or `(...)`, so this hack redefines the
# function at the top level to always return false when stdout is not
@@ -127,6 +158,24 @@ supports_hyperlinks() {
return 1
}
+# Adapted from code and information by Anton Kochkov (@XVilka)
+# Source: https://gist.github.com/XVilka/8346728
+supports_truecolor() {
+ case "$COLORTERM" in
+ truecolor|24bit) return 0 ;;
+ esac
+
+ case "$TERM" in
+ iterm |\
+ tmux-truecolor |\
+ linux-truecolor |\
+ xterm-truecolor |\
+ screen-truecolor) return 0 ;;
+ esac
+
+ return 1
+}
+
fmt_link() {
# $1: text, $2: url, $3: fallback mode
if supports_hyperlinks; then
@@ -150,13 +199,34 @@ fmt_code() {
}
fmt_error() {
- printf '%sError: %s%s\n' "$BOLD$RED" "$*" "$RESET" >&2
+ printf '%sError: %s%s\n' "${FMT_BOLD}${FMT_RED}" "$*" "$FMT_RESET" >&2
}
setup_color() {
# Only use colors if connected to a terminal
- if is_tty; then
- RAINBOW="
+ if ! is_tty; then
+ FMT_RAINBOW=""
+ FMT_RED=""
+ FMT_GREEN=""
+ FMT_YELLOW=""
+ FMT_BLUE=""
+ FMT_BOLD=""
+ FMT_RESET=""
+ return
+ fi
+
+ if supports_truecolor; then
+ FMT_RAINBOW="
+ $(printf '\033[38;2;255;0;0m')
+ $(printf '\033[38;2;255;97;0m')
+ $(printf '\033[38;2;247;255;0m')
+ $(printf '\033[38;2;0;255;30m')
+ $(printf '\033[38;2;77;0;255m')
+ $(printf '\033[38;2;168;0;255m')
+ $(printf '\033[38;2;245;0;172m')
+ "
+ else
+ FMT_RAINBOW="
$(printf '\033[38;5;196m')
$(printf '\033[38;5;202m')
$(printf '\033[38;5;226m')
@@ -165,21 +235,14 @@ setup_color() {
$(printf '\033[38;5;093m')
$(printf '\033[38;5;163m')
"
- RED=$(printf '\033[31m')
- GREEN=$(printf '\033[32m')
- YELLOW=$(printf '\033[33m')
- BLUE=$(printf '\033[34m')
- BOLD=$(printf '\033[1m')
- RESET=$(printf '\033[m')
- else
- RAINBOW=""
- RED=""
- GREEN=""
- YELLOW=""
- BLUE=""
- BOLD=""
- RESET=""
fi
+
+ FMT_RED=$(printf '\033[31m')
+ FMT_GREEN=$(printf '\033[32m')
+ FMT_YELLOW=$(printf '\033[33m')
+ FMT_BLUE=$(printf '\033[34m')
+ FMT_BOLD=$(printf '\033[1m')
+ FMT_RESET=$(printf '\033[0m')
}
setup_ohmyzsh() {
@@ -190,7 +253,7 @@ setup_ohmyzsh() {
# precedence over umasks except for filesystems mounted with option "noacl".
umask g-w,o-w
- echo "${BLUE}Cloning Oh My Zsh...${RESET}"
+ echo "${FMT_BLUE}Cloning Oh My Zsh...${FMT_RESET}"
command_exists git || {
fmt_error "git is not installed"
@@ -204,13 +267,19 @@ setup_ohmyzsh() {
exit 1
fi
- git clone -c core.eol=lf -c core.autocrlf=false \
- -c fsck.zeroPaddedFilemode=ignore \
- -c fetch.fsck.zeroPaddedFilemode=ignore \
- -c receive.fsck.zeroPaddedFilemode=ignore \
- -c oh-my-zsh.remote=origin \
- -c oh-my-zsh.branch="$BRANCH" \
- --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
+ # Manual clone with git config options to support git < v1.7.2
+ git init "$ZSH" && cd "$ZSH" \
+ && git config core.eol lf \
+ && git config core.autocrlf false \
+ && git config fsck.zeroPaddedFilemode ignore \
+ && git config fetch.fsck.zeroPaddedFilemode ignore \
+ && git config receive.fsck.zeroPaddedFilemode ignore \
+ && git config oh-my-zsh.remote origin \
+ && git config oh-my-zsh.branch "$BRANCH" \
+ && git remote add origin "$REMOTE" \
+ && git fetch --depth=1 origin \
+ && git checkout -b "$BRANCH" "origin/$BRANCH" || {
+ rm -rf "$ZSH"
fmt_error "git clone of oh-my-zsh repo failed"
exit 1
}
@@ -222,14 +291,14 @@ setup_zshrc() {
# Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones
# with datestamp of installation that moved them aside, so we never actually
# destroy a user's original zshrc
- echo "${BLUE}Looking for an existing zsh config...${RESET}"
+ echo "${FMT_BLUE}Looking for an existing zsh config...${FMT_RESET}"
# Must use this exact name so uninstall.sh can find it
OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
# Skip this if the user doesn't want to replace an existing .zshrc
if [ "$KEEP_ZSHRC" = yes ]; then
- echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}"
+ echo "${FMT_YELLOW}Found ~/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}"
return
fi
if [ -e "$OLD_ZSHRC" ]; then
@@ -241,14 +310,14 @@ setup_zshrc() {
fi
mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"
- echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \
- "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}"
+ echo "${FMT_YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \
+ "${FMT_GREEN}Backing up to ${OLD_OLD_ZSHRC}${FMT_RESET}"
fi
- echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}"
+ echo "${FMT_YELLOW}Found ~/.zshrc.${FMT_RESET} ${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}"
mv ~/.zshrc "$OLD_ZSHRC"
fi
- echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"
+ echo "${FMT_GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${FMT_RESET}"
# Replace $HOME path with '$HOME' in $ZSH variable in .zshrc file
omz=$(echo "$ZSH" | sed "s|^$HOME/|\$HOME/|")
@@ -273,19 +342,19 @@ setup_shell() {
if ! command_exists chsh; then
cat <<EOF
I can't change your shell automatically because this system does not have chsh.
-${BLUE}Please manually change your default shell to zsh${RESET}
+${FMT_BLUE}Please manually change your default shell to zsh${FMT_RESET}
EOF
return
fi
- echo "${BLUE}Time to change your default shell to zsh:${RESET}"
+ echo "${FMT_BLUE}Time to change your default shell to zsh:${FMT_RESET}"
# Prompt for user choice on changing the default login shell
printf '%sDo you want to change your default shell to zsh? [Y/n]%s ' \
- "$YELLOW" "$RESET"
+ "$FMT_YELLOW" "$FMT_RESET"
read -r opt
case $opt in
- y*|Y*|"") echo "Changing the shell..." ;;
+ y*|Y*|"") ;;
n*|N*) echo "Shell change skipped."; return ;;
*) echo "Invalid choice. Shell change skipped."; return ;;
esac
@@ -323,38 +392,55 @@ EOF
if [ -n "$SHELL" ]; then
echo "$SHELL" > ~/.shell.pre-oh-my-zsh
else
- grep "^$USERNAME:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
+ grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
+ fi
+
+ echo "Changing your shell to $zsh..."
+
+ # Check if user has sudo privileges to run `chsh` with or without `sudo`
+ #
+ # This allows the call to succeed without password on systems where the
+ # user does not have a password but does have sudo privileges, like in
+ # Google Cloud Shell.
+ #
+ # On systems that don't have a user with passwordless sudo, the user will
+ # be prompted for the password either way, so this shouldn't cause any issues.
+ #
+ if user_can_sudo; then
+ sudo -k chsh -s "$zsh" "$USER" # -k forces the password prompt
+ else
+ chsh -s "$zsh" "$USER" # run chsh normally
fi
- # Actually change the default shell to zsh
- if ! chsh -s "$zsh"; then
+ # Check if the shell change was successful
+ if [ $? -ne 0 ]; then
fmt_error "chsh command unsuccessful. Change your default shell manually."
else
export SHELL="$zsh"
- echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}"
+ echo "${FMT_GREEN}Shell successfully changed to '$zsh'.${FMT_RESET}"
fi
echo
}
-# shellcheck disable=SC2183 # printf string has more %s than arguments ($RAINBOW expands to multiple arguments)
+# shellcheck disable=SC2183 # printf string has more %s than arguments ($FMT_RAINBOW expands to multiple arguments)
print_success() {
- printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
- printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
- printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET
- printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET
- printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
- printf '%s %s %s %s /____/ %s %s %s %s....is now installed!%s\n' $RAINBOW $GREEN $RESET
+ printf '%s %s__ %s %s %s %s %s__ %s\n' $FMT_RAINBOW $FMT_RESET
+ printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $FMT_RAINBOW $FMT_RESET
+ printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $FMT_RAINBOW $FMT_RESET
+ printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $FMT_RAINBOW $FMT_RESET
+ printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $FMT_RAINBOW $FMT_RESET
+ printf '%s %s %s %s /____/ %s %s %s %s....is now installed!%s\n' $FMT_RAINBOW $FMT_GREEN $FMT_RESET
printf '\n'
printf '\n'
- printf "%s %s %s\n" "Before you scream ${BOLD}${YELLOW}Oh My Zsh!${RESET} look over the" \
+ printf "%s %s %s\n" "Before you scream ${FMT_BOLD}${FMT_YELLOW}Oh My Zsh!${FMT_RESET} look over the" \
"$(fmt_code "$(fmt_link ".zshrc" "file://$HOME/.zshrc" --text)")" \
"file to select plugins, themes, and options."
printf '\n'
printf '%s\n' "• Follow us on Twitter: $(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
printf '%s\n' "• Join our Discord community: $(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
printf '%s\n' "• Get stickers, t-shirts, coffee mugs and more: $(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
- printf '%s\n' $RESET
+ printf '%s\n' $FMT_RESET
}
main() {
@@ -377,12 +463,12 @@ main() {
setup_color
if ! command_exists zsh; then
- echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first."
+ echo "${FMT_YELLOW}Zsh is not installed.${FMT_RESET} Please install zsh first."
exit 1
fi
if [ -d "$ZSH" ]; then
- echo "${YELLOW}The \$ZSH folder already exists ($ZSH).${RESET}"
+ echo "${FMT_YELLOW}The \$ZSH folder already exists ($ZSH).${FMT_RESET}"
if [ "$custom_zsh" = yes ]; then
cat <<EOF
@@ -410,7 +496,7 @@ EOF
print_success
if [ $RUNZSH = no ]; then
- echo "${YELLOW}Run zsh to try it out.${RESET}"
+ echo "${FMT_YELLOW}Run zsh to try it out.${FMT_RESET}"
exit
fi
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index 994ffe9c9..b6cb10b5a 100755
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -86,6 +86,24 @@ supports_hyperlinks() {
return 1
}
+# Adapted from code and information by Anton Kochkov (@XVilka)
+# Source: https://gist.github.com/XVilka/8346728
+supports_truecolor() {
+ case "$COLORTERM" in
+ truecolor|24bit) return 0 ;;
+ esac
+
+ case "$TERM" in
+ iterm |\
+ tmux-truecolor |\
+ linux-truecolor |\
+ xterm-truecolor |\
+ screen-truecolor) return 0 ;;
+ esac
+
+ return 1
+}
+
fmt_link() {
# $1: text, $2: url, $3: fallback mode
if supports_hyperlinks; then
@@ -107,15 +125,27 @@ setopt typeset_silent
typeset -a RAINBOW
if is_tty; then
- RAINBOW=(
- "$(printf '\033[38;5;196m')"
- "$(printf '\033[38;5;202m')"
- "$(printf '\033[38;5;226m')"
- "$(printf '\033[38;5;082m')"
- "$(printf '\033[38;5;021m')"
- "$(printf '\033[38;5;093m')"
- "$(printf '\033[38;5;163m')"
- )
+ if supports_truecolor; then
+ RAINBOW=(
+ "$(printf '\033[38;2;255;0;0m')"
+ "$(printf '\033[38;2;255;97;0m')"
+ "$(printf '\033[38;2;247;255;0m')"
+ "$(printf '\033[38;2;0;255;30m')"
+ "$(printf '\033[38;2;77;0;255m')"
+ "$(printf '\033[38;2;168;0;255m')"
+ "$(printf '\033[38;2;245;0;172m')"
+ )
+ else
+ RAINBOW=(
+ "$(printf '\033[38;5;196m')"
+ "$(printf '\033[38;5;202m')"
+ "$(printf '\033[38;5;226m')"
+ "$(printf '\033[38;5;082m')"
+ "$(printf '\033[38;5;021m')"
+ "$(printf '\033[38;5;093m')"
+ "$(printf '\033[38;5;163m')"
+ )
+ fi
RED=$(printf '\033[31m')
GREEN=$(printf '\033[32m')
@@ -164,7 +194,7 @@ last_commit=$(git rev-parse "$branch")
# Update Oh My Zsh
printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
-if git pull --rebase --stat $remote $branch; then
+if LANG= git pull --quiet --rebase $remote $branch; then
# Check if it was really updated or not
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
message="Oh My Zsh is already at the latest version."