From d1c07f9569f4f7bb90345ccc363d71a8b8507687 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 2 Jan 2022 02:30:00 +0100 Subject: chore: add Projects Beta GitHub Action --- .github/workflows/project.yml | 134 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 .github/workflows/project.yml diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml new file mode 100644 index 000000000..ba3e115c9 --- /dev/null +++ b/.github/workflows/project.yml @@ -0,0 +1,134 @@ +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 + steps: + - name: Generate token + id: generate_token + uses: tibdex/github-app-token@36464acb844fc53b9b8b2401da68844f6b05ebb0 + with: + app_id: ${{ secrets.OHMYZSH_BOT_APP_ID }} + private_key: ${{ secrets.OHMYZSH_BOT_APP_PEM }} + - name: Read project data + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + 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 <> $GITHUB_ENV + - name: Classify Pull Request + if: github.event_name == 'pull_request_target' + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + gh pr view ${{ github.event.pull_request.number }} --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' + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + 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 + -- cgit v1.2.3-70-g09d2 From 95a66532d17181693b828bda95f4261e5421b409 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 2 Jan 2022 03:09:52 +0100 Subject: chore: use GITHUB_TOKEN auth for Project Beta GitHub Action --- .github/workflows/project.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index ba3e115c9..2b3cc732f 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -10,15 +10,9 @@ jobs: name: Add to project runs-on: ubuntu-latest steps: - - name: Generate token - id: generate_token - uses: tibdex/github-app-token@36464acb844fc53b9b8b2401da68844f6b05ebb0 - with: - app_id: ${{ secrets.OHMYZSH_BOT_APP_ID }} - private_key: ${{ secrets.OHMYZSH_BOT_APP_PEM }} - name: Read project data env: - GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} ORGANIZATION: ohmyzsh PROJECT_NUMBER: "1" run: | @@ -45,9 +39,10 @@ jobs: 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: - GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} ISSUE_ID: ${{ github.event.issue.node_id }} PR_ID: ${{ github.event.pull_request.node_id }} run: | @@ -62,10 +57,11 @@ jobs: ' -f project=$PROJECT_ID -f item=${ISSUE_ID:-$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' env: - GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} run: | gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files.[].path' | awk -F/ ' /^plugins\// { @@ -92,10 +88,11 @@ jobs: 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' env: - GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} run: | gh api graphql -f query=' mutation ( -- cgit v1.2.3-70-g09d2 From 1d35b30461b2cc9a31330ff4e96cc5f97f76fb22 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 2 Jan 2022 03:17:40 +0100 Subject: chore: fix auth in Project tracking Action --- .github/workflows/project.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 2b3cc732f..c25fd2e22 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -16,6 +16,8 @@ jobs: ORGANIZATION: ohmyzsh PROJECT_NUMBER: "1" run: | + gh auth login --with-token ${{ env.GITHUB_TOKEN }} + # Get Project data gh api graphql -f query=' query($org: String!, $number: Int!) { -- cgit v1.2.3-70-g09d2 From 861e7e24a356ac571af2f362275ddfbac4be69ab Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 2 Jan 2022 03:19:46 +0100 Subject: chore: please work --- .github/workflows/project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index c25fd2e22..1e66efda8 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -16,7 +16,7 @@ jobs: ORGANIZATION: ohmyzsh PROJECT_NUMBER: "1" run: | - gh auth login --with-token ${{ env.GITHUB_TOKEN }} + gh auth login # Get Project data gh api graphql -f query=' -- cgit v1.2.3-70-g09d2 From 17c52ccfc9b06d45f041b24af35d1804d645620f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 2 Jan 2022 03:27:25 +0100 Subject: chore: look ma no auth! --- .github/workflows/project.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 1e66efda8..7559060d5 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -12,12 +12,9 @@ jobs: steps: - name: Read project data env: - GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} ORGANIZATION: ohmyzsh PROJECT_NUMBER: "1" run: | - gh auth login - # Get Project data gh api graphql -f query=' query($org: String!, $number: Int!) { @@ -44,7 +41,6 @@ jobs: - name: Add to project env: - GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} ISSUE_ID: ${{ github.event.issue.node_id }} PR_ID: ${{ github.event.pull_request.node_id }} run: | @@ -62,8 +58,6 @@ jobs: - name: Classify Pull Request if: github.event_name == 'pull_request_target' - env: - GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} run: | gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files.[].path' | awk -F/ ' /^plugins\// { @@ -93,8 +87,6 @@ jobs: - name: Fill Pull Request fields in project if: github.event_name == 'pull_request_target' - env: - GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} run: | gh api graphql -f query=' mutation ( -- cgit v1.2.3-70-g09d2 From dd7f0f22111bff8145c46f9638c0c95cbc143ce3 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 2 Jan 2022 03:32:07 +0100 Subject: chore: let's try again --- .github/workflows/project.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 7559060d5..0fe897587 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -12,11 +12,12 @@ jobs: steps: - name: Read project data env: + GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} ORGANIZATION: ohmyzsh PROJECT_NUMBER: "1" run: | # Get Project data - gh api graphql -f query=' + GITHUB_TOKEN=$GITHUB_TOKEN gh api graphql -f query=' query($org: String!, $number: Int!) { organization(login: $org){ projectNext(number: $number) { @@ -41,6 +42,7 @@ jobs: - name: Add to project env: + GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} ISSUE_ID: ${{ github.event.issue.node_id }} PR_ID: ${{ github.event.pull_request.node_id }} run: | @@ -58,6 +60,8 @@ jobs: - name: Classify Pull Request if: github.event_name == 'pull_request_target' + env: + GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} run: | gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files.[].path' | awk -F/ ' /^plugins\// { @@ -87,6 +91,8 @@ jobs: - name: Fill Pull Request fields in project if: github.event_name == 'pull_request_target' + env: + GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} run: | gh api graphql -f query=' mutation ( -- cgit v1.2.3-70-g09d2 From 121ee818a52b6c88fa4b7ae993ad15a27dc99038 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 2 Jan 2022 03:37:05 +0100 Subject: chore: I'm dumb af --- .github/workflows/project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 0fe897587..2b3cc732f 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -17,7 +17,7 @@ jobs: PROJECT_NUMBER: "1" run: | # Get Project data - GITHUB_TOKEN=$GITHUB_TOKEN gh api graphql -f query=' + gh api graphql -f query=' query($org: String!, $number: Int!) { organization(login: $org){ projectNext(number: $number) { -- cgit v1.2.3-70-g09d2 From 9dd1dc49d92da4641e83057099691a22ebd52bd8 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 3 Jan 2022 12:32:37 +0100 Subject: chore: simplify `GITHUB_TOKEN` env in project GitHub Action --- .github/workflows/project.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 2b3cc732f..6968e5ad4 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -9,10 +9,11 @@ jobs: add-to-project: name: Add to project runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} steps: - name: Read project data env: - GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} ORGANIZATION: ohmyzsh PROJECT_NUMBER: "1" run: | @@ -42,7 +43,6 @@ jobs: - name: Add to project env: - GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} ISSUE_ID: ${{ github.event.issue.node_id }} PR_ID: ${{ github.event.pull_request.node_id }} run: | @@ -60,8 +60,6 @@ jobs: - name: Classify Pull Request if: github.event_name == 'pull_request_target' - env: - GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} run: | gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files.[].path' | awk -F/ ' /^plugins\// { @@ -91,8 +89,6 @@ jobs: - name: Fill Pull Request fields in project if: github.event_name == 'pull_request_target' - env: - GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} run: | gh api graphql -f query=' mutation ( -- cgit v1.2.3-70-g09d2 From 512839ef7800fa32d78c47f160bdae3293ad22c1 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 3 Jan 2022 13:02:28 +0100 Subject: chore: simplify project GitHub Action --- .github/workflows/project.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 6968e5ad4..013255890 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -43,8 +43,7 @@ jobs: - name: Add to project env: - ISSUE_ID: ${{ github.event.issue.node_id }} - PR_ID: ${{ github.event.pull_request.node_id }} + 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!, $item: ID!) { @@ -54,7 +53,7 @@ jobs: } } } - ' -f project=$PROJECT_ID -f item=${ISSUE_ID:-$PR_ID} --jq '.data.addProjectNextItem.projectNextItem.id')" + ' -f project=$PROJECT_ID -f item=$ISSUE_OR_PR_ID --jq '.data.addProjectNextItem.projectNextItem.id')" echo "ITEM_ID=$item_id" >> $GITHUB_ENV -- cgit v1.2.3-70-g09d2 From 63345c4e5dd8ce210a43c9e89a883a262e755c69 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 3 Jan 2022 13:10:53 +0100 Subject: ci: disable GitHub Actions on forks --- .github/workflows/main.yml | 1 + .github/workflows/project.yml | 1 + 2 files changed, 2 insertions(+) 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 index 013255890..2a27b70fc 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -9,6 +9,7 @@ jobs: add-to-project: name: Add to project runs-on: ubuntu-latest + if: github.repository == 'ohmyzsh/ohmyzsh' env: GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }} steps: -- cgit v1.2.3-70-g09d2 From 596cef84c75261398fe66f713d97d5ca96130146 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 16 Dec 2021 10:07:35 +0100 Subject: style(svn-fast-info): fix code style and `svn info` locale --- plugins/svn-fast-info/svn-fast-info.plugin.zsh | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index f40a59685..f2f449f79 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 @@ -31,7 +31,7 @@ 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" } @@ -40,33 +40,33 @@ function svn_current_branch_name() { } 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 } -- cgit v1.2.3-70-g09d2 From ef3a85cd42c671217a0bcb58685484a5a5a0ada4 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 16 Dec 2021 10:08:25 +0100 Subject: fix(svn-fast-info): URL-decode svn branch name --- plugins/svn-fast-info/svn-fast-info.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index f2f449f79..05f0ac67d 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -36,7 +36,9 @@ function svn_repo_need_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() { -- cgit v1.2.3-70-g09d2 From 75ed59b7c09e3bb2d04a5d35065bdd9277e9947f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 16 Dec 2021 10:09:05 +0100 Subject: fix(svn-fast-info): quote % characters in svn branch name --- plugins/svn-fast-info/svn-fast-info.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index 05f0ac67d..46dd5cb0c 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -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)" \ -- cgit v1.2.3-70-g09d2 From c76dc91e02f7e8885e6eb71d725c21b15616ad05 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 20 Dec 2021 11:22:54 +0100 Subject: fix(svn): return true repo name in `svn_get_repo_name` --- plugins/svn/svn.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index fbc9ee538..851f1a45e 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -19,10 +19,10 @@ in_svn() { } 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() { -- cgit v1.2.3-70-g09d2 From 93ec48fb0a798775b9e5d366c11a4ac3826c3ea4 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 20 Dec 2021 11:24:00 +0100 Subject: fix(svn): refactor and quote % characters in `svn_prompt_info` --- plugins/svn/svn.plugin.zsh | 104 +++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 851f1a45e..9c3b50d16 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -1,21 +1,28 @@ 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() { @@ -26,47 +33,44 @@ svn_get_repo_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 $1 + else + # Otherwise, no lines were found, or an error occurred. Return clean. + echo $2 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 } -- cgit v1.2.3-70-g09d2 From 304af0a577336abd3090f9dec645052c4c987a47 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 15 Dec 2021 13:03:16 +0100 Subject: fix(lib): quote % in `git_remote_status` --- lib/git.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3-70-g09d2 From 5b076eab9bf8b85b48faac20383aa20ba0f8b740 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 26 Dec 2021 19:31:07 +0100 Subject: fix(lib): quote % in `nvm_prompt_info` --- lib/nvm.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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}" } -- cgit v1.2.3-70-g09d2 From 42afa6e2ea663431ae2ff0a4aae8e57ce175eb4a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 26 Dec 2021 19:32:52 +0100 Subject: fix(pyenv): quote % in `pyenv_prompt_info` --- plugins/pyenv/pyenv.plugin.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 -- cgit v1.2.3-70-g09d2 From e7390a860374fb38dd7bf67242ec12e8a6925a80 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 26 Dec 2021 19:34:30 +0100 Subject: fix(jenv): quote % in `jenv_prompt_info` --- plugins/jenv/jenv.plugin.zsh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 -- cgit v1.2.3-70-g09d2 From 3e9fe6e7720cf431d5c24a4037cfb5e8b212a6aa Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 26 Dec 2021 20:43:54 +0100 Subject: fix(virtualenv): quote % in `virtualenv_prompt_info` --- plugins/virtualenv/virtualenv.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3-70-g09d2 From 9836aebe672159622193f14a89eedc38ccd29a5d Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 14 Dec 2021 11:58:58 +0100 Subject: fix(agnoster): quote % in prompt functions --- themes/agnoster.zsh-theme | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index fe7ddbac6..5f4efe813 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 } @@ -237,8 +236,8 @@ prompt_status() { 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 } -- cgit v1.2.3-70-g09d2 From 4e777ef9d62f70ec971a3eaca71a23b9f4c93a54 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 27 Dec 2021 00:33:20 +0100 Subject: fix(trapd00r): fix potential command injection in `zsh_path` --- themes/trapd00r.zsh-theme | 2 ++ 1 file changed, 2 insertions(+) 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) -- cgit v1.2.3-70-g09d2 From 43be5ea32150912ae2e85e2cc278c092022ea53f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 27 Dec 2021 00:38:58 +0100 Subject: fix(bureau): quote % in git prompt function and remove global variables --- themes/bureau.zsh-theme | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 3b3bdc80f..7a253a688 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -17,13 +17,14 @@ ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}" bureau_git_branch () { + 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 _STATUS _INDEX # check status of files _INDEX=$(command git status --porcelain 2> /dev/null) @@ -63,18 +64,22 @@ bureau_git_status() { echo $_STATUS } -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() { + local branch=$(bureau_git_branch) + local status=$(bureau_git_status) + local info + + if [[ -z "${branch}" ]]; then + return + fi + + info="${branch:gs/%/%%}" + + if [[ -n "${status}" ]]; then + info+=" $status" fi - echo $_result + + echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}" } -- cgit v1.2.3-70-g09d2 From a9d57eb2eec4d6234c4714a430ddfb4c57443570 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 27 Dec 2021 15:01:25 +0100 Subject: fix: quote % in `box_name` prompt functions --- themes/candy-kingdom.zsh-theme | 4 +++- themes/fino-time.zsh-theme | 5 +++-- themes/fino.zsh-theme | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) 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: Date: Mon, 3 Jan 2022 13:58:14 +0100 Subject: fix(aws): quote % in `aws_prompt_info` --- plugins/aws/aws.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 3a3a111b4..c18bd634b 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -155,8 +155,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:=}" + [[ -n "$AWS_PROFILE" ]] || return + echo "${ZSH_THEME_AWS_PREFIX:=}" } if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then -- cgit v1.2.3-70-g09d2 From a280726d934878a31f6dae35d8677a53551bbcf5 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 3 Jan 2022 14:00:54 +0100 Subject: fix(fossil): refactor `fossil_prompt_info` and quote % in branch --- plugins/fossil/fossil.plugin.zsh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) 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 () { -- cgit v1.2.3-70-g09d2 From d87ab251c7fe18626b2d0c4e4a184e7bed7c508b Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 3 Jan 2022 14:03:36 +0100 Subject: fix(kubectx): quote % in `kubectx_prompt_info` --- plugins/kubectx/kubectx.plugin.zsh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh index abbdc254b..af9a17ef1 100644 --- a/plugins/kubectx/kubectx.plugin.zsh +++ b/plugins/kubectx/kubectx.plugin.zsh @@ -1,9 +1,11 @@ typeset -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) + + # use value in associative array if it exists + # otherwise fall back to the context name + echo "${${kubectx_mapping[$current_ctx]:-$current_ctx}:gs/%/%%}" } -- cgit v1.2.3-70-g09d2 From 8e973d42bd3bc5028d88ce731113b03ac8a5590c Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 3 Jan 2022 17:05:48 +0100 Subject: fix(bureau): fix `status` variable name causing error (#10561) Also cleaned up the code a bit Fixes #10561 --- themes/bureau.zsh-theme | 53 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 7a253a688..50058e213 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -24,59 +24,58 @@ bureau_git_branch () { } bureau_git_status() { - local _STATUS _INDEX + local result gitstatus # 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" + gitstatus=$(command git status --porcelain -b 2> /dev/null) + if [[ -n "$gitstatus" ]]; then + if $(echo "$gitstatus" | command grep -q '^[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 $(echo "$gitstatus" | command grep -q '^.[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 $(echo "$gitstatus" | command grep -q -E '^\?\? '); then + result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED" fi - if $(echo "$_INDEX" | command grep -q '^UU '); then - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED" + if $(echo "$gitstatus" | command grep -q '^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" + if $(echo "$gitstatus" | command grep -q '^## .*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 $(echo "$gitstatus" | command grep -q '^## .*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 $(echo "$gitstatus" | command grep -q '^## .*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" + 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 gitbranch=$(bureau_git_branch) + local gitstatus=$(bureau_git_status) local info - if [[ -z "${branch}" ]]; then + if [[ -z "$gitbranch" ]]; then return fi - info="${branch:gs/%/%%}" + info="${gitbranch:gs/%/%%}" - if [[ -n "${status}" ]]; then - info+=" $status" + if [[ -n "$gitstatus" ]]; then + info+=" $gitstatus" fi echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}" -- cgit v1.2.3-70-g09d2 From a7c46d0ebdbeb23d751a61be8f9b64935572f720 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 3 Jan 2022 17:09:59 +0100 Subject: fix(ubuntu): fix `defining function based on alias` error (#10560) Fixes #10560 --- plugins/ubuntu/ubuntu.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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'" -- cgit v1.2.3-70-g09d2 From 31d63ea884e8ef56a40bed8771cdd8d3aec131f9 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 4 Jan 2022 11:38:53 +0100 Subject: fix(kubectx): allow prompt sequences in `kubectx_mapping` (#10562) Fixes #10562 --- plugins/kubectx/kubectx.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/kubectx/kubectx.plugin.zsh b/plugins/kubectx/kubectx.plugin.zsh index af9a17ef1..1419f102f 100644 --- a/plugins/kubectx/kubectx.plugin.zsh +++ b/plugins/kubectx/kubectx.plugin.zsh @@ -1,4 +1,4 @@ -typeset -A kubectx_mapping +typeset -g -A kubectx_mapping function kubectx_prompt_info() { (( $+commands[kubectl] )) || return @@ -7,5 +7,5 @@ function kubectx_prompt_info() { # use value in associative array if it exists # otherwise fall back to the context name - echo "${${kubectx_mapping[$current_ctx]:-$current_ctx}:gs/%/%%}" + echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}" } -- cgit v1.2.3-70-g09d2 From d3bb52d7d825f2a6ce2e1c76ca472b05c6f27b40 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 5 Jan 2022 09:10:32 +0100 Subject: style: declare globals properly By default, `typeset` defines variables locally unless in the main scope. This is specially bad when using `omz plugin load`, which happens inside a function, so the declared variables don't continue being defined when the function finishes and the main scope reappears. --- plugins/colored-man-pages/colored-man-pages.plugin.zsh | 2 +- plugins/deno/deno.plugin.zsh | 2 +- plugins/fnm/fnm.plugin.zsh | 2 +- plugins/gh/gh.plugin.zsh | 2 +- plugins/helm/helm.plugin.zsh | 2 +- plugins/rbw/rbw.plugin.zsh | 2 +- plugins/rust/rust.plugin.zsh | 4 ++-- plugins/rvm/rvm.plugin.zsh | 2 +- plugins/volta/volta.plugin.zsh | 2 +- themes/dieter.zsh-theme | 2 +- themes/jonathan.zsh-theme | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) 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/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/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/helm/helm.plugin.zsh b/plugins/helm/helm.plugin.zsh index 472c1c9dd..c6b91693a 100644 --- a/plugins/helm/helm.plugin.zsh +++ b/plugins/helm/helm.plugin.zsh @@ -14,7 +14,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 `helm`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _helm _comps[helm]=_helm fi diff --git a/plugins/rbw/rbw.plugin.zsh b/plugins/rbw/rbw.plugin.zsh index 3825be7a6..56683ad06 100644 --- a/plugins/rbw/rbw.plugin.zsh +++ b/plugins/rbw/rbw.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 `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 diff --git a/plugins/rust/rust.plugin.zsh b/plugins/rust/rust.plugin.zsh index 014c73b3b..465b701b0 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 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/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/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/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]%}" -- cgit v1.2.3-70-g09d2 From 7ae4f76f6dda1521505c57880ea1e5ee2f1aa183 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 5 Jan 2022 09:03:30 +0100 Subject: refactor(kubectl): optimize completion generation --- plugins/kubectl/kubectl.plugin.zsh | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 3630facaa..bf602bb7b 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 doesn't exist yet, we need to autoload it and + # bind it to `kubectl`. Otherwise, compinit will have already done that. + if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubectl" ]]; then + typeset -g -A _comps + autoload -Uz _kubectl + _comps[kubectl]=_kubectl + fi + + kubectl completion zsh >! "$ZSH_CACHE_DIR/completions/_kubectl" &| fi # This command is used a LOT both below and in daily life @@ -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 -- cgit v1.2.3-70-g09d2 From 67cc59b4258a13232cddfddd75f44d8ca2b80172 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 5 Jan 2022 09:23:27 +0100 Subject: style: some code style fixes --- plugins/frontend-search/frontend-search.plugin.zsh | 32 +++++++------- plugins/pj/pj.plugin.zsh | 51 ++++++++++------------ 2 files changed, 39 insertions(+), 44 deletions(-) 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/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 -- cgit v1.2.3-70-g09d2 From 4e2f4cdf686fe560cec3ec7072628c4d0f723929 Mon Sep 17 00:00:00 2001 From: Sang-Yun Oh Date: Sat, 8 Jan 2022 01:34:42 +0900 Subject: docs(vi-mode): fix link typo in readme (#10570) --- plugins/vi-mode/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- cgit v1.2.3-70-g09d2 From 71e6d5fde87be76205e87eed2e1a306a2f3bc5a8 Mon Sep 17 00:00:00 2001 From: Fabian Günter Date: Sat, 8 Jan 2022 19:59:59 +0100 Subject: fix(svn): fix output order in `svn_dirty_choose` (#10572) --- plugins/svn/svn.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 9c3b50d16..e55e5b2dd 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -67,10 +67,10 @@ svn_dirty_choose() { 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 $1 + echo $2 else # Otherwise, no lines were found, or an error occurred. Return clean. - echo $2 + echo $3 fi } -- cgit v1.2.3-70-g09d2 From c6e7f8905fb61b927f12f43fb57f8c514cd48a67 Mon Sep 17 00:00:00 2001 From: Joey Territo <54502648+jtt9340@users.noreply.github.com> Date: Sat, 8 Jan 2022 14:03:32 -0500 Subject: fix(rust): fix `cargo` completion when sysroot contains spaces (#10571) When generating completions for Cargo, if the Rust sysroot (i.e. `rustc +${${(z)$(rustup default)}[1]} --print sysroot`) contains spaces, Cargo completions will not work because the spaces are not escaped, thus passing two arguments to the "source" command instead of one. The spaces need to be escaped for this to work. --- plugins/rust/rust.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/rust/rust.plugin.zsh b/plugins/rust/rust.plugin.zsh index 465b701b0..db6ca9e74 100644 --- a/plugins/rust/rust.plugin.zsh +++ b/plugins/rust/rust.plugin.zsh @@ -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 -- cgit v1.2.3-70-g09d2 From a92ee838f3e6b1a8dba548673555ebd514939324 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 9 Jan 2022 20:27:22 +0100 Subject: fix(cli): follow symlinks in plugin or theme completions --- lib/cli.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 8cf8368e6..0a85402df 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -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 -- cgit v1.2.3-70-g09d2 From fbdc078fa60c2c34a7f5078846902538d162fbee Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 9 Jan 2022 23:06:34 +0100 Subject: style: use 24bit colors in Oh My Zsh logo if supported --- tools/install.sh | 62 ++++++++++++++++++++++++++++++++++++++++++-------------- tools/upgrade.sh | 48 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 86 insertions(+), 24 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 731d89a29..5009bd586 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -127,6 +127,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 @@ -155,7 +173,28 @@ fmt_error() { setup_color() { # Only use colors if connected to a terminal - if is_tty; then + if ! is_tty; then + RAINBOW="" + RED="" + GREEN="" + YELLOW="" + BLUE="" + BOLD="" + RESET="" + return + fi + + 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') @@ -165,21 +204,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 + + RED=$(printf '\033[31m') + GREEN=$(printf '\033[32m') + YELLOW=$(printf '\033[33m') + BLUE=$(printf '\033[34m') + BOLD=$(printf '\033[1m') + RESET=$(printf '\033[0m') } setup_ohmyzsh() { diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 994ffe9c9..25381de7e 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') -- cgit v1.2.3-70-g09d2 From 0ca2e48ee8449439a6e0a4ca0652a4ec07031ad3 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 10 Jan 2022 17:22:31 +0100 Subject: ci(project): fix `gh pr view` call to use ohmyzsh repository --- .github/workflows/project.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index 2a27b70fc..bb1063acb 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -47,21 +47,23 @@ jobs: 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!, $item: ID!) { - addProjectNextItem(input: {projectId: $project, contentId: $item}) { + mutation($project: ID!, $content: ID!) { + addProjectNextItem(input: {projectId: $project, contentId: $content}) { projectNextItem { id } } } - ' -f project=$PROJECT_ID -f item=$ISSUE_OR_PR_ID --jq '.data.addProjectNextItem.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: | - gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files.[].path' | awk -F/ ' + gh pr view ${{ github.event.pull_request.number }} \ + --repo ${{ github.repository }} \ + --json files --jq '.files.[].path' | awk -F/ ' /^plugins\// { plugins[$2] = 1 } -- cgit v1.2.3-70-g09d2 From 971683762e3aba543b0dc787e8a5ee1c16b5ace7 Mon Sep 17 00:00:00 2001 From: WeZZard <960509+WeZZard@users.noreply.github.com> Date: Tue, 11 Jan 2022 01:38:35 +0800 Subject: fix(avit): disable `log.showSignatures` in `_git_time_since_commit` (#10072) --- themes/avit.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index 1e20d8f9f..d117c4e94 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.showSignatures=false log --format='%at' -1 2>/dev/null); then now=$(date +%s) seconds_since_last_commit=$((now-last_commit)) -- cgit v1.2.3-70-g09d2 From 9c84c344d762b200de7acc794b9a0e7832144e7a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 10 Jan 2022 19:39:05 +0100 Subject: fix: disable `log.showSignature` in `git log` calls --- plugins/git/git.plugin.zsh | 4 +--- themes/Soliah.zsh-theme | 4 +--- themes/avit.zsh-theme | 2 +- themes/dogenpunk.zsh-theme | 4 +--- themes/smt.zsh-theme | 2 +- themes/wedisagree.zsh-theme | 4 +--- tools/changelog.sh | 2 +- 7 files changed, 7 insertions(+), 15 deletions(-) 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/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/avit.zsh-theme b/themes/avit.zsh-theme index d117c4e94..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=$(command git -c log.showSignatures=false log --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/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/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/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/tools/changelog.sh b/tools/changelog.sh index 664f34608..86774a7ea 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -414,7 +414,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)"}) -- cgit v1.2.3-70-g09d2 From b7a59e6d5c1a699b972a780b4a4eb4ffd89f22b3 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Jan 2022 16:18:00 +0100 Subject: fix(installer): run `chsh` with sudo if user has privileges This fixes the error in Google Cloud Shell, where a password prompt appears when running `chsh` but the user (hello) does not have a password. If ran with `sudo`, the `chsh` command happens without a password prompt. --- tools/install.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 5009bd586..d3be1ace4 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -317,7 +317,7 @@ EOF "$YELLOW" "$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 @@ -355,11 +355,20 @@ 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 - # Actually change the default shell to zsh - if ! chsh -s "$zsh"; then + echo "Changing your shell to $zsh..." + + # Check if user has sudo privileges and run `chsh` or `sudo chsh` + if LANG= sudo -l -U "$USER" 2>/dev/null | grep -q "is not allowed to run"; then + chsh -s "$zsh" "$USER" # run chsh normally + else + sudo -k chsh -s "$zsh" "$USER" # -k forces the password prompt + fi + + # 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" -- cgit v1.2.3-70-g09d2 From a0a949de56f7bc63403c521bfb1d7426843ec5b7 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Jan 2022 18:56:18 +0100 Subject: fix(installer): fix `sudo` check for users with password or without privileges The previous check only worked if the user could run `sudo` without typing the password, which is almost none (I checked in Google Cloud Shell so I failed to notice this). This new check works whether the user has no sudo privileges, or if it has, whether they have to type in the password or not. It should really be easier to check if the user doesn't have privilege without having to make them type the password. --- tools/install.sh | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index d3be1ace4..b7498fa64 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -56,6 +56,28 @@ command_exists() { command -v "$@" >/dev/null 2>&1 } +user_can_sudo() { + # 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 may not run sudo on + # + # 2. Pass `-S` to `sudo` to tell it to get the password from stdin + # instead of from a tty, and pipe `true` to `sudo`, since it doesn't + # output anything. This will make sudo exit with error code 1 and print + # the message: + # sudo: no password was provided + # + # 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. + # + true | LANG= sudo -v -S 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 @@ -360,8 +382,16 @@ EOF echo "Changing your shell to $zsh..." - # Check if user has sudo privileges and run `chsh` or `sudo chsh` - if LANG= sudo -l -U "$USER" 2>/dev/null | grep -q "is not allowed to run"; then + # 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 chsh -s "$zsh" "$USER" # run chsh normally else sudo -k chsh -s "$zsh" "$USER" # -k forces the password prompt -- cgit v1.2.3-70-g09d2 From c63ba17525b0b4344729762253c9d9e1c0823d49 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Jan 2022 19:53:50 +0100 Subject: refactor(installer): simplify `user_can_sudo` check --- tools/install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index b7498fa64..d3f1ee640 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -64,18 +64,18 @@ user_can_sudo() { # • without privilege: exits with error code 1 and prints the message: # Sorry, user may not run sudo on # - # 2. Pass `-S` to `sudo` to tell it to get the password from stdin - # instead of from a tty, and pipe `true` to `sudo`, since it doesn't - # output anything. This will make sudo exit with error code 1 and print - # the message: - # sudo: no password was provided + # 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. # - true | LANG= sudo -v -S 2>&1 | grep -q "may not run sudo" + 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 -- cgit v1.2.3-70-g09d2 From b4819557618bbf8452c612f614ad824d243bb376 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 11 Jan 2022 23:40:33 +0100 Subject: ci(project): fix .list files not found error --- .github/workflows/project.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index bb1063acb..800761554 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -61,6 +61,8 @@ jobs: - 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/ ' -- cgit v1.2.3-70-g09d2 From 93cea53618ebd3f108275c88c948f790492337b4 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 12 Jan 2022 12:19:34 +0100 Subject: fix(yarn): update completion (#10579) Fixes #10578 --- plugins/yarn/_yarn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) -- cgit v1.2.3-70-g09d2 From bddecfed58058910f0aeb78d9010f4f8f6d83692 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 13 Jan 2022 12:34:10 +0100 Subject: style(updater): remove statl from `git pull` --- tools/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 25381de7e..55412062a 100755 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -194,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 git pull --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." -- cgit v1.2.3-70-g09d2 From aaebe4c890394cb5d345c949aecb77aaf30b9c56 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 13 Jan 2022 14:29:12 +0100 Subject: fix(mvn): fix listing modules in completion (#10586) --- plugins/mvn/mvn.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3-70-g09d2 From 805427e06bc0549c7b9a4f50d3e39bbf68043f16 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 13 Jan 2022 17:28:15 +0100 Subject: fix(updater): give priority to `zstyle` settings if set (#10587) Fixes #10587 --- tools/check_for_upgrade.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 293f48edf..729d8ecb5 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. -- cgit v1.2.3-70-g09d2 From 035c856c2cbbad2b45252ec8c065c3a9e7eefa65 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 13 Jan 2022 17:46:09 +0100 Subject: fix: get branch name first in `omz version` and changelog --- lib/cli.zsh | 7 ++++--- tools/changelog.sh | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 0a85402df..ec59d1d44 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -791,12 +791,13 @@ function _omz::version { # 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~ or branch~) 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="" # Get short hash for the current HEAD local commit=$(command git rev-parse --short HEAD 2>/dev/null) diff --git a/tools/changelog.sh b/tools/changelog.sh index 86774a7ea..49532a4a4 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -395,12 +395,12 @@ function main { # 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 -- cgit v1.2.3-70-g09d2 From 1e277553bcc9f23a904bf728013df6ebfe339e74 Mon Sep 17 00:00:00 2001 From: Mykola Krachkovsky Date: Fri, 14 Jan 2022 16:28:39 +0200 Subject: fix(svn): fix sed call in `svn_get_rev_nr` (#10590) --- plugins/svn/svn.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index e55e5b2dd..22b07b4ec 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -55,7 +55,7 @@ svn_get_branch_name() { } svn_get_rev_nr() { - sed -n 's/Revision:\ //p' "${1:-$(LANG= svn info 2>/dev/null)}" + sed -n 's/Revision:\ //p' <<<"${1:-$(LANG= svn info 2>/dev/null)}" } svn_dirty() { -- cgit v1.2.3-70-g09d2 From 567bd593954641bd59376f6fd5f9c06bf37bc9e7 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 17 Jan 2022 13:18:10 +0100 Subject: refactor(cli): use self-referencing in subcommand functions --- lib/cli.zsh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index ec59d1d44..70076bcfb 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -182,7 +182,7 @@ function _omz::changelog { ! command git rev-parse --verify "${version}^{commit}" ) &>/dev/null; then cat >&2 < must be a valid branch, tag or commit. EOF @@ -193,9 +193,9 @@ EOF } function _omz::plugin { - (( $# > 0 && $+functions[_omz::plugin::$1] )) || { + (( $# > 0 && $+functions[$0::$1] )) || { cat >&2 < [options] +Usage: ${(j: :)${(s.::.)0#_}} [options] Available commands: @@ -212,12 +212,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 [...]" + echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} [...]" return 1 fi @@ -307,7 +307,7 @@ multi == 1 && length(\$0) > 0 { function _omz::plugin::enable { if [[ -z "$1" ]]; then - echo >&2 "Usage: omz plugin enable [...]" + echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} [...]" return 1 fi @@ -383,7 +383,7 @@ multi == 1 && /^[^#]*\)/ { function _omz::plugin::info { if [[ -z "$1" ]]; then - echo >&2 "Usage: omz plugin info " + echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} " return 1 fi @@ -430,7 +430,7 @@ function _omz::plugin::list { function _omz::plugin::load { if [[ -z "$1" ]]; then - echo >&2 "Usage: omz plugin load [...]" + echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} [...]" return 1 fi @@ -477,9 +477,9 @@ function _omz::plugin::load { } function _omz::pr { - (( $# > 0 && $+functions[_omz::pr::$1] )) || { + (( $# > 0 && $+functions[$0::$1] )) || { cat >&2 < [options] +Usage: ${(j: :)${(s.::.)0#_}} [options] Available commands: @@ -493,7 +493,7 @@ EOF local command="$1" shift - _omz::pr::$command "$@" + $0::$command "$@" } function _omz::pr::clean { @@ -534,7 +534,7 @@ function _omz::pr::test { # Check the input if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then - echo >&2 "Usage: omz pr test " + echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} " return 1 fi @@ -619,9 +619,9 @@ function _omz::reload { } function _omz::theme { - (( $# > 0 && $+functions[_omz::theme::$1] )) || { + (( $# > 0 && $+functions[$0::$1] )) || { cat >&2 < [options] +Usage: ${(j: :)${(s.::.)0#_}} [options] Available commands: @@ -636,7 +636,7 @@ EOF local command="$1" shift - _omz::theme::$command "$@" + $0::$command "$@" } function _omz::theme::list { @@ -671,7 +671,7 @@ function _omz::theme::list { function _omz::theme::set { if [[ -z "$1" ]]; then - echo >&2 "Usage: omz theme set " + echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} " return 1 fi @@ -739,7 +739,7 @@ EOF function _omz::theme::use { if [[ -z "$1" ]]; then - echo >&2 "Usage: omz theme use " + echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} " return 1 fi -- cgit v1.2.3-70-g09d2 From dfaad779a9bbe1f83e30820d227d4b7870bdf33f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 17 Jan 2022 12:45:59 +0100 Subject: fix(helm): fix completion loading mechanism --- plugins/helm/helm.plugin.zsh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/helm/helm.plugin.zsh b/plugins/helm/helm.plugin.zsh index c6b91693a..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 - typeset -g -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" &| -- cgit v1.2.3-70-g09d2 From 4f2d8b4d4cbc51e609f4b568e87907883422ab41 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 17 Jan 2022 12:46:20 +0100 Subject: fix(kubectl): source completion instead of autoloading it --- plugins/kubectl/kubectl.plugin.zsh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index bf602bb7b..6edb59751 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -8,15 +8,15 @@ if (( $+commands[kubectl] )); then 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 `kubectl`. 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/_kubectl" ]]; then - typeset -g -A _comps - autoload -Uz _kubectl - _comps[kubectl]=_kubectl + 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 - - kubectl completion zsh >! "$ZSH_CACHE_DIR/completions/_kubectl" &| fi # This command is used a LOT both below and in daily life -- cgit v1.2.3-70-g09d2 From 540b2200afb68a3282419ffb6c49bbf8f642b67e Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Tue, 18 Jan 2022 18:46:14 +0100 Subject: feat(sudo): respect `$SUDO_EDITOR` and `$VISUAL`, switch to `sudo -e` (#10596) --- plugins/sudo/README.md | 16 ++++++++++++++++ plugins/sudo/sudo.plugin.zsh | 15 ++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) 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 esc 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 esc 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 EscEsc as the trigger. diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index e02f88a87..e8d183414 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,6 +11,7 @@ # * Dongweiming # * Subhaditya Nath # * Marc Cornellà +# * Carlo Sala # # ------------------------------------------------------------------------------ @@ -35,10 +36,14 @@ sudo-command-line() { LBUFFER="${LBUFFER:1}" fi + # 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 - sudoedit\ *) __sudo-replace-buffer "sudoedit" "" ;; + sudo\ -e\ *) __sudo-replace-buffer "sudo -e" "" ;; sudo\ *) __sudo-replace-buffer "sudo" "" ;; *) LBUFFER="sudo $LBUFFER" ;; esac @@ -72,9 +77,9 @@ sudo-command-line() { # 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 -- cgit v1.2.3-70-g09d2 From 957dca698cd0a0cafc6d2551eeff19fe223f41bd Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 18 Jan 2022 19:03:27 +0100 Subject: style(sudo): clean code style and reorganise logic --- plugins/sudo/sudo.plugin.zsh | 50 +++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index e8d183414..2a0b3bfc4 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -17,9 +17,13 @@ __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 @@ -36,18 +40,21 @@ sudo-command-line() { LBUFFER="${LBUFFER:1}" fi - # If $SUDO_EDITOR or $VISUAL are defined, then use that as $EDITOR - # Else use the default $EDITOR - local EDITOR=${SUDO_EDITOR:-${VISUAL:-$EDITOR}} + { + # 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 - # 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 - else # Check if the typed command is really an alias to $EDITOR # Get the first part of the typed command @@ -72,7 +79,8 @@ 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 @@ -83,13 +91,13 @@ sudo-command-line() { 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 -- cgit v1.2.3-70-g09d2 From cddf1b69820c9fe3d33a0f00ac6eab37b9d67377 Mon Sep 17 00:00:00 2001 From: Marco Franssen Date: Tue, 18 Jan 2022 20:57:07 +0100 Subject: feat(fig): add plugin for Fig (#10432) --- plugins/fig/README.md | 9 +++++++++ plugins/fig/fig.plugin.zsh | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 plugins/fig/README.md create mode 100644 plugins/fig/fig.plugin.zsh 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..60678bfda --- /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 completions zsh >| "$ZSH_CACHE_DIR/completions/_fig" &| -- cgit v1.2.3-70-g09d2 From 22c11da108764336d92d03d3113c1f486cdb5911 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 18 Jan 2022 21:26:45 +0100 Subject: fix(fig): fix typo in completion command --- plugins/fig/fig.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fig/fig.plugin.zsh b/plugins/fig/fig.plugin.zsh index 60678bfda..cddb6c7c0 100644 --- a/plugins/fig/fig.plugin.zsh +++ b/plugins/fig/fig.plugin.zsh @@ -10,4 +10,4 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_fig" ]]; then _comps[fig]=_fig fi -fig completions zsh >| "$ZSH_CACHE_DIR/completions/_fig" &| +fig completion zsh >| "$ZSH_CACHE_DIR/completions/_fig" &| -- cgit v1.2.3-70-g09d2 From fe9d87d6dc2f3e6194862799b0707f97844e83ac Mon Sep 17 00:00:00 2001 From: Mike Mattice Date: Wed, 19 Jan 2022 08:58:34 -0600 Subject: feat(aws): accept aws mfa tokencode on `acp` cli call (#10130) Co-authored-by: Mike Mattice --- plugins/aws/README.md | 8 ++++---- plugins/aws/aws.plugin.zsh | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) 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 [] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection. -* `acp []`: in addition to `asp` functionality, it actually changes the profile by - assuming the role specified in the `` configuration. It supports MFA and sets - `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It - requires the roles to be configured as per the +* `acp [] []`: in addition to `asp` functionality, it actually changes + the profile by assuming the role specified in the `` configuration. It supports + MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if + obtained. It requires the roles to be configured as per the [official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html). Run `acp` without arguments to clear the profile. diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index c18bd634b..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 -- cgit v1.2.3-70-g09d2 From 00d0735704d8e1070a51bbd1334db32d2e822fe6 Mon Sep 17 00:00:00 2001 From: kronion Date: Wed, 19 Jan 2022 09:49:24 -0600 Subject: feat(poetry): add plugin to provide completion for Poetry (#10595) --- plugins/poetry/README.md | 9 +++++++++ plugins/poetry/poetry.plugin.zsh | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 plugins/poetry/README.md create mode 100644 plugins/poetry/poetry.plugin.zsh 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..e872e9fd6 --- /dev/null +++ b/plugins/poetry/poetry.plugin.zsh @@ -0,0 +1,16 @@ +# 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[gh]=_poetry +fi + +poetry completions zsh >| "$ZSH_CACHE_DIR/completions/_poetry" &| + +unset comp_file -- cgit v1.2.3-70-g09d2 From 0b08b70b0cc7ff286ea942f0e20a41f10bef0ee8 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Jan 2022 17:15:16 +0100 Subject: chore(poetry): fix copy-paste error --- plugins/poetry/poetry.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/poetry/poetry.plugin.zsh b/plugins/poetry/poetry.plugin.zsh index e872e9fd6..3cb7845d6 100644 --- a/plugins/poetry/poetry.plugin.zsh +++ b/plugins/poetry/poetry.plugin.zsh @@ -8,7 +8,7 @@ fi if [[ ! -f "$ZSH_CACHE_DIR/completions/_poetry" ]]; then typeset -g -A _comps autoload -Uz _poetry - _comps[gh]=_poetry + _comps[poetry]=_poetry fi poetry completions zsh >| "$ZSH_CACHE_DIR/completions/_poetry" &| -- cgit v1.2.3-70-g09d2 From a7efd96a60157965370e1dbc4c7fce66b7a64225 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Jan 2022 19:27:53 +0100 Subject: fix(dotenv): match for exact directory path in allowed/disallowed files --- plugins/dotenv/dotenv.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 40ec5c46f..394455ae1 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 -- cgit v1.2.3-70-g09d2 From 675a2d9922ffc1f2cf88dd3d871f22136b7e525c Mon Sep 17 00:00:00 2001 From: Billy Mathews Date: Wed, 17 Jan 2018 00:08:38 +0000 Subject: feat(tmux): add `tmuxconf` alias to edit .tmux.conf (#6555) Closes #6555 --- plugins/tmux/README.md | 21 +++++++++++---------- plugins/tmux/tmux.plugin.zsh | 1 + 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index 551814a39..bc192a40c 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 ~/.tmux.conf` | 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..9d333257e 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -11,6 +11,7 @@ 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 ~/.tmux.conf' # CONFIGURATION VARIABLES # Automatically start tmux -- cgit v1.2.3-70-g09d2 From 2b492aec93487e8e25cf03df4540aa73dbf5fc9e Mon Sep 17 00:00:00 2001 From: kronion Date: Fri, 21 Jan 2022 12:52:24 -0600 Subject: chore(poetry): remove unnecessary unset (#10605) --- plugins/poetry/poetry.plugin.zsh | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/poetry/poetry.plugin.zsh b/plugins/poetry/poetry.plugin.zsh index 3cb7845d6..cebcb46c4 100644 --- a/plugins/poetry/poetry.plugin.zsh +++ b/plugins/poetry/poetry.plugin.zsh @@ -12,5 +12,3 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_poetry" ]]; then fi poetry completions zsh >| "$ZSH_CACHE_DIR/completions/_poetry" &| - -unset comp_file -- cgit v1.2.3-70-g09d2 From 4e0f19cf923163104d86308d2366d37da35c0622 Mon Sep 17 00:00:00 2001 From: "GitHubLeakedPAN, GitHubLeakedMyautsai" Date: Sun, 23 Jan 2022 04:56:36 +0800 Subject: feat(ys): show `svn` repository information (#10582) --- themes/ys.zsh-theme | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme index 45bbae2d1..5ef500e14 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() { @@ -66,6 +73,7 @@ PROMPT=" %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\ ${hg_info}\ ${git_info}\ +${svn_info}\ ${venv_info}\ \ [%*] $exit_code -- cgit v1.2.3-70-g09d2 From 84931adcd465e9a3b5e38f3b416a1df2acc33801 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 21 Jan 2022 19:03:35 +0100 Subject: fix: do not call chpwd hooks in subshells --- lib/cli.zsh | 10 +++++----- tools/check_for_upgrade.sh | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 70076bcfb..2f3f293da 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)' @@ -176,7 +176,7 @@ 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}" @@ -761,7 +761,7 @@ 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 @@ -777,7 +777,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,7 +787,7 @@ function _omz::update { function _omz::version { ( - cd "$ZSH" + builtin cd -q "$ZSH" # Get the version name: # 1) try tag-like version diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 729d8ecb5..3f6d35c3e 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -36,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 @@ -58,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) @@ -136,7 +136,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 -- cgit v1.2.3-70-g09d2 From d4f5fa37e8be25e1b4f281fcf5b90cf700dc3c95 Mon Sep 17 00:00:00 2001 From: Mathias Neerup Date: Thu, 31 Mar 2016 14:51:47 +0200 Subject: feat(simple): add color to git status indicator (#4962) Closes #4962 --- themes/simple.zsh-theme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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]%}✔" -- cgit v1.2.3-70-g09d2 From 3f5402e2687475d83ec98613dc93373620e5ce57 Mon Sep 17 00:00:00 2001 From: Ricky Medina Date: Mon, 24 Jan 2022 09:21:34 -0500 Subject: feat(1password): add plugin for 1password (#8884) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/1password/1password.plugin.zsh | 46 ++++++++++++++++++++++++++++++++++ plugins/1password/README.md | 35 ++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 plugins/1password/1password.plugin.zsh create mode 100644 plugins/1password/README.md diff --git a/plugins/1password/1password.plugin.zsh b/plugins/1password/1password.plugin.zsh new file mode 100644 index 000000000..5af5ebb2b --- /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 5 seconds. The +# clipboard is cleared after another 10 seconds. +function opswd() { + if [[ $# -lt 1 ]]; then + echo "Usage: opswd " + 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) &! +} + +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..97be45437 --- /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. + +## `opwsd` + +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/). -- cgit v1.2.3-70-g09d2 From c7221c5f257fc42ec8f6c6a6463bc8a5da25b00f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 24 Jan 2022 15:41:40 +0100 Subject: style(installer): prefix formatting variables with `FMT_` --- tools/install.sh | 78 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index d3f1ee640..b4b90a62d 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -190,24 +190,24 @@ 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="" - RED="" - GREEN="" - YELLOW="" - BLUE="" - BOLD="" - RESET="" + FMT_RAINBOW="" + FMT_RED="" + FMT_GREEN="" + FMT_YELLOW="" + FMT_BLUE="" + FMT_BOLD="" + FMT_RESET="" return fi if supports_truecolor; then - RAINBOW=" + FMT_RAINBOW=" $(printf '\033[38;2;255;0;0m') $(printf '\033[38;2;255;97;0m') $(printf '\033[38;2;247;255;0m') @@ -217,7 +217,7 @@ setup_color() { $(printf '\033[38;2;245;0;172m') " else - RAINBOW=" + FMT_RAINBOW=" $(printf '\033[38;5;196m') $(printf '\033[38;5;202m') $(printf '\033[38;5;226m') @@ -228,12 +228,12 @@ setup_color() { " fi - RED=$(printf '\033[31m') - GREEN=$(printf '\033[32m') - YELLOW=$(printf '\033[33m') - BLUE=$(printf '\033[34m') - BOLD=$(printf '\033[1m') - RESET=$(printf '\033[0m') + 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() { @@ -244,7 +244,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" @@ -276,14 +276,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 @@ -295,14 +295,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/|") @@ -327,16 +327,16 @@ setup_shell() { if ! command_exists chsh; then cat < Date: Mon, 24 Jan 2022 15:41:57 +0100 Subject: fix(installer): define `$USER` if not defined Fixes missing $USER value in ArchLinux sh (bash) --- tools/install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/install.sh b/tools/install.sh index b4b90a62d..9ad6f7d14 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -51,6 +51,9 @@ CHSH=${CHSH:-yes} RUNZSH=${RUNZSH:-yes} KEEP_ZSHRC=${KEEP_ZSHRC:-no} +# Sane defaults +USER=${USER:-$(whoami)} + command_exists() { command -v "$@" >/dev/null 2>&1 -- cgit v1.2.3-70-g09d2 From 788802af68af9a1adbfdb678086939c89d79d999 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 24 Jan 2022 15:45:42 +0100 Subject: fix(installer): correct check for `sudo` in shell change logic --- tools/install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 9ad6f7d14..34dca8413 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -60,6 +60,8 @@ command_exists() { } 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: @@ -78,7 +80,7 @@ user_can_sudo() { # 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" + ! 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 @@ -395,9 +397,9 @@ EOF # be prompted for the password either way, so this shouldn't cause any issues. # if user_can_sudo; then - chsh -s "$zsh" "$USER" # run chsh normally - else sudo -k chsh -s "$zsh" "$USER" # -k forces the password prompt + else + chsh -s "$zsh" "$USER" # run chsh normally fi # Check if the shell change was successful -- cgit v1.2.3-70-g09d2 From 8e7c33bf15ba2835da03604b396885ace635689c Mon Sep 17 00:00:00 2001 From: David Chin Date: Mon, 24 Jan 2022 10:30:49 -0500 Subject: chore(1password): fix typo in `opswd` (#10614) --- plugins/1password/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/1password/README.md b/plugins/1password/README.md index 97be45437..f6790ca8a 100644 --- a/plugins/1password/README.md +++ b/plugins/1password/README.md @@ -11,7 +11,7 @@ plugins=(... 1password) Then, you can use the command `opswd` to copy passwords for services into your clipboard. -## `opwsd` +## `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. -- cgit v1.2.3-70-g09d2 From f64cabc780496636b3e4f5283ef8d77c23f18e92 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 24 Jan 2022 17:38:32 +0100 Subject: fix(cli): make sure to run `zsh` command if an alias exists (#9737) Fixes #9737 --- lib/cli.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/cli.zsh b/lib/cli.zsh index 2f3f293da..edc10e722 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -289,7 +289,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" @@ -365,7 +365,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" @@ -721,7 +721,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" @@ -765,9 +765,9 @@ function _omz::update { # 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 -- cgit v1.2.3-70-g09d2 From 4417faf84cf538d6b22ec613b043f23ef4023457 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 24 Jan 2022 17:45:09 +0100 Subject: feat(postgres): support Homebrew for Apple Silicon (#10618) --- plugins/postgres/postgres.plugin.zsh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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" -- cgit v1.2.3-70-g09d2 From fc40b53e6460560ed9b256deb87f2165f8d48f1f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 24 Jan 2022 18:32:36 +0100 Subject: style(updater): silence `git pull` output and show errors in English --- tools/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 55412062a..b6cb10b5a 100755 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -194,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 $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." -- cgit v1.2.3-70-g09d2 From 3741d1aa0253291c432e6ce3469f1d16dedbc914 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 26 Jan 2022 17:13:10 +0100 Subject: fix(npx)!: detect new `npx` versions and fail gracefully (#10452) BREAKING CHANGE: the `npx` plugin used a feature of `npx` to check for npm packages and run them if a command was not found. This feature was removed in v7.0.0 and was deemed insecure. The `npx` plugin is now officially deprecated and will be removed soon. Fixes #10452 --- plugins/npx/README.md | 25 +------------------------ plugins/npx/npx.plugin.zsh | 17 +++++++++++------ plugins/osx/osx.plugin.zsh | 4 ++-- 3 files changed, 14 insertions(+), 32 deletions(-) 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 +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" -- cgit v1.2.3-70-g09d2 From 59c40eee8e9232f556e9d4c8c97eb1b866846af3 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 27 Jan 2022 18:01:27 +0100 Subject: fix(installer): avoid `git clone -c` to support git v1.7.1 (#10621) --- tools/install.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 34dca8413..2290bc1eb 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -263,13 +263,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 } -- cgit v1.2.3-70-g09d2 From 303ae79712d8d1df05b3ec6f63eb129c9a2ed031 Mon Sep 17 00:00:00 2001 From: Kuri Schlarb <246386+ntninja@users.noreply.github.com> Date: Thu, 27 Jan 2022 20:48:42 +0000 Subject: fix(ys): fix `$VIRTUAL_ENV` check if `nounset` is enabled (#9915) --- themes/ys.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme index 5ef500e14..4c3c56ffc 100644 --- a/themes/ys.zsh-theme +++ b/themes/ys.zsh-theme @@ -49,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}" } -- cgit v1.2.3-70-g09d2 From ad8220bc6d4529db43c0968175f1b8d0e6637db0 Mon Sep 17 00:00:00 2001 From: ajr-dev Date: Thu, 27 Jan 2022 17:59:04 +0100 Subject: fix(tmux): use `$ZSH_TMUX_CONFIG` setting in tmuxconf alias --- plugins/tmux/README.md | 20 ++++++++++---------- plugins/tmux/tmux.plugin.zsh | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md index bc192a40c..7348f77c9 100644 --- a/plugins/tmux/README.md +++ b/plugins/tmux/README.md @@ -15,16 +15,16 @@ 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 | -| `tmuxconf` | `$EDITOR ~/.tmux.conf` | Open .tmux.conf file with an editor | +| 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 diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 9d333257e..b9bb66d59 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -3,16 +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' -alias tmuxconf='$EDITOR ~/.tmux.conf' - # CONFIGURATION VARIABLES # Automatically start tmux : ${ZSH_TMUX_AUTOSTART:=false} @@ -40,6 +30,16 @@ alias tmuxconf='$EDITOR ~/.tmux.conf' # 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 -- cgit v1.2.3-70-g09d2 From b5edb51ee4bb0b3e9f5cbb0c46348bcbdd941f04 Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 27 Jan 2022 22:00:50 +0100 Subject: style(rkj-repos): change `white` to `default` to support light color schemes (#6195) Co-authored-by: Matthias Doering --- themes/rkj-repos.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ' -- cgit v1.2.3-70-g09d2 From 3c5367d272011e7bca9fa4e8f9a5f9635f938d11 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 28 Jan 2022 13:22:31 +0100 Subject: fix(changelog): don't show changelog with only ignored type commits --- tools/changelog.sh | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/tools/changelog.sh b/tools/changelog.sh index 49532a4a4..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,7 +394,7 @@ 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 @@ -441,7 +447,7 @@ function main { # Output previous release display-release # Reinitialize commit storage - commits=() + types=() subjects=() scopes=() breaking=() -- cgit v1.2.3-70-g09d2 From 6f9650d940f31d9d10f07a176a85ca3b814f448f Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 28 Jan 2022 06:45:05 -0600 Subject: fix(gitfast): update to git-completion 1.3.6 (#10633) --- plugins/gitfast/_git | 46 +- plugins/gitfast/git-completion.bash | 1007 +++++++++++++++++------------------ plugins/gitfast/git-prompt.sh | 7 +- plugins/gitfast/update | 2 +- 4 files changed, 518 insertions(+), 544 deletions(-) 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=' and # '-C ' 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 -# © 2009-2010, Bash Completion Maintainers -# -# -# 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 . -# -# 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= and : 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 +# © 2009-2010, Bash Completion Maintainers +# +# +# 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 . +# +# 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= and : 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" && -- cgit v1.2.3-70-g09d2 From 11a87eac47c579366620f995330532f47dc651f2 Mon Sep 17 00:00:00 2001 From: Gheritarish Date: Fri, 28 Jan 2022 13:47:41 +0100 Subject: chore(1password): fix comments to follow code (#10634) --- plugins/1password/1password.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/1password/1password.plugin.zsh b/plugins/1password/1password.plugin.zsh index 5af5ebb2b..9398b02b4 100644 --- a/plugins/1password/1password.plugin.zsh +++ b/plugins/1password/1password.plugin.zsh @@ -4,8 +4,8 @@ if (( ${+commands[op]} )); then 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 5 seconds. The -# clipboard is cleared after another 10 seconds. +# 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 " -- cgit v1.2.3-70-g09d2 From 46f5d38b1dc6a725e78bd53ca35a6299b4e91ece Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 28 Jan 2022 20:53:30 +0100 Subject: refactor(installer): use POSIX-standard's `id -u -n` to define `$USER` --- tools/install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 2290bc1eb..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} @@ -51,9 +58,6 @@ CHSH=${CHSH:-yes} RUNZSH=${RUNZSH:-yes} KEEP_ZSHRC=${KEEP_ZSHRC:-no} -# Sane defaults -USER=${USER:-$(whoami)} - command_exists() { command -v "$@" >/dev/null 2>&1 -- cgit v1.2.3-70-g09d2 From eabec36586f990b883e7dbf4583e6d86ac46c7ea Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Fri, 28 Jan 2022 23:28:19 +0100 Subject: style(init): use consistent code style in init script (#10601) --- oh-my-zsh.sh | 71 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 32 deletions(-) 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 -- cgit v1.2.3-70-g09d2 From 73001e9382db99ebd6effcf0bdcd227985109142 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 1 Feb 2022 12:56:22 +0100 Subject: refactor(django): remove deprecated `django` plugin BREAKING CHANGE: the `django` plugin was deprecated in 2021-09-22. With this change it has now been removed altogether. Zsh already provides built-in completion for Django commands. --- plugins/django/README.md | 12 -- plugins/django/django.plugin.zsh | 407 --------------------------------------- 2 files changed, 419 deletions(-) delete mode 100644 plugins/django/README.md delete mode 100644 plugins/django/django.plugin.zsh 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" -- cgit v1.2.3-70-g09d2 From 3fdad09d095c0d415e0bd9b5710f57fe30fc962a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 1 Feb 2022 13:07:53 +0100 Subject: chore: update copyright year --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3-70-g09d2 From 0be7c897f824223fa1cd22976b07ae79eff6aaea Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 1 Feb 2022 13:11:49 +0100 Subject: refactor(zsh_reload)!: remove deprecated plugin BREAKING CHANGE: the `zsh_reload` was deprecated long ago and showed a deprecation message. The `src` function was replaced by the CLI command `omz reload`, so use that instead from now on. --- plugins/zsh_reload/README.md | 3 --- plugins/zsh_reload/zsh_reload.plugin.zsh | 7 ------- 2 files changed, 10 deletions(-) delete mode 100644 plugins/zsh_reload/README.md delete mode 100644 plugins/zsh_reload/zsh_reload.plugin.zsh 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 -} -- cgit v1.2.3-70-g09d2 From 4ee0cf3cb4c64568430f9af5b1edca2602ab5807 Mon Sep 17 00:00:00 2001 From: Civan Yavuzşen Date: Tue, 1 Feb 2022 23:48:14 +0100 Subject: feat(multipass): add plugin for multipass (#10140) Co-authored-by: C. Yavuzsen --- plugins/multipass/README.md | 22 ++++++++++ plugins/multipass/_multipass | 73 ++++++++++++++++++++++++++++++++++ plugins/multipass/multipass.plugin.zsh | 7 ++++ 3 files changed, 102 insertions(+) create mode 100644 plugins/multipass/README.md create mode 100644 plugins/multipass/_multipass create mode 100644 plugins/multipass/multipass.plugin.zsh 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