├── .dockerignore ├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug-report.yml │ ├── config.yml │ ├── documentation.yml │ ├── feature-request.yml │ └── maintenance.yml ├── dependabot.yaml ├── labeler.yml ├── stale.yml └── workflows │ ├── bump-homebrew-formula.yml │ ├── containers.yaml │ ├── documentation.yaml │ ├── installer.yaml │ ├── labeler.yaml │ ├── linting.yaml │ ├── release.yml │ └── tests.yaml ├── .gitignore ├── .releaserc.json ├── .zunit.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── Makefile ├── README.md ├── VERSION ├── _zinit ├── doc ├── CHANGELOG.md ├── HACKING.md ├── img │ ├── m.png │ ├── update.png │ ├── zplugin.png │ ├── zplugin.svg │ ├── zplugin_refcard.png │ └── zplugin_refcard.svg ├── zinit.1 └── zsdoc │ ├── Makefile │ ├── README.md │ ├── zinit-additional.zsh.adoc │ ├── zinit-autoload.zsh.adoc │ ├── zinit-install.zsh.adoc │ ├── zinit-side.zsh.adoc │ └── zinit.zsh.adoc ├── docker ├── Dockerfile ├── init.zsh ├── utils.zsh ├── zshenv ├── zshrc └── zshrc-fancy ├── scripts ├── docker-build.sh ├── docker-run.sh └── install.sh ├── share ├── git-process-output.zsh ├── rpm2cpio.zsh ├── template-plugin │ ├── template-script │ └── zsh.gitignore └── zsh.ctags ├── tests ├── _output │ └── .gitkeep ├── _support │ ├── annex_test_assertions │ ├── bootstrap │ └── gen-ghr-test ├── annexes.zunit ├── commands.zunit ├── compile.zunit ├── gh-r.zunit ├── ices.zunit ├── plugins.zunit └── snippets.zunit ├── zi-browse-symbol ├── zinit-additional.zsh ├── zinit-autoload.zsh ├── zinit-install.zsh ├── zinit-side.zsh └── zinit.zsh /.dockerignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | .github/ 3 | .git* 4 | doc/ 5 | scripts/ 6 | test/ 7 | tests/ 8 | 9 | *.zwc 10 | Makefile 11 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # By default, everything is text 2 | * text 3 | 4 | # These must be unix EOLs 5 | *.sh eol=lf 6 | *.zsh diff=zsh eol=lf 7 | *.zunit diff=zsh eol=lf 8 | Makefile eol=lf 9 | 10 | # Use the markdown differ. 11 | *.md diff=markdown 12 | 13 | # Binary files 14 | *.png binary 15 | 16 | # EOF 17 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @alichtman @pschmitt @vladdoster 2 | 3 | # Should consider adding @psprint as well 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: File a bug report 3 | title: "[bug]: " 4 | labels: ["bug", "triage"] 5 | assignees: 6 | - vladdoster 7 | body: 8 | 9 | - type: markdown 10 | attributes: 11 | value: | 12 | Thanks for taking the time to fill out this bug report! 13 | 14 | ## Self Check 15 | 16 | - Look for similar errors in existing [GitHub Issues](https://github.com/zdharma-continuum/zinit/issues?q=is%3Aissue) (open or closed). 17 | - Try reaching out on the [Gitter server](https://gitter.im/zdharma-continuum/community/) for help. 18 | 19 | - type: textarea 20 | id: what-happened 21 | attributes: 22 | label: What happened? 23 | description: Also tell us, what did you expect to happen? 24 | placeholder: Tell us what you see! 25 | value: "A bug happened!" 26 | validations: 27 | required: true 28 | 29 | - type: textarea 30 | validations: 31 | required: true 32 | attributes: 33 | label: Steps to reproduce 34 | description: | 35 | Steps to reproduce the problem 36 | placeholder: | 37 | 1. Enable plugin 'foo' 38 | 2. Run 'foo bar' or try to complete command 'foo --widget' 39 | 3. See error 40 | 41 | - type: textarea 42 | id: logs 43 | attributes: 44 | label: Relevant output 45 | description: Please copy and paste any relevant output. This will be automatically formatted into code, so no need for backticks. 46 | render: shell 47 | 48 | - type: textarea 49 | attributes: 50 | label: Screenshots and recordings 51 | description: | 52 | If applicable, add screenshots or [asciinema](https://asciinema.org) session to explain your problem 53 | 54 | - type: input 55 | validations: 56 | required: true 57 | attributes: 58 | label: Operating System & Version 59 | description: | 60 | Output of 61 | ``` 62 | echo "OS: ${OSTYPE:-N/A} | Vendor: ${VENDOR:-N/A} | Machine: ${MACHTYPE:-N/A} | CPU: ${CPUTYPE:-N/A} | Processor: ${$(uname -p 2>/dev/null):-N/A} | Hardware: ${$(uname -m 2>/dev/null):-N/A}" 63 | ``` 64 | 65 | - type: input 66 | validations: 67 | required: true 68 | attributes: 69 | label: Zsh version 70 | description: Output of `zsh --version` 71 | 72 | - type: input 73 | validations: 74 | required: true 75 | attributes: 76 | label: Terminal emulator 77 | description: Terminal name & output of `echo "${TERM}"` 78 | 79 | - type: dropdown 80 | attributes: 81 | label: If using WSL on Windows, which version of WSL 82 | description: Output `wsl -l -v` 83 | options: 84 | - 'WSL 1' 85 | - 'WSL 2' 86 | 87 | - type: textarea 88 | attributes: 89 | label: Additional context 90 | description: Add any other context about the problem. This can be themes, plugins, custom settings, etc. 91 | 92 | - type: checkboxes 93 | id: terms 94 | attributes: 95 | label: Code of Conduct 96 | description: By submitting this issue, you agree to follow our [Code of Conduct](../../CODE_OF_CONDUCT.md) 97 | options: 98 | - label: I agree to follow this project's Code of Conduct 99 | required: true 100 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Support 4 | url: https://github.com/zdharma-continuum/zinit/discussions 5 | about: Ask the community for support 6 | - name: Get help on Gitter 7 | url: https://gitter.im/zdharma-continuum/community/ 8 | about: Have a quick question? Join the Gitter community and ask your question. 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | description: Create a report to help us improve the documentation 3 | labels: [documentation] 4 | title: "[doc]: " 5 | body: 6 | - type: input 7 | id: link 8 | attributes: 9 | label: Documentation Link 10 | description: | 11 | Link to any documentation or examples that you are referencing. 12 | Suggested improvements should be based on the development version of the docs: https://zdharma-continuum.github.io/zinit/wiki/ 13 | placeholder: https://zdharma-continuum.github.io/zinit/wiki/... 14 | - type: textarea 15 | id: problem 16 | attributes: 17 | label: Problem 18 | description: What is missing, unclear, or wrong in the documentation? 19 | placeholder: | 20 | * I found [...] to be unclear because [...] 21 | * [...] made me think that [...] when really it should be [...] 22 | * There is no example showing how to do [...] 23 | validations: 24 | required: true 25 | - type: textarea 26 | id: improvement 27 | attributes: 28 | label: Suggested improvement 29 | placeholder: | 30 | * This line should be be changed to say [...] 31 | * Include a paragraph explaining [...] 32 | * Add a figure showing [...] 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest a feature for Zinit 3 | labels: ["feature"] 4 | title: "[feat]: " 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | ## Self Check 10 | - Look for similar features in existing [GitHub Issues](https://github.com/zdharma-continuum/zinit/issues?q=is%3Aissue) (open or closed). 11 | - type: input 12 | attributes: 13 | label: If the feature request is for a plugin or theme, specify it here. 14 | description: The name of the plugin or theme that you would like us to improve. 15 | placeholder: e.g. Git plugin, Agnoster theme 16 | - type: textarea 17 | attributes: 18 | label: If the feature solves a problem you have, specify it here. 19 | description: A description of what the problem is. 20 | placeholder: Ex. I'm always frustrated when... 21 | - type: textarea 22 | attributes: 23 | label: Describe the proposed feature. 24 | description: A description of what you want to happen. Be as specific as possible. 25 | validations: 26 | required: true 27 | - type: textarea 28 | attributes: 29 | label: Describe alternatives you've considered 30 | description: A description of any alternative solutions or features you've considered. This can also include other plugins or themes. 31 | - type: textarea 32 | attributes: 33 | label: Additional context 34 | description: Add any other context, screenshots or Gitter conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at. 35 | - type: textarea 36 | attributes: 37 | label: Related Issues 38 | description: Is there any open or closed issues that is related to this feature request? If so please link them below! 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/maintenance.yml: -------------------------------------------------------------------------------- 1 | name: Maintenance 2 | description: Help improve performance, usability and/or consistency. 3 | title: "[maint]: " 4 | labels: [Maintenance] 5 | body: 6 | - type: textarea 7 | id: summary 8 | attributes: 9 | label: Summary 10 | description: Please provide 1-2 short sentences that succinctly describes what could be improved. 11 | validations: 12 | required: true 13 | - type: textarea 14 | id: fix 15 | attributes: 16 | label: Proposed fix 17 | description: Please describe how you think this could be improved. 18 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | -------------------------------------------------------------------------------- /.github/labeler.yml: -------------------------------------------------------------------------------- 1 | ci/cd: 2 | - changed-files: 3 | - any-glob-to-any-file: '.github/**' 4 | 5 | docker: 6 | - changed-files: 7 | - any-glob-to-any-file: 'docker/**' 8 | 9 | scripts: 10 | - changed-files: 11 | - any-glob-to-any-file: 'docker/**' 12 | 13 | tests: 14 | - changed-files: 15 | - any-glob-to-any-file: ['.zunit.yml', 'tests/**/*'] 16 | 17 | completion: 18 | - changed-files: 19 | - any-glob-to-any-file: '_zinit' 20 | 21 | # Add 'Documentation' label to any file changes within 'docs' folder 22 | docs: 23 | - changed-files: 24 | - any-glob-to-any-file: 'doc/**' 25 | - any-glob-to-any-file: '**/*.md' 26 | 27 | # Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder 28 | zinit: 29 | - changed-files: 30 | - any-glob-to-any-file: 'zinit*.zsh*' 31 | 32 | # Add 'feature' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name 33 | feature: 34 | - head-branch: ['^feat'] 35 | 36 | fix: 37 | - head-branch: ['^fix'] 38 | 39 | # Add 'release' label to any PR that is opened against the `main` branch 40 | release: 41 | - base-branch: 'main' 42 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-stale - https://github.com/probot/stale 2 | 3 | # Number of days of inactivity before an Issue or Pull Request becomes stale 4 | daysUntilStale: 180 5 | # Number of days of inactivity before an Issue or Pull Request with the stale label is closed. 6 | daysUntilClose: 7 7 | # Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) 8 | onlyLabels: [] 9 | # Set to true to ignore issues in a project (defaults to false) 10 | exemptProjects: false 11 | # Set to true to ignore issues in a milestone 12 | exemptMilestones: false 13 | # Set to true to ignore issues with an assignee 14 | exemptAssignees: false 15 | # Label to use when marking as stale 16 | staleLabel: stale 17 | # Limit the number of actions per hour, from 1-30. Default is 30 18 | limitPerRun: 30 19 | # configuration settings that are specific to just 'issues' or 'pulls': 20 | pulls: 21 | daysUntilStale: 30 22 | markComment: > 23 | This pull request has been automatically marked as stale because it has not had 24 | recent activity. It will be closed if no further activity occurs. Thank you 25 | for your contributions. 26 | unmarkComment: > 27 | This pull request has been automatically marked as not stale anymore due to the recent activity. 28 | closeComment: > 29 | This pull request has been automatically closed because it had not recent activity during the stale period. 30 | issues: 31 | markComment: > 32 | This issue has been automatically marked as stale because it has not had 33 | recent activity. It will be closed if no further activity occurs. Thank you 34 | for your contributions. 35 | unmarkComment: > 36 | This issue has been automatically marked as not stale anymore due to the recent activity. 37 | closeComment: > 38 | This issue has been automatically closed because it had not recent activity during the stale period. 39 | -------------------------------------------------------------------------------- /.github/workflows/bump-homebrew-formula.yml: -------------------------------------------------------------------------------- 1 | name: Bump Homebrew Formula 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | tags: 7 | - '*' 8 | 9 | jobs: 10 | bump-homebrew-formula: 11 | runs-on: macos-latest 12 | steps: 13 | - name: Checkout repository 14 | uses: actions/checkout@v4 15 | 16 | - name: Bump Homebrew formulae 17 | uses: dawidd6/action-homebrew-bump-formula@v4 18 | with: 19 | formula: zinit 20 | # A Personal Access Token (PAT) is instead of the default 21 | # GITHUB_TOKEN because brew bump-formula-pr creates a fork of the 22 | # formula's tap repository (if needed) and then creates a pull 23 | # request. 24 | token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} 25 | -------------------------------------------------------------------------------- /.github/workflows/containers.yaml: -------------------------------------------------------------------------------- 1 | name: Container images 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | tags: 8 | - v[0-9]+.[0-9]+.[0-9]+ 9 | workflow_dispatch: 10 | 11 | jobs: 12 | build-containers-with-zsh: 13 | runs-on: ubuntu-latest 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | zsh_version: 18 | - 5.8 19 | - 5.9 20 | steps: 21 | - name: check out repository code 22 | uses: actions/checkout@v4 23 | 24 | - name: Grab git slugs (short commit id, branch etc.) 25 | uses: rlespinasse/github-slug-action@v3.x 26 | 27 | - name: set up qemu 28 | uses: docker/setup-qemu-action@v3 29 | 30 | - name: setup docker buildx 31 | id: buildx 32 | uses: docker/setup-buildx-action@v3 33 | with: 34 | install: true 35 | use: true 36 | 37 | - name: login to github container registry 38 | uses: docker/login-action@v3 39 | with: 40 | registry: ghcr.io 41 | username: ${{ github.actor }} 42 | password: ${{ secrets.GITHUB_TOKEN }} 43 | 44 | - name: build and push 45 | id: docker_build_zsh_versions 46 | uses: docker/build-push-action@v6 47 | timeout-minutes: 90 # compiling older zsh versions take a long time 48 | with: 49 | push: ${{ github.event.number == 0 }} 50 | file: ./docker/Dockerfile 51 | build-args: | 52 | ZINIT_ZSH_VERSION=${{ matrix.zsh_version }}-tcsetpgrp 53 | tags: | 54 | ghcr.io/${{ github.repository }}:zsh-${{ matrix.zsh_version }} 55 | ghcr.io/${{ github.repository }}:zsh-${{ matrix.zsh_version }}-${{ env.GITHUB_SHA_SHORT }} 56 | platforms: linux/amd64,linux/arm64/v8 57 | cache-from: type=gha 58 | cache-to: type=gha,mode=max 59 | 60 | build-container-latest: 61 | runs-on: ubuntu-latest 62 | steps: 63 | - name: checkout code 64 | uses: actions/checkout@v4 65 | 66 | - name: get vcs details 67 | uses: rlespinasse/github-slug-action@v3.x 68 | 69 | - name: setup docker qemu 70 | uses: docker/setup-qemu-action@v3 71 | 72 | - name: setup docker buildx 73 | id: buildx 74 | uses: docker/setup-buildx-action@v3 75 | with: 76 | install: true 77 | use: true 78 | 79 | - name: github container registry authentication 80 | uses: docker/login-action@v3 81 | with: 82 | registry: ghcr.io 83 | username: ${{ github.actor }} 84 | password: ${{ secrets.GITHUB_TOKEN }} 85 | 86 | - name: build & push new image 87 | id: docker_build_latest 88 | uses: docker/build-push-action@v6 89 | if: github.ref == 'refs/heads/main' 90 | with: 91 | push: true 92 | file: ./docker/Dockerfile 93 | tags: | 94 | ghcr.io/${{ github.repository }}:latest 95 | ghcr.io/${{ github.repository }}:${{ env.GITHUB_SHA_SHORT }} 96 | ghcr.io/${{ github.repository }}:${{ env.GITHUB_REF_SLUG }} 97 | platforms: linux/amd64,linux/arm64/v8 98 | cache-from: type=gha 99 | cache-to: type=gha,mode=max 100 | -------------------------------------------------------------------------------- /.github/workflows/documentation.yaml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | paths: 8 | - 'zinit*.zsh' 9 | push: 10 | branches: 11 | - main 12 | workflow_dispatch: 13 | 14 | jobs: 15 | zshelldoc: 16 | runs-on: ubuntu-latest 17 | steps: 18 | 19 | - name: checkout repository 20 | uses: actions/checkout@v4 21 | with: 22 | repository: ${{ github.event.pull_request.head.repo.full_name }} 23 | ref: ${{ github.event.pull_request.head.ref }} 24 | 25 | - name: re-generate documentation 26 | run: | 27 | make doc/container 28 | sudo chown -R "$(id -u):$(id -g)" . 29 | 30 | - name: commit changes to the current branch 31 | uses: EndBug/add-and-commit@v9 32 | with: 33 | add: 'doc' 34 | author_name: GitHub Actions 35 | author_email: actions@github.com 36 | commit: --signoff 37 | message: 'docs: generate' 38 | push: true 39 | -------------------------------------------------------------------------------- /.github/workflows/installer.yaml: -------------------------------------------------------------------------------- 1 | # name: Installer 2 | 3 | # concurrency: 4 | # cancel-in-progress: true 5 | # group: ${{ github.workflow }}-${{ github.ref }} 6 | 7 | # defaults: 8 | # run: 9 | # shell: bash 10 | 11 | # env: 12 | # NO_INPUT: true 13 | # TERM: xterm 14 | # ZINIT_BRANCH: ${{ github.ref_name }} 15 | # ZINIT_COMMIT: ${{ github.sha }} 16 | # ZINIT_REPO: ${{ github.repository }} 17 | 18 | # on: 19 | # pull_request: 20 | # branches: 21 | # - main 22 | # paths: 23 | # - .github/workflows/installer.yaml 24 | # - scripts/** 25 | # - share/** 26 | # - zinit*.zsh 27 | # push: 28 | # branches: 29 | # - main 30 | # workflow_dispatch: 31 | 32 | # jobs: 33 | 34 | # zinit-installer: 35 | 36 | # runs-on: ${{ matrix.os }} 37 | # strategy: 38 | # fail-fast: true 39 | # matrix: 40 | # annexes: ["with annexes", "no annexes"] 41 | # os: [macos-latest, ubuntu-latest, windows-latest] 42 | 43 | # steps: 44 | 45 | # - name: check out repository 46 | # uses: actions/checkout@v3 47 | 48 | # - name: windows dependencies 49 | # if: runner.os == 'Windows' 50 | # uses: egor-tensin/setup-cygwin@v3 51 | # with: 52 | # platform: x64 53 | # packages: curl git zsh 54 | 55 | # - name: remove \r 56 | # if: runner.os == 'Windows' 57 | # run: sed -i 's/\r$//' scripts/*.sh 58 | 59 | # - name: linux/macos dependencies 60 | # if: runner.os != 'Windows' 61 | # run: brew install --force curl subversion unzip xz zsh 62 | 63 | # - name: install 64 | # run: ./scripts/install.sh 65 | 66 | # - name: verify install 67 | # run: zsh -silc 'zinit --help' 68 | -------------------------------------------------------------------------------- /.github/workflows/labeler.yaml: -------------------------------------------------------------------------------- 1 | name: Labeler 2 | 3 | on: 4 | pull_request_target: # https://securitylab.github.com/research/github-actions-preventing-pwn-requests 5 | 6 | jobs: 7 | label-pull-requests: 8 | 9 | permissions: 10 | contents: read 11 | pull-requests: write 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/labeler@v5 17 | with: 18 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 19 | sync-labels: true 20 | -------------------------------------------------------------------------------- /.github/workflows/linting.yaml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | push: 8 | branches: 9 | - main 10 | workflow_dispatch: 11 | 12 | jobs: 13 | mdlint: 14 | name: Markdown Lint 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - uses: xt0rted/markdownlint-problem-matcher@v3 20 | 21 | - run: npm install -g markdownlint-cli 22 | 23 | # disabled checks: 24 | # - MD013/line-length 25 | # - MD033/no-inline-html 26 | # - MD034/no-bare-urls 27 | # - MD036/no-emphasis-as-heading 28 | # - MD041/first-line-heading/first-line-h1 29 | - run: | 30 | markdownlint --version 31 | 32 | # List files to lint 33 | ls *.md **/*.md 34 | 35 | markdownlint \ 36 | --ignore '**/CHANGELOG.md' \ 37 | --disable MD013 MD033 MD034 MD036 MD041 -- \ 38 | *.md **/*.md 39 | 40 | zshlint: 41 | name: ZSH Lint 42 | runs-on: ubuntu-latest 43 | 44 | strategy: 45 | fail-fast: false 46 | matrix: 47 | task: [zsh-noexec, zsh-zcompile] 48 | 49 | steps: 50 | - uses: actions/checkout@v4 51 | with: 52 | fetch-depth: 0 53 | 54 | - uses: actions/setup-python@v5 55 | 56 | - name: install dependencies 57 | run: | 58 | sudo apt-get update 59 | sudo apt-get install --yes zsh 60 | 61 | - name: "run lint (${{ matrix.task }})" 62 | run: | 63 | case "${{ matrix.task }}" in 64 | zsh-noexec) 65 | find . -name '*.zsh' -type f -print0 \ 66 | | xargs -0 -n1 -P4 zsh -n 67 | ;; 68 | zsh-zcompile) 69 | find . -name '*.zsh' -type f \ 70 | -exec zsh -fc "zcompile {}" \; 71 | ;; 72 | *) 73 | echo "ERROR: unknown task ${{ matrix.task }}" >&2 74 | exit 1 75 | ;; 76 | esac 77 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | release: 8 | name: release 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | - uses: actions/setup-node@v4 13 | with: 14 | node-version: '20' 15 | 16 | - name: Fetch dependencies 17 | run: | 18 | npm install --no-package-lock \ 19 | @semantic-release/changelog @semantic-release-plus/docker @semantic-release/exec @semantic-release/git \ 20 | conventional-changelog-eslint @google/semantic-release-replace-plugin 21 | 22 | - name: Set up Docker Buildx 23 | uses: docker/setup-buildx-action@v3 24 | 25 | - name: Generate release 26 | run: npx semantic-release --ci -- 27 | env: 28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 29 | GIT_AUTHOR_EMAIL: 'mvdoster@gmail.com' 30 | GIT_AUTHOR_NAME: 'Vladislav Doster' 31 | GIT_COMMITTER_EMAIL: 'mvdoster@gmail.com' 32 | GIT_COMMITTER_NAME: 'Vladislav Doster' 33 | -------------------------------------------------------------------------------- /.github/workflows/tests.yaml: -------------------------------------------------------------------------------- 1 | name: Unit Tests 2 | 3 | concurrency: 4 | group: ${{ github.workflow }}-${{ github.ref }} 5 | cancel-in-progress: true 6 | 7 | env: 8 | HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 9 | TERM: xterm-256color 10 | 11 | on: 12 | pull_request: 13 | branches: 14 | - main 15 | paths: 16 | - "tests/**" 17 | - "share/**" 18 | - "zinit*.zsh" 19 | - ".github/workflows/tests.yaml" 20 | push: 21 | branches: 22 | - main 23 | workflow_dispatch: 24 | 25 | jobs: 26 | zunit-tests: 27 | runs-on: ${{ matrix.os }} 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | os: [macos-latest, ubuntu-latest] 32 | zunit_test: 33 | - annexes 34 | - commands 35 | - compile 36 | - gh-r 37 | - ices 38 | - plugins 39 | - snippets 40 | 41 | steps: 42 | - name: checkout ${{ github.repository }} 43 | uses: actions/checkout@v4 44 | with: 45 | fetch-depth: 0 46 | 47 | - name: install homebrew 48 | id: setup-homebrew 49 | uses: Homebrew/actions/setup-homebrew@master 50 | 51 | - name: "install musl" 52 | if: runner.os == 'Linux' 53 | run: | 54 | sudo apt-get update --yes 55 | sudo apt-get install --no-install-recommends --yes \ 56 | autoconf automake autotools-dev \ 57 | build-essential byacc \ 58 | file \ 59 | gcc gettext glibc-source grep \ 60 | libc6 libc6-dev libevent-dev libncurses5-dev libncursesw5-dev libtool libuvc0 lua5.1 \ 61 | m4 \ 62 | ninja-build \ 63 | pkg-config \ 64 | xz-utils \ 65 | zsh 66 | 67 | - name: "install dependencies" 68 | id: install-deps 69 | run: | 70 | brew install --force --overwrite autoconf automake binutils byacc cmake coreutils curl gettext gnu-sed libevent libtool libuv lua lua@5.4 make ncurses ninja parallel pkg-config texinfo unzip xz zsh 71 | brew link --force --overwrite ncurses 72 | 73 | - name: "install zunit" 74 | id: install-zunit 75 | shell: zsh {0} 76 | run: | 77 | mkdir -p "$HOME/.local/bin" 78 | echo "$HOME/.local/bin" >> $GITHUB_PATH 79 | git clone --depth 1 https://github.com/zdharma-continuum/zunit 80 | cd ./zunit 81 | ./configure --prefix=$HOME/.local 82 | make all install 83 | 84 | - name: "run tests" 85 | run: zunit run tests/${{ matrix.zunit_test }}.zunit 86 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.[aos] 2 | *.bundle 3 | *.dll 4 | *.orig 5 | *.txt 6 | *.zini 7 | *.zwc 8 | *deploy*key* 9 | *~ 10 | .*.sw? 11 | .project 12 | TAGS 13 | TODO* 14 | \#* 15 | doc/zsdoc/data 16 | other 17 | site*/ 18 | tags 19 | test/ 20 | txt/ 21 | zmodules/ 22 | tests/_output/ 23 | tests/_support/tmp* 24 | .idea 25 | -------------------------------------------------------------------------------- /.releaserc.json: -------------------------------------------------------------------------------- 1 | { 2 | "repositoryUrl": "https://github.com/zdharma-continuum/zinit.git", 3 | "branches": [ 4 | "main" 5 | ], 6 | "plugins": [ 7 | [ "@semantic-release/commit-analyzer", { } ], 8 | [ 9 | "@google/semantic-release-replace-plugin", 10 | { 11 | "replacements": [ 12 | { 13 | "files": [ 14 | "VERSION" 15 | ], 16 | "from": "^([0-9]).+([0-9]).+([0-9])$", 17 | "to": "${nextRelease.version}", 18 | "results": [ 19 | { 20 | "file": "VERSION", 21 | "hasChanged": true 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | ], 28 | [ "@semantic-release/release-notes-generator", { } ], 29 | [ 30 | "@semantic-release/changelog", 31 | { 32 | "changelogFile": "CHANGELOG.md" 33 | } 34 | ], 35 | [ 36 | "@semantic-release/git", 37 | { 38 | "assets": [ 39 | "CHANGELOG.md", 40 | "VERSION" 41 | ], 42 | "message": "release: v${lastRelease.version} → v${nextRelease.version}\n\n${nextRelease.notes}" 43 | } 44 | ], 45 | "@semantic-release/github" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /.zunit.yml: -------------------------------------------------------------------------------- 1 | allow_risky: false 2 | directories: 3 | output: tests/_output 4 | support: tests/_support 5 | tests: tests 6 | fail_fast: false 7 | verbose: true 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for 6 | everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity 7 | and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, 8 | or sexual identity and orientation. 9 | 10 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to a positive environment for our community include: 15 | 16 | - Demonstrating empathy and kindness toward other people 17 | - Being respectful of differing opinions, viewpoints, and experiences 18 | - Giving and gracefully accepting constructive feedback 19 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 20 | - Focusing on what is best not just for us as individuals, but for the overall community 21 | 22 | Examples of unacceptable behavior include: 23 | 24 | - The use of sexualized language or imagery, and sexual attention or advances of any kind 25 | - Trolling, insulting or derogatory comments, and personal or political attacks 26 | - Public or private harassment 27 | - Publishing others' private information, such as a physical or email address, without their explicit permission 28 | - Other conduct which could reasonably be considered inappropriate in a professional setting 29 | 30 | ## Enforcement Responsibilities 31 | 32 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take 33 | appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, 34 | or harmful. 35 | 36 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, 37 | issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for 38 | moderation decisions when appropriate. 39 | 40 | ## Scope 41 | 42 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing 43 | the community in public spaces. Examples of representing our community include using an official e-mail address, posting 44 | via an official social media account, or acting as an appointed representative at an online or offline event. 45 | 46 | ## Enforcement 47 | 48 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible 49 | for enforcement at . All complaints will be reviewed and investigated promptly and fairly. 50 | 51 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 52 | 53 | ## Enforcement Guidelines 54 | 55 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem 56 | in violation of this Code of Conduct: 57 | 58 | ### 1. Correction 59 | 60 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the 61 | community. 62 | 63 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation 64 | and an explanation of why the behavior was inappropriate. A public apology may be requested. 65 | 66 | ### 2. Warning 67 | 68 | **Community Impact**: A violation through a single incident or series of actions. 69 | 70 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including 71 | unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding 72 | interactions in community spaces as well as external channels like social media. Violating these terms may lead to a 73 | temporary or permanent ban. 74 | 75 | ### 3. Temporary Ban 76 | 77 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 78 | 79 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified 80 | period of time. No public or private interaction with the people involved, including unsolicited interaction with those 81 | enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 82 | 83 | ### 4. Permanent Ban 84 | 85 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate 86 | behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 87 | 88 | **Consequence**: A permanent ban from any sort of public interaction within the community. 89 | 90 | ## Attribution 91 | 92 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at 93 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 94 | 95 | Community Impact Guidelines were inspired by 96 | [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 97 | 98 | For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. 99 | Translations are available at https://www.contributor-covenant.org/translations. 100 | 101 | [homepage]: https://www.contributor-covenant.org 102 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors 4 | Copyright (c) 2021-2022 zdharma-continuum 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .EXPORT_ALL_VARIABLES: 2 | 3 | ZSH := $(shell command -v zsh 2> /dev/null) 4 | SRC := zinit{'','-additional','-autoload','-install','-side'}.zsh 5 | DOC_SRC := $(foreach wrd,$(SRC),../$(wrd)) 6 | 7 | .PHONY: all clean container doc doc/container tags tags/emacs tags/vim test zwc 8 | 9 | clean: 10 | rm -rf *.zwc doc/zsdoc/zinit{'','-additional','-autoload','-install','-side'}.zsh.adoc doc/zsdoc/data/ 11 | 12 | container: 13 | docker build --tag=ghcr.io/zdharma-continuum/zinit:latest --file=docker/Dockerfile . 14 | 15 | doc: clean 16 | cd doc; zsh -l -d -f -i -c "zsd -v --scomm --cignore '(\#*FUNCTION:[[:space:]][\:\∞\.\+\@\-a-zA-Z0-9]*[\[]*|}[[:space:]]\#[[:space:]][\]]*)' $(DOC_SRC)" 17 | 18 | doc/container: container 19 | ./scripts/docker-run.sh --docs --debug 20 | 21 | # Run ctags to generate Emacs and Vim's format tag file. 22 | tags: tags/emacs tags/vim 23 | 24 | tags/emacs: ## Build Emacs-style ctags file 25 | @if type ctags >/dev/null 2>&1; then \ 26 | if ctags --version | grep >/dev/null 2>&1 "Universal Ctags"; then \ 27 | ctags -e -R --options=share/zsh.ctags --languages=zsh \ 28 | --pattern-length-limit=250 --maxdepth=1; \ 29 | else \ 30 | ctags -e -R --languages=sh --langmap=sh:.zsh; \ 31 | fi; \ 32 | printf "Created the Emacs \`TAGS\` file.\\n"; \ 33 | else \ 34 | printf 'Error: Please install a Ctags (e.g.: either the Exuberant or Universal %b' \ 35 | 'version) utility first.\n'; \ 36 | fi 37 | 38 | tags/vim: ## Build the Vim-style ctags file 39 | @if type ctags >/dev/null 2>&1; then \ 40 | if ctags --version | grep >/dev/null 2>&1 "Universal Ctags"; then \ 41 | ctags --languages=zsh --maxdepth=1 --options=share/zsh.ctags --pattern-length-limit=250 -R; \ 42 | else \ 43 | ctags -R --languages=sh --langmap=sh:.zsh; \ 44 | fi; \ 45 | printf "Created the Vim's style \`tags\` file.\\n"; \ 46 | else \ 47 | printf 'Error: Please install a ctags first.\n'; \ 48 | fi 49 | 50 | test: 51 | zunit run 52 | 53 | zwc: 54 | $(or $(ZSH),:) -fc 'for f in *.zsh; do zcompile -R -- $$f.zwc $$f || exit; done' 55 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 3.13.1 2 | -------------------------------------------------------------------------------- /_zinit: -------------------------------------------------------------------------------- 1 | #compdef zinit 2 | #autoload 3 | # 4 | # Zinit ZSH completion function 5 | # Copyright (c) 2016-2020 Sebastian Gniazdowski 6 | # Copyright (c) 2016-2023 zdharma-continuum 7 | # Homepage: https://github.com/zdharma-continuum/zinit 8 | # License: MIT License 9 | # 10 | 11 | # FUNCTION: __zinit_commands [[[ 12 | __zinit_commands(){ 13 | local -a commands 14 | commands=( 15 | 'add-fpath:Add plugin folder to $FPATH' 16 | 'bindkeys:List of plugin defined key bindings' 17 | 'cclear:Clear completions list' 18 | 'cd:Go to a plugin or snippet direcorty' 19 | 'cdclear:Clear the compdef replay list' 20 | 'cdisable:Disable completions' 21 | 'cdreplay:Replay compdef list' 22 | 'cenable:Enable completions' 23 | 'changes:View plugins git log' 24 | 'compile:Compile plugin (or all plugins if --all passed)' 25 | 'compiled:List of compiled plugins' 26 | 'compinit:Refresh installed completions' 27 | 'completions:List status of all installed completions' 28 | 'create:Generate Zsh plugin boilerplate' 29 | 'creinstall:Install completions for plugin' 30 | 'csearch:Search for available completions from any plugin' 31 | 'cuninstall:Uninstall completions for plugin' 32 | 'debug:Functions for debugging Zinit' 33 | 'delete:Uninstall a plugin or snippet' 34 | 'edit:Edit a plugins or snippet with \$EDITOR' 35 | 'env-whitelist:Specify names (also patterns) of parameters to be left unchanged during an unload' 36 | 'glance:Look at plugins source' 37 | 'help:Usage information' 38 | 'load:Load plugin' 39 | 'man:Display Zinit'\''s manpage' 40 | 'module:Manage binary Zsh module shipped with Zinit' 41 | 'plugins:List status of all installed plugins' 42 | 'recall:Fetch saved ice modifiers and construct ' 43 | 'recently:Show plugins that changed recently' 44 | 'report:Show plugins report' 45 | 'run:Run a command inside plugins folder' 46 | 'self-update:Fetch the newest version of Zinit from GitHub using `git`(1) and recompile' 47 | 'snippet:Source a local or remote file' 48 | 'snippets:List status of all installed snippets' 49 | 'srv:Control a service, command' 50 | 'status:Git status for plugin' 51 | 'stress:Test plugin for compatibility with set of options' 52 | 'times:Display brief statistics for your Zinit installation' 53 | 'uncompile:Remove compiled plugin' 54 | 'uninstall:Uninstall a formula or cask' 55 | 'unload:Unload a plugin or snippet' 56 | 'update:Upgrade outdated plugins and snippets using the same options they were originally installed with' 57 | 'version:Print the version numbers of Zinit to standard output' 58 | 'zstatus:Overall Zinit status' 59 | ) 60 | _describe -t commands 'zinit commands' commands 61 | } # ]]] 62 | ### 63 | # Commands in the debug context 64 | ### 65 | _zinit_debug_commands=( 66 | 'clear:Clear report of debug tracing session' 67 | 'report:Show report of debug tracing session' 68 | 'revert:Revert changes detected during debug tracing session' 69 | 'start:Start debug tracing session' 70 | 'status:Show current state of debug mode' 71 | 'stop:Stop debug tracing session' 72 | ) 73 | # FUNCTION: __zinit_completion_caching_policy [[[ 74 | __zinit_completion_caching_policy(){ 75 | local -a tmp 76 | (( $#tmp )) || return 0 77 | tmp=( $ZINIT[BIN_DIR]/*.git/index(om[1]N) ) 78 | [[ -z $tmp || $tmp -nt $1 ]] 79 | } # ]]] 80 | # FUNCTION: __zinit_installed [[[ 81 | __zinit_installed() { 82 | _alternative \ 83 | 'plugins:installed:__zinit_installed_plugins' \ 84 | 'snippets:installed:__zinit_installed_snippets' 85 | } # ]]] 86 | # FUNCTION: __zinit_installed_plugins [[[ 87 | __zinit_installed_plugins(){ 88 | # [[ -prefix '-' ]] && return 0 89 | typeset -a list 90 | local expl 91 | list=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) ) 92 | list=( "${list[@]//---//}" ) 93 | list=( "${list[@]:#_local/zinit}" ) 94 | list=( "${list[@]:#custom}" ) 95 | _wanted list expl 'plugins' compadd -a - list 96 | } # ]]] 97 | # FUNCTION: __zinit_installed_snippets [[[ 98 | __zinit_installed_snippets(){ 99 | # [[ -prefix '-' ]] && return 0 100 | typeset -a snippets 101 | local expl 102 | snippets=( "${ZINIT[SNIPPETS_DIR]}"/**/._zinit(D/:h) ) 103 | snippets=( ${(Q)snippets[@]#${ZINIT[SNIPPETS_DIR]}/} ) 104 | # formulae=( ${(qq)formulae[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} ) 105 | # formulae=( ${formulae[@]/--//} ) 106 | # 107 | _wanted snippets expl 'snippets' compadd -a - snippets 108 | } # ]]] 109 | # FUNCTION: __zinit_list_aliases [[[ 110 | __zinit_list_aliases(){ 111 | local -a aliases 112 | aliases=( ls list uninstall delete ) 113 | builtin print -- "$aliases" 114 | } # ]]] 115 | 116 | # FUNCTION: _zinit_add_fpath [[[ 117 | _zinit_add_fpath(){ 118 | _arguments -A \ 119 | '(-h --help)'{-h,--help}'[Show this help message]' && ret=0 120 | } # ]]] 121 | # FUNCTION: _zinit_bindkeys [[[ 122 | _zinit_bindkeys(){ 123 | _message 'Hit enter to list the defined key bindings replay' && ret=0 124 | } # ]]] 125 | # FUNCTION: _zinit_cclear [[[ 126 | _zinit_cclear(){ 127 | _arguments -A \ 128 | '(-h --help)'{-h,--help}'[Show this help message]' \ 129 | '(-q --quiet)'{-q,--quiet}'[Turn off messages from the operation]' \ 130 | && ret=0 131 | } # ]]] 132 | # FUNCTION: _zinit_cd [[[ 133 | _zinit_cd(){ 134 | _arguments - plugin '1::plugin:__zinit_installed_plugins' && ret=0 135 | } # ]]] 136 | # FUNCTION: _zinit_cdclear [[[ 137 | _zinit_cdclear(){ 138 | _arguments -A \ 139 | '(-h --help)'{-h,--help}'[Show this help message]' \ 140 | '(-q --quiet)'{-q,--quiet}'[Turn off messages from the operation]' \ 141 | && ret=0 142 | } # ]]] 143 | # FUNCTION: _zinit_cdisable [[[ 144 | _zinit_cdisable(){ 145 | _message 'Press enter to disable completions' && ret=0 146 | } # ]]] 147 | # FUNCTION: _zinit_cdlist [[[ 148 | _zinit_cdlist(){ 149 | _message 'List of compdef replays' && ret=0 150 | } # ]]] 151 | # FUNCTION: _zinit_cdreplay [[[ 152 | _zinit_cdreplay(){ 153 | _arguments -A \ 154 | '(-h --help)'{-h,--help}'[Show this help message]' \ 155 | '(-q --quiet)'{-q,--quiet}'[Turn off messages from the operation]' \ 156 | && ret=0 157 | } # ]]] 158 | # FUNCTION: _zinit_cenable [[[ 159 | _zinit_cenable(){ 160 | _message 'Hit enter to enable completions' && ret=0 161 | } # ]]] 162 | # FUNCTION: _zinit_changes [[[ 163 | _zinit_changes(){ 164 | _message 'View git log of a plugin' && ret=0 165 | } # ]]] 166 | # FUNCTION: _zinit_compiled [[[ 167 | _zinit_compiled(){ 168 | _message 'Hit enter to get list of compiled plugins and snippets' 169 | } # ]]] 170 | # FUNCTION: _zinit_compinit [[[ 171 | _zinit_compinit(){ 172 | _message "Refresh completions" && ret=0 173 | } # ]]] 174 | # FUNCTION: _zinit_completions [[[ 175 | _zinit_completions(){ 176 | _message "Display a list of completions" && ret=0 177 | } # ]]] 178 | # FUNCTION: _zinit_create [[[ 179 | _zinit_compile(){ 180 | _arguments \ 181 | '(-h --help)'{-h,--help}'[Show this help message]' \ 182 | '(-q --quiet)'{-q,--quiet}'[Make some output more quiet]' \ 183 | + '(operation)' \ 184 | '(-a --all)'{-a,--all}'[Compile all plugins]' \ 185 | '*::installed:__zinit_installed' \ 186 | && ret=0 187 | } # ]]] 188 | # FUNCTION: _zinit_create [[[ 189 | _zinit_create(){ 190 | _arguments \ 191 | '1:Plugin Name' && ret=0 192 | } # ]]] 193 | # FUNCTION: _zinit_creinstall [[[ 194 | _zinit_creinstall(){ 195 | _arguments - plugin '1::plugin:__zinit_installed_plugins' && ret=0 196 | } # ]]] 197 | # FUNCTION: _zinit_csearch [[[ 198 | _zinit_csearch(){ 199 | ret=0 200 | } # ]]] 201 | # FUNCTION: _zinit_cunistall [[[ 202 | _zinit_cunistall(){ 203 | _arguments - installed '*::installed:__zinit_installed' && ret=0 204 | } # ]]] 205 | # FUNCTION: _zinit_delete [[[ 206 | _zinit_delete(){ 207 | _arguments \ 208 | {-d,--debug}'[Enable xtrace]' \ 209 | {-h,--help}'[Show this help message]' \ 210 | {-q,--quiet}'[Make some output more quiet]' \ 211 | {-y,--yes}'[Automatically confirm any yes/no prompts]' \ 212 | + '(operation)' \ 213 | '*::installed:__zinit_installed' \ 214 | {-a,--all}'[Delete all plugins and snippets]' \ 215 | {-c,--clean}'[Delete only the currently-not loaded plugins and snippets]' \ 216 | && ret=0 217 | } # ]]] 218 | _zinit_debug(){ 219 | _arguments \ 220 | '1: :_zinit_debug_cmds' 221 | } # ]]] 222 | # FUNCTION: _zinit_edit [[[ 223 | _zinit_edit(){ 224 | _arguments \ 225 | - installed '*::plugin:__zinit_installed_plugins' \ 226 | - snippet '*::snippet:__zinit_installed_snippets' && ret=0 227 | } # ]]] 228 | # FUNCTION: _zinit_env_whitelist [[[ 229 | _zinit_env_whitelist(){ 230 | _arguments -A \ 231 | '(-h --help)'{-h,--help}'[Show this help message]' \ 232 | '(-v --verbose)'{-v,--verbose}'[Make some output more verbose]' \ 233 | && ret=0 234 | } # ]]] 235 | # FUNCTION: _zinit_glance [[[ 236 | _zinit_glance(){ 237 | _arguments - installed '1:installed:__zinit_installed' && ret=0 238 | } # ]]] 239 | # FUNCTION: _zinit_list [[[ 240 | _zinit_list(){ 241 | _message 'Hit enter to list the defined key bindings replay' && ret=0 242 | } # ]]] 243 | # FUNCTION: _zinit_loaded [[[ 244 | _zinit_loaded(){ 245 | _message 'Hit enter to list the defined key bindings replay' && ret=0 246 | } # ]]] 247 | # FUNCTION: _zinit_man [[[ 248 | _zinit_man(){ 249 | _message "Hit enter to view the Zinit man page" && ret=0 250 | } # ]]] 251 | # FUNCTION: _zinit_module [[[ 252 | _zinit_module(){ 253 | _arguments \ 254 | - subcommand '*::subcommand:(build help info)' && ret=0 255 | } # ]]] 256 | # FUNCTION: _zinit_recall [[[ 257 | _zinit_recall(){ 258 | _message 'Hit enter to list the defined key bindings replay' && ret=0 259 | } # ]]] 260 | # FUNCTION: _zinit_recently [[[ 261 | _zinit_recently(){ 262 | ret=0 263 | } # ]]] 264 | # FUNCTION: _zinit_report [[[ 265 | _zinit_report(){ 266 | _message 'Hit enter to list the defined key bindings replay' && ret=0 267 | } # ]]] 268 | # FUNCTION: _zinit_run [[[ 269 | _zinit_run(){ 270 | _arguments \ 271 | - installed '1:installed:__zinit_installed' \ 272 | '2:command to run:' && ret=0 273 | } # ]]] 274 | # FUNCTION: _zinit_self_update [[[ 275 | _zinit_self_update(){ 276 | } # ]]] 277 | # FUNCTION: _zinit_snippet [[[ 278 | _zinit_snippet(){ 279 | _arguments -A \ 280 | '(-c --command)'{-c,--command}'[Load the snippet as a command (i.e., make executable and apend to $PATH])' \ 281 | '(-f --force)'{-f,--force}'[Force new download of the snippet file]' \ 282 | '(-h --help)'{-h,--help}'[Show this help message]' 283 | _arguments - snippet '*::snippet:__zinit_installed_snippets' && ret=0 284 | } # ]]] 285 | # FUNCTION: _zinit_status [[[ 286 | _zinit_status(){ 287 | _message 'Display current status of Zinit' && ret=0 288 | } # ]]] 289 | # FUNCTION: _zinit_stress [[[ 290 | _zinit_stress(){ 291 | _message 'Stress' && ret=0 292 | } # ]]] 293 | # FUNCTION: _zinit_times [[[ 294 | _zinit_times(){ 295 | _arguments \ 296 | '--help[Show this help message]' \ 297 | + '(operation)' \ 298 | '(-a --all)'{-a,--all}'[show both load times and loading moments]' \ 299 | '(-m --moments)'{-m,--moments}'[Display loading moments]' \ 300 | '(-s --seconds)'{-s,--seconds}'[Load times displayed in seconds]' \ 301 | && ret=0 302 | } # ]]] 303 | # FUNCTION: _zinit_uncompile [[[ 304 | _zinit_uncompile(){ 305 | _arguments \ 306 | '(-h --help)'{-h,--help}'[Show this help message]' \ 307 | '(-q --quiet)'{-q,--quiet}'[Make some output more quiet]' \ 308 | + '(operation)' \ 309 | '(-a --all)'{-a,--all}'[Uncompile all plugins]' \ 310 | '*::installed:__zinit_installed' \ 311 | && ret=0 312 | } # ]]] 313 | # FUNCTION: _zinit_unload [[[ 314 | _zinit_unload(){ 315 | _arguments -A \ 316 | '(-h --help)'{-h,--help}'[Show this help message]' \ 317 | '(-q --quiet)'{-q,--quiet}'[Turn off messages from the operation]' \ 318 | - installed '*:installed:__zinit_installed' 319 | } # ]]] 320 | # FUNCTION: _zinit_update [[[ 321 | _zinit_update(){ 322 | _arguments \ 323 | '(-h --help)'{-h,--help}'[Show this help message]' \ 324 | '(-n --no-pager)'{-n,--no-pager}'[Disable the use of the pager]' \ 325 | '(-q --quiet)'{-q,--quiet}'[Turn off almost-all messages from the update operation FOR the objects which don'\''t have any new version available]' \ 326 | '(-r --reset)'{-r,--reset}'[Reset the repository before updating (or remove the files for single-file snippets and gh-r plugins)]' \ 327 | '(-s --snippets)'{-s,--snippets}'[Update only snippets (i.e.: skip updating plugins)]' \ 328 | '(-u --urge)'{-u,--urge}'[Cause all the hooks like: atpull'\'\'', cp'\'\'', etc. to execute even when there aren'\''t any new commits / any new version of the gh-r file / etc.… available for download↔ simulate a non-empty update]' \ 329 | '(-v --verbose)'{-v,--verbose}'[Turn on more messages from the operation]' \ 330 | - set1 \ 331 | '(-p --parallel)'{-p,--parallel}'[Turn on concurrent, multi-thread update (of all objects)]' \ 332 | '(-a --all)'{-a,--all}'[Update all plugins and snippets]' \ 333 | - set2 \ 334 | '1:installed:__zinit_installed' 335 | } # ]]] 336 | # FUNCTION: _zunit_load [[[ 337 | _zinit_load() { 338 | _message 'Hit enter to list the defined key bindings replay' && ret=0 339 | } # ]]] 340 | 341 | # FUNCTION: _zinit [[[ 342 | _zinit(){ 343 | local curcontext="$curcontext" state state_descr line expl 344 | local tmp ret=1 345 | _arguments -A \ 346 | '(-h --help)'{-h,--help}'[Show this help message]' 347 | _arguments -C \ 348 | "1: :->cmds" \ 349 | "*::arg:->args" 350 | case "$state" in 351 | cmds) 352 | __zinit_commands && return 0 353 | ;; 354 | args) 355 | local cmd="${line[1]}" 356 | curcontext="${curcontext%:*}-${cmd}:${curcontext##*:}" 357 | local completion_func="_zinit_${cmd//-/_}" 358 | _call_function ret "${completion_func}" && return ret 359 | _message "a completion function is not defined for command or alias: ${cmd}" 360 | return 1 361 | ;; 362 | esac 363 | } # ]]] 364 | 365 | (( $+functions[_zinit_debug_cmds] )) || _zinit_debug_cmds() { 366 | _describe -t commands 'commands' _zinit_debug_commands "$@" 367 | } 368 | 369 | _zinit "$@" 370 | 371 | #vim: filetype=zsh foldmarker=[[[,]]] foldmethod=marker shiftwidth=2 softtabstop=2 tabstop=2: 372 | -------------------------------------------------------------------------------- /doc/HACKING.md: -------------------------------------------------------------------------------- 1 | # HACKING.md 2 | 3 | ## Documentation 4 | 5 | ### README: Update the table of content 6 | 7 | 1. Install [doctoc](https://github.com/thlorenz/doctoc) 8 | 2. To update the TOC run the following command: 9 | 10 | ```zsh 11 | doctoc --github README.md 12 | ``` 13 | 14 | ### Update asciidoc and/or zshelldoc 15 | 16 | 1. Make sure you have [docker](https://www.docker.com/) or [podman](https://podman.io/) installed. 17 | 2. From the root of the repo, run: 18 | 19 | ```zsh 20 | make doc-container 21 | ``` 22 | 23 | If for some reason you want to build the zshelldocs or the PDF manually, you'll need: 24 | 25 | 1. Patience, zsd is very finicky about locales. You have been warned. 26 | 2. [zshelldoc (zsd)](https://github.com/zdharma-continuum/zshelldoc) 27 | 3. [asciidoc](https://asciidoc.org/) 28 | 4. `make doc` 29 | 30 | ### Generate the manpage (doc/zinit.1) 31 | 32 | 1. Install [pandoc](https://pandoc.org/) 33 | 2. From the root of the repo run: 34 | 35 | ```zsh 36 | pandoc --standalone --to man README.md -o doc/zinit.1 37 | ``` 38 | 39 | ### Updating the gh-pages (zdharma-continuum.github.io) 40 | 41 | 1. Check out the [documentation branch](https://github.com/zdharma-continuum/zinit/tree/documentation) 42 | 43 | ```shell 44 | git fetch origin documentation 45 | git checkout documentation 46 | ``` 47 | 48 | 2. Do your modifications and push your changes 49 | 3. Keep an eye on [the CI logs](https://github.com/zdharma-continuum/zinit/actions/workflows/gh-pages.yaml) 50 | 4. If all went well you can head to https://zdharma-continuum.github.io/ to see your changes live. 51 | 52 | **NOTE:** If you really **need** to push directly, without CI please refer to \[the README in the 53 | documentation\]https://github.com/zdharma-continuum/zinit/blob/documentation/README.md 54 | 55 | ## Testing 56 | 57 | We run our tests with [zunit](https://zunit.xyz). 58 | 59 | To add a new test case: 60 | 61 | 1. Install [zunit](https://zunit.xyz) and [revolver](https://github.com/molovo/revolver): 62 | 63 | ```zsh 64 | zinit for \ 65 | as"program" \ 66 | atclone"ln -sfv revolver.zsh-completion _revolver" \ 67 | atpull"%atclone" \ 68 | pick"revolver" \ 69 | @molovo/revolver \ 70 | as"completion" \ 71 | atclone"./build.zsh; ln -sfv zunit.zsh-completion _zunit" \ 72 | atpull"%atclone" \ 73 | sbin"zunit" \ 74 | @zunit-zsh/zunit 75 | ``` 76 | 77 | 2. Create a new `.zunit` file in the `tests/` dir. Here's a template: 78 | 79 | ```zsh 80 | #!/usr/bin/env zunit 81 | 82 | @setup { 83 | load setup 84 | setup 85 | } 86 | 87 | @teardown { 88 | load teardown 89 | teardown 90 | } 91 | 92 | @test 'zinit-annex-bin-gem-node installation' { 93 | # This spawns the official zinit container, and executes a single zinit command 94 | # inside it 95 | run ./scripts/docker-run.sh --wrap --debug --zunit \ 96 | zinit light as"null" for zdharma-continuum/null 97 | 98 | # Verify exit code of the command above 99 | assert $state equals 0 100 | assert "$output" contains "Downloading" 101 | 102 | local artifact="${PLUGINS_DIR}/zdharma-continuum---null/readme.md" 103 | # Check if we downloaded the file correctly and if it is readable 104 | assert "$artifact" is_file 105 | assert "$artifact" is_readable 106 | } 107 | ``` 108 | 109 | You should of course also check out the existing tests ;) 110 | 111 | 3. To run your new test: 112 | 113 | ```zsh 114 | zunit --verbose tests/your_test.zunit 115 | ``` 116 | 117 | ### Debugging tests 118 | 119 | If you ever need to inspect the `ZINIT[HOME_DIR]` dir, where zinit's internal data is stored you can do so by commenting 120 | out the `@teardown` section in your test. Then you can re-run said test and head over to `${TMPDIR:-/tmp}/zunit-zinit`. 121 | Good luck! 122 | 123 | ## Misc 124 | 125 | ### Get the list of supported ices 126 | 127 | To get the list in a quick-and-dirty fashion you issue: 128 | 129 | ```zsh 130 | zinit --help | tail -1 131 | ``` 132 | 133 | See 134 | [zinit-autoload.zsh](https://github.com/zdharma-continuum/zinit/blob/2feb41cf70d2f782386bbaa6fda691e3bdc7f1ac/zinit-autoload.zsh#L3445-L3447) 135 | for implementation details. 136 | -------------------------------------------------------------------------------- /doc/img/m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zdharma-continuum/zinit/9a3e5c97975accfdde54e4a5810150212a41b898/doc/img/m.png -------------------------------------------------------------------------------- /doc/img/update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zdharma-continuum/zinit/9a3e5c97975accfdde54e4a5810150212a41b898/doc/img/update.png -------------------------------------------------------------------------------- /doc/img/zplugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zdharma-continuum/zinit/9a3e5c97975accfdde54e4a5810150212a41b898/doc/img/zplugin.png -------------------------------------------------------------------------------- /doc/img/zplugin.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 41 | 43 | 50 | 57 | 64 | 65 | 67 | 68 | 70 | image/svg+xml 71 | 73 | 74 | 75 | 76 | 77 | 81 | 88 | 95 | 102 | 109 | 116 | 123 | 130 | 131 | 135 | 140 | 141 | 145 | 150 | 155 | 160 | 161 | 165 | 170 | 175 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /doc/img/zplugin_refcard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zdharma-continuum/zinit/9a3e5c97975accfdde54e4a5810150212a41b898/doc/img/zplugin_refcard.png -------------------------------------------------------------------------------- /doc/zsdoc/Makefile: -------------------------------------------------------------------------------- 1 | # This Makefile is to convert supplied Asciidoc files into 2 | # other formats like pdf and man. The files contain Zplugin's 3 | # code documentation. 4 | # 5 | # *.adoc files are generated by Makefile from upper (i.e. top) 6 | # directory. 7 | 8 | all: man pdf 9 | 10 | # MANUALS 11 | # Converted with a2x from asciidoc package 12 | 13 | man: man/zinit.zsh.1 man/zinit-side.zsh.1 man/zinit-install.zsh.1 man/zinit-autoload.zsh.1 14 | 15 | man/zinit.zsh.1: 16 | @mkdir -p man 17 | a2x --verbose -L --doctype manpage --format manpage -D man zinit.zsh.adoc 18 | 19 | man/zinit-side.zsh.1: 20 | @mkdir -p man 21 | a2x --verbose -L --doctype manpage --format manpage -D man zinit-side.zsh.adoc 22 | 23 | man/zinit-install.zsh.1: 24 | @mkdir -p man 25 | a2x --verbose -L --doctype manpage --format manpage -D man zinit-install.zsh.adoc 26 | 27 | man/zinit-autoload.zsh.1: 28 | @mkdir -p man 29 | a2x --verbose -L --doctype manpage --format manpage -D man zinit-autoload.zsh.adoc 30 | 31 | # PDFS 32 | # Uses asciidoctor not a2x (i.e. not asciidoc) 33 | 34 | pdf: pdf/zinit.zsh.pdf pdf/zinit-side.zsh.pdf pdf/zinit-install.zsh.pdf pdf/zinit-autoload.zsh.pdf 35 | 36 | pdf/zinit.zsh.pdf: 37 | @mkdir -p pdf 38 | asciidoctor -a reproducible -b pdf -r asciidoctor-pdf -D pdf zinit.zsh.adoc 39 | 40 | pdf/zinit-side.zsh.pdf: 41 | @mkdir -p pdf 42 | asciidoctor -a reproducible -b pdf -r asciidoctor-pdf -D pdf zinit-side.zsh.adoc 43 | 44 | pdf/zinit-install.zsh.pdf: 45 | @mkdir -p pdf 46 | asciidoctor -a reproducible -b pdf -r asciidoctor-pdf -D pdf zinit-install.zsh.adoc 47 | 48 | pdf/zinit-autoload.zsh.pdf: 49 | @mkdir -p pdf 50 | asciidoctor -a reproducible -b pdf -r asciidoctor-pdf -D pdf zinit-autoload.zsh.adoc 51 | 52 | clean: 53 | rm -rf man pdf data 54 | 55 | .PHONY: man pdf clean 56 | 57 | # vim:noet:sts=8:ts=8 58 | -------------------------------------------------------------------------------- /doc/zsdoc/README.md: -------------------------------------------------------------------------------- 1 | # Code documentation 2 | 3 | Here is `Asciidoc` code documentation generated using [Zshelldoc](https://github.com/zdharma-continuum/zshelldoc). There 4 | are `4` Zinit's source files, the main one is [zinit.zsh](zinit.zsh.adoc). The documentation lists all functions, 5 | interactions between them, their comments and features used. 6 | 7 | Github allows to directly view `Asciidoc` documents: 8 | 9 | - [zinit.zsh](zinit.zsh.adoc) – always loaded, in `.zshrc` 10 | ([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit.zsh)) 11 | - [zinit-side.zsh](zinit-side.zsh.adoc) – common functions, loaded by `*-install` and `*-autoload` scripts 12 | ([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit-side.zsh)) 13 | - [zinit-install.zsh](zinit-install.zsh.adoc) – functions used only when installing a plugin or snippet 14 | ([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit-install.zsh)) 15 | - [zinit-autoload.zsh](zinit-autoload.zsh.adoc) – functions used only in interactive `Zinit` invocations 16 | ([pdf](https://zdharma-continuum.github.io/zinit/wiki/zinit-autoload.zsh/)) 17 | 18 | # PDFs, man pages, etc. 19 | 20 | Formats other than `Asciidoc` can be produced by using provided Makefile. For example, issuing `make pdf` will create 21 | and populate a new directory `pdf` (requires `asciidoctor`, install with `gem install asciidoctor-pdf --pre`). 22 | `make man` will create man pages (requires package `asciidoc`, uses its command `a2x`, which is quite slow). 23 | -------------------------------------------------------------------------------- /doc/zsdoc/zinit-additional.zsh.adoc: -------------------------------------------------------------------------------- 1 | 2 | NAME 3 | 4 | zinit-additional.zsh - a shell script 5 | 6 | Documentation automatically generated with `zshelldoc' 7 | 8 | == FUNCTIONS 9 | +zinit-debug 10 | .zinit-debug-clear 11 | .zinit-debug-report 12 | .zinit-debug-revert 13 | .zinit-debug-start 14 | .zinit-debug-status 15 | .zinit-debug-stop 16 | .zinit-service 17 | .zinit-wrap-track-functions 18 | :zinit-tmp-subst-source 19 | 20 | === DETAILS 21 | 22 | ==== Script Body 23 | 24 | Has 1 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.). 25 | 26 | ==== +zinit-debug 27 | 28 | ____ 29 | 30 | Debug command entry point 31 | 32 | ____ 33 | 34 | Has 35 line(s). Doesn't call other functions. 35 | 36 | Uses feature(s): _setopt_, _zmodload_, _zparseopts_ 37 | 38 | Called by: 39 | 40 | zinit.zsh/zinit 41 | 42 | ==== .zinit-debug-clear 43 | 44 | ____ 45 | 46 | Clear latest debug report 47 | 48 | ____ 49 | 50 | Has 7 line(s). Calls functions: 51 | 52 | .zinit-debug-clear 53 | |-- zinit-autoload.zsh/.zinit-clear-report-for 54 | `-- zinit.zsh/+zi-log 55 | 56 | Called by: 57 | 58 | zinit-autoload.zsh/.zinit-unload 59 | 60 | ==== .zinit-debug-report 61 | 62 | ____ 63 | 64 | Displays debug report (data recorded in interactive session). 65 | 66 | ____ 67 | 68 | Has 6 line(s). Calls functions: 69 | 70 | .zinit-debug-report 71 | |-- zinit-autoload.zsh/.zinit-show-report 72 | `-- zinit.zsh/+zi-log 73 | 74 | Uses feature(s): _source_ 75 | 76 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 77 | 78 | ==== .zinit-debug-revert 79 | 80 | ____ 81 | 82 | Revert changes made during debug mode 83 | 84 | ____ 85 | 86 | Has 7 line(s). Calls functions: 87 | 88 | .zinit-debug-revert 89 | |-- zinit-autoload.zsh/.zinit-unload 90 | `-- zinit.zsh/+zi-log 91 | 92 | Uses feature(s): _source_ 93 | 94 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 95 | 96 | ==== .zinit-debug-start 97 | 98 | ____ 99 | 100 | Start debug mode 101 | 102 | ____ 103 | 104 | Has 13 line(s). Calls functions: 105 | 106 | .zinit-debug-start 107 | |-- zinit.zsh/+zi-log 108 | |-- zinit.zsh/.zinit-diff 109 | `-- zinit.zsh/.zinit-tmp-subst-on 110 | 111 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 112 | 113 | ==== .zinit-debug-status 114 | 115 | ____ 116 | 117 | Revert changes made during debug mode 118 | 119 | ____ 120 | 121 | Has 2 line(s). Calls functions: 122 | 123 | .zinit-debug-status 124 | `-- zinit.zsh/+zi-log 125 | 126 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 127 | 128 | ==== .zinit-debug-stop 129 | 130 | ____ 131 | 132 | Stop debug mode 133 | 134 | ____ 135 | 136 | Has 14 line(s). Calls functions: 137 | 138 | .zinit-debug-stop 139 | |-- zinit.zsh/+zi-log 140 | |-- zinit.zsh/.zinit-diff 141 | `-- zinit.zsh/.zinit-tmp-subst-off 142 | 143 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 144 | 145 | ==== .zinit-service 146 | 147 | ____ 148 | 149 | Handles given service, i.e. obtains lock, runs it, or waits if no lock 150 | 151 | $1 - type "p" or "s" (plugin or snippet) 152 | $2 - mode - for plugin (light or load) 153 | $3 - id - URL or plugin ID or alias name (from id-as'') 154 | 155 | ____ 156 | 157 | Has 37 line(s). Calls functions: 158 | 159 | .zinit-service 160 | |-- zinit.zsh/.zinit-load 161 | `-- zinit.zsh/.zinit-load-snippet 162 | 163 | Uses feature(s): _kill_, _read_, _setopt_ 164 | 165 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 166 | 167 | ==== .zinit-wrap-track-functions 168 | 169 | Has 19 line(s). Doesn't call other functions. 170 | 171 | Uses feature(s): _eval_ 172 | 173 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 174 | 175 | ==== :zinit-tmp-subst-source 176 | 177 | Has 25 line(s). Calls functions: 178 | 179 | :zinit-tmp-subst-source 180 | `-- zinit.zsh/+zi-log 181 | 182 | Uses feature(s): _eval_ 183 | 184 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 185 | 186 | -------------------------------------------------------------------------------- /doc/zsdoc/zinit-install.zsh.adoc: -------------------------------------------------------------------------------- 1 | 2 | NAME 3 | 4 | zinit-install.zsh - a shell script 5 | 6 | Documentation automatically generated with `zshelldoc' 7 | 8 | == FUNCTIONS 9 | +zinit-cmake-hook 10 | .zi::get-architecture 11 | .zinit-at-eval 12 | .zinit-compinit 13 | .zinit-download-file-stdout 14 | .zinit-download-snippet 15 | .zinit-extract 16 | .zinit-forget-completion 17 | .zinit-get-cygwin-package 18 | .zinit-get-latest-gh-r-url-part 19 | .zinit-get-package 20 | .zinit-get-url-mtime 21 | .zinit-install-completions 22 | .zinit-jq-check 23 | .zinit-json-get-value 24 | .zinit-json-to-array 25 | .zinit-mirror-using-svn 26 | .zinit-setup-plugin-dir 27 | .zinit-single-line 28 | .zinit-update-snippet 29 | __zinit-cmake-base-hook 30 | zicp 31 | ziextract 32 | zimv 33 | ∞zinit-atclone-hook 34 | ∞zinit-atpull-e-hook 35 | ∞zinit-atpull-hook 36 | ∞zinit-compile-plugin-hook 37 | ∞zinit-configure-base-hook 38 | ∞zinit-configure-e-hook 39 | ∞zinit-configure-hook 40 | ∞zinit-cp-hook 41 | ∞zinit-extract-hook 42 | ∞zinit-file-cp-mv-operation 43 | ∞zinit-make-base-hook 44 | ∞zinit-make-e-hook 45 | ∞zinit-make-ee-hook 46 | ∞zinit-make-hook 47 | ∞zinit-mv-hook 48 | ∞zinit-ps-on-update-hook 49 | ∞zinit-reset-hook 50 | AUTOLOAD compinit 51 | 52 | === DETAILS 53 | 54 | ==== Script Body 55 | 56 | Has 6 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.). 57 | 58 | Uses feature(s): _source_ 59 | 60 | ==== +zinit-cmake-hook 61 | 62 | Has 1 line(s). Calls functions: 63 | 64 | +zinit-cmake-hook 65 | `-- __zinit-cmake-base-hook 66 | `-- zinit.zsh/+zi-log 67 | 68 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 69 | 70 | ==== .zi::get-architecture 71 | 72 | Has 39 line(s). Calls functions: 73 | 74 | .zi::get-architecture 75 | `-- zinit.zsh/+zi-log 76 | 77 | Uses feature(s): _setopt_ 78 | 79 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 80 | 81 | ==== .zinit-at-eval 82 | 83 | Has 9 line(s). Calls functions: 84 | 85 | .zinit-at-eval 86 | `-- zinit.zsh/@zinit-substitute 87 | 88 | Uses feature(s): _eval_ 89 | 90 | Called by: 91 | 92 | ∞zinit-atpull-e-hook 93 | ∞zinit-atpull-hook 94 | 95 | ==== .zinit-compinit 96 | 97 | ____ 98 | 99 | User-exposed `compinit' frontend which first ensures that all 100 | completions managed by Zinit are forgotten by Zshell. After 101 | that it runs normal `compinit', which should more easily detect 102 | Zinit's completions. 103 | 104 | No arguments. 105 | 106 | ____ 107 | 108 | Has 26 line(s). Calls functions: 109 | 110 | .zinit-compinit 111 | |-- .zinit-forget-completion 112 | |-- compinit 113 | `-- zinit.zsh/+zi-log 114 | 115 | Uses feature(s): _autoload_, _compinit_, _setopt_, _unfunction_ 116 | 117 | Called by: 118 | 119 | .zinit-install-completions 120 | zinit-autoload.zsh/.zinit-uninstall-completions 121 | zinit-autoload.zsh/.zinit-update-or-status-all 122 | zinit.zsh/.zinit-prepare-home 123 | zinit.zsh/zinit 124 | 125 | ==== .zinit-download-file-stdout 126 | 127 | ____ 128 | 129 | Downloads file to stdout. Supports following backend commands: 130 | curl, wget, lftp, lynx. Used by snippet loading. 131 | 132 | ____ 133 | 134 | Has 53 line(s). Calls functions: 135 | 136 | .zinit-download-file-stdout 137 | `-- zinit.zsh/+zi-log 138 | 139 | Uses feature(s): _setopt_, _trap_, _type_ 140 | 141 | Called by: 142 | 143 | .zinit-download-snippet 144 | .zinit-get-cygwin-package 145 | .zinit-get-package 146 | .zinit-setup-plugin-dir 147 | 148 | ==== .zinit-download-snippet 149 | 150 | ____ 151 | 152 | Downloads snippet 153 | file – with curl, wget, lftp or lynx, 154 | directory, with Subversion – when svn-ICE is active. 155 | 156 | Github supports Subversion protocol and allows to clone subdirectories. 157 | This is used to provide a layer of support for Oh-My-Zsh and Prezto. 158 | 159 | ____ 160 | 161 | Has 377 line(s). Calls functions: 162 | 163 | .zinit-download-snippet 164 | |-- .zinit-download-file-stdout 165 | |   `-- zinit.zsh/+zi-log 166 | |-- .zinit-get-url-mtime 167 | |-- .zinit-install-completions 168 | |   |-- .zinit-compinit 169 | |   |   |-- .zinit-forget-completion 170 | |   |   |-- compinit 171 | |   |   `-- zinit.zsh/+zi-log 172 | |   |-- .zinit-forget-completion 173 | |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 174 | |   |-- zinit-side.zsh/.zinit-exists-physically-message 175 | |   |-- zinit.zsh/+zi-log 176 | |   `-- zinit.zsh/.zinit-any-to-user-plugin 177 | |-- .zinit-mirror-using-svn 178 | |-- zinit-side.zsh/.zinit-store-ices 179 | |-- zinit.zsh/+zi-log 180 | `-- zinit.zsh/is-at-least 181 | 182 | Uses feature(s): _is-at-least_, _setopt_, _trap_, _zcompile_ 183 | 184 | Called by: 185 | 186 | .zinit-update-snippet 187 | zinit.zsh/.zinit-load-snippet 188 | 189 | ==== .zinit-extract 190 | 191 | Has 30 line(s). Calls functions: 192 | 193 | .zinit-extract 194 | |-- ziextract 195 | |   `-- zinit.zsh/+zi-log 196 | `-- zinit.zsh/+zi-log 197 | 198 | Uses feature(s): _setopt_ 199 | 200 | Called by: 201 | 202 | ∞zinit-extract-hook 203 | 204 | ==== .zinit-forget-completion 205 | 206 | ____ 207 | 208 | Implements alternation of Zsh state so that already initialized 209 | completion stops being visible to Zsh. 210 | 211 | $1 - completion function name, e.g. "_cp"; can also be "cp" 212 | 213 | ____ 214 | 215 | Has 20 line(s). Doesn't call other functions. 216 | 217 | Uses feature(s): _setopt_, _unfunction_ 218 | 219 | Called by: 220 | 221 | .zinit-compinit 222 | .zinit-install-completions 223 | zinit-autoload.zsh/.zinit-uninstall-completions 224 | zinit.zsh/zinit 225 | 226 | ==== .zinit-get-cygwin-package 227 | 228 | Has 70 line(s). Calls functions: 229 | 230 | .zinit-get-cygwin-package 231 | |-- .zinit-download-file-stdout 232 | |   `-- zinit.zsh/+zi-log 233 | `-- zinit.zsh/+zi-log 234 | 235 | Uses feature(s): _setopt_ 236 | 237 | Called by: 238 | 239 | .zinit-setup-plugin-dir 240 | 241 | ==== .zinit-get-latest-gh-r-url-part 242 | 243 | ____ 244 | 245 | Gets version string of latest release of given Github 246 | package. Connects to Github releases page. 247 | 248 | ____ 249 | 250 | Has 55 line(s). Calls functions: 251 | 252 | .zinit-get-latest-gh-r-url-part 253 | `-- zinit.zsh/+zi-log 254 | 255 | Uses feature(s): _setopt_ 256 | 257 | Called by: 258 | 259 | .zinit-setup-plugin-dir 260 | zinit-autoload.zsh/.zinit-update-or-status 261 | 262 | ==== .zinit-get-package 263 | 264 | Has 195 line(s). Calls functions: 265 | 266 | .zinit-get-package 267 | |-- .zinit-download-file-stdout 268 | |   `-- zinit.zsh/+zi-log 269 | |-- .zinit-jq-check 270 | |   `-- zinit.zsh/+zi-log 271 | |-- .zinit-json-to-array 272 | |   `-- .zinit-jq-check 273 | |   `-- zinit.zsh/+zi-log 274 | |-- ziextract 275 | |   `-- zinit.zsh/+zi-log 276 | |-- zinit.zsh/+zi-log 277 | `-- zinit.zsh/@zinit-substitute 278 | 279 | Uses feature(s): _eval_, _setopt_, _trap_ 280 | 281 | Called by: 282 | 283 | zinit.zsh/.zinit-load 284 | 285 | ==== .zinit-get-url-mtime 286 | 287 | ____ 288 | 289 | For the given URL returns the date in the Last-Modified 290 | header as a time stamp 291 | 292 | ____ 293 | 294 | Has 35 line(s). Doesn't call other functions. 295 | 296 | Uses feature(s): _read_, _setopt_, _trap_, _type_ 297 | 298 | Called by: 299 | 300 | .zinit-download-snippet 301 | 302 | ==== .zinit-install-completions 303 | 304 | ____ 305 | 306 | Installs all completions of given plugin. After that they are visible to 307 | 'compinit'. Visible completions can be selectively disabled and enabled. User 308 | can access completion data with 'completions' subcommand. 309 | 310 | $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) 311 | $2 - plugin if $1 (i.e., user) given 312 | $3 - if 1, then reinstall, otherwise only install completions that are not present 313 | 314 | ____ 315 | 316 | Has 62 line(s). Calls functions: 317 | 318 | .zinit-install-completions 319 | |-- .zinit-compinit 320 | |   |-- .zinit-forget-completion 321 | |   |-- compinit 322 | |   `-- zinit.zsh/+zi-log 323 | |-- .zinit-forget-completion 324 | |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 325 | |-- zinit-side.zsh/.zinit-exists-physically-message 326 | |-- zinit.zsh/+zi-log 327 | `-- zinit.zsh/.zinit-any-to-user-plugin 328 | 329 | Uses feature(s): _setopt_ 330 | 331 | Called by: 332 | 333 | .zinit-download-snippet 334 | .zinit-setup-plugin-dir 335 | zinit.zsh/zinit 336 | 337 | ==== .zinit-jq-check 338 | 339 | ____ 340 | 341 | Check if jq is available and outputs an error message with instructions if 342 | that's not the case 343 | 344 | ____ 345 | 346 | Has 8 line(s). Calls functions: 347 | 348 | .zinit-jq-check 349 | `-- zinit.zsh/+zi-log 350 | 351 | Called by: 352 | 353 | .zinit-get-package 354 | .zinit-json-get-value 355 | .zinit-json-to-array 356 | 357 | ==== .zinit-json-get-value 358 | 359 | ____ 360 | 361 | Wrapper around jq that return the value of a property 362 | 363 | $1: JSON structure 364 | $2: jq path 365 | 366 | ____ 367 | 368 | Has 4 line(s). Calls functions: 369 | 370 | .zinit-json-get-value 371 | `-- .zinit-jq-check 372 | `-- zinit.zsh/+zi-log 373 | 374 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 375 | 376 | ==== .zinit-json-to-array 377 | 378 | ____ 379 | 380 | Wrapper around jq that sets key/values of an associative array, replicating 381 | the structure of a given JSON object 382 | 383 | $1: JSON structure 384 | $2: jq path 385 | $3: name of the associative array to store the key/value pairs in 386 | 387 | ____ 388 | 389 | Has 13 line(s). Calls functions: 390 | 391 | .zinit-json-to-array 392 | `-- .zinit-jq-check 393 | `-- zinit.zsh/+zi-log 394 | 395 | Uses feature(s): _eval_, _setopt_ 396 | 397 | Called by: 398 | 399 | .zinit-get-package 400 | 401 | ==== .zinit-mirror-using-svn 402 | 403 | ____ 404 | 405 | Used to clone subdirectories from Github. If in update mode 406 | (see $2), then invokes `svn update', in normal mode invokes 407 | `svn checkout --non-interactive -q '. In test mode only 408 | compares remote and local revision and outputs true if update 409 | is needed. 410 | 411 | $1 - URL 412 | $2 - mode, "" - normal, "-u" - update, "-t" - test 413 | $3 - subdirectory (not path) with working copy, needed for -t and -u 414 | 415 | ____ 416 | 417 | Has 29 line(s). Doesn't call other functions. 418 | 419 | Uses feature(s): _setopt_ 420 | 421 | Called by: 422 | 423 | .zinit-download-snippet 424 | 425 | ==== .zinit-setup-plugin-dir 426 | 427 | ____ 428 | 429 | Clones given plugin into PLUGIN_DIR. Supports multiple 430 | sites (respecting `from' and `proto' ice modifiers). 431 | Invokes compilation of plugin's main file. 432 | 433 | $1 - user 434 | $2 - plugin 435 | 436 | ____ 437 | 438 | Has 213 line(s). Calls functions: 439 | 440 | .zinit-setup-plugin-dir 441 | |-- .zinit-download-file-stdout 442 | |   `-- zinit.zsh/+zi-log 443 | |-- .zinit-get-cygwin-package 444 | |   |-- .zinit-download-file-stdout 445 | |   |   `-- zinit.zsh/+zi-log 446 | |   `-- zinit.zsh/+zi-log 447 | |-- .zinit-get-latest-gh-r-url-part 448 | |   `-- zinit.zsh/+zi-log 449 | |-- .zinit-install-completions 450 | |   |-- .zinit-compinit 451 | |   |   |-- .zinit-forget-completion 452 | |   |   |-- compinit 453 | |   |   `-- zinit.zsh/+zi-log 454 | |   |-- .zinit-forget-completion 455 | |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 456 | |   |-- zinit-side.zsh/.zinit-exists-physically-message 457 | |   |-- zinit.zsh/+zi-log 458 | |   `-- zinit.zsh/.zinit-any-to-user-plugin 459 | |-- ziextract 460 | |   `-- zinit.zsh/+zi-log 461 | |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 462 | |-- zinit-side.zsh/.zinit-store-ices 463 | |-- zinit.zsh/+zi-log 464 | `-- zinit.zsh/.zinit-get-object-path 465 | 466 | Uses feature(s): _setopt_, _trap_ 467 | 468 | Called by: 469 | 470 | zinit-autoload.zsh/.zinit-update-or-status 471 | zinit.zsh/.zinit-load 472 | 473 | ==== .zinit-single-line 474 | 475 | ____ 476 | 477 | Display cURL progress bar on a single line 478 | 479 | ____ 480 | 481 | Has 20 line(s). Doesn't call other functions. 482 | 483 | Uses feature(s): _read_, _setopt_ 484 | 485 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 486 | 487 | ==== .zinit-update-snippet 488 | 489 | Has 76 line(s). Calls functions: 490 | 491 | .zinit-update-snippet 492 | |-- .zinit-download-snippet 493 | |   |-- .zinit-download-file-stdout 494 | |   |   `-- zinit.zsh/+zi-log 495 | |   |-- .zinit-get-url-mtime 496 | |   |-- .zinit-install-completions 497 | |   |   |-- .zinit-compinit 498 | |   |   |   |-- .zinit-forget-completion 499 | |   |   |   |-- compinit 500 | |   |   |   `-- zinit.zsh/+zi-log 501 | |   |   |-- .zinit-forget-completion 502 | |   |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 503 | |   |   |-- zinit-side.zsh/.zinit-exists-physically-message 504 | |   |   |-- zinit.zsh/+zi-log 505 | |   |   `-- zinit.zsh/.zinit-any-to-user-plugin 506 | |   |-- .zinit-mirror-using-svn 507 | |   |-- zinit-side.zsh/.zinit-store-ices 508 | |   |-- zinit.zsh/+zi-log 509 | |   `-- zinit.zsh/is-at-least 510 | |-- zinit.zsh/+zi-log 511 | |-- zinit.zsh/.zinit-get-object-path 512 | `-- zinit.zsh/.zinit-pack-ice 513 | 514 | Uses feature(s): _eval_, _setopt_ 515 | 516 | Called by: 517 | 518 | zinit-autoload.zsh/.zinit-update-or-status-snippet 519 | 520 | ==== __zinit-cmake-base-hook 521 | 522 | ____ 523 | 524 | FUNCTION: __zinit-cmake-base-hook [[[ 525 | A base common implementation of the cmake ice 526 | 527 | ____ 528 | 529 | Has 23 line(s). Calls functions: 530 | 531 | __zinit-cmake-base-hook 532 | `-- zinit.zsh/+zi-log 533 | 534 | Uses feature(s): _eval_, _setopt_ 535 | 536 | Called by: 537 | 538 | +zinit-cmake-hook 539 | 540 | ==== zicp 541 | 542 | Has 30 line(s). Doesn't call other functions. 543 | 544 | Uses feature(s): _setopt_ 545 | 546 | Called by: 547 | 548 | zimv 549 | 550 | ==== ziextract 551 | 552 | ____ 553 | 554 | If the file is an archive, it is extracted by this function. 555 | Next stage is scanning of files with the common utility file 556 | to detect executables. They are given +x mode. There are also 557 | messages to the user on performed actions. 558 | 559 | $1 - url 560 | $2 - file 561 | 562 | ____ 563 | 564 | Has 283 line(s). Calls functions: 565 | 566 | ziextract 567 | `-- zinit.zsh/+zi-log 568 | 569 | Uses feature(s): _setopt_, _unfunction_, _zparseopts_ 570 | 571 | Called by: 572 | 573 | .zinit-extract 574 | .zinit-get-package 575 | .zinit-setup-plugin-dir 576 | 577 | ==== zimv 578 | 579 | Has 3 line(s). Calls functions: 580 | 581 | zimv 582 | `-- zicp 583 | 584 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 585 | 586 | ==== ∞zinit-atclone-hook 587 | 588 | Has 26 line(s). Calls functions: 589 | 590 | ∞zinit-atclone-hook 591 | |-- zinit-side.zsh/.zinit-countdown 592 | `-- zinit.zsh/@zinit-substitute 593 | 594 | Uses feature(s): _eval_, _setopt_ 595 | 596 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 597 | 598 | ==== ∞zinit-atpull-e-hook 599 | 600 | Has 22 line(s). Calls functions: 601 | 602 | ∞zinit-atpull-e-hook 603 | |-- .zinit-at-eval 604 | |   `-- zinit.zsh/@zinit-substitute 605 | `-- zinit-side.zsh/.zinit-countdown 606 | 607 | Uses feature(s): _setopt_ 608 | 609 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 610 | 611 | ==== ∞zinit-atpull-hook 612 | 613 | Has 22 line(s). Calls functions: 614 | 615 | ∞zinit-atpull-hook 616 | |-- .zinit-at-eval 617 | |   `-- zinit.zsh/@zinit-substitute 618 | `-- zinit-side.zsh/.zinit-countdown 619 | 620 | Uses feature(s): _setopt_ 621 | 622 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 623 | 624 | ==== ∞zinit-compile-plugin-hook 625 | 626 | Has 20 line(s). Calls functions: 627 | 628 | ∞zinit-compile-plugin-hook 629 | `-- zinit-autoload.zsh/.zinit-compile-plugin 630 | 631 | Uses feature(s): _setopt_, _source_ 632 | 633 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 634 | 635 | ==== ∞zinit-configure-base-hook 636 | 637 | ____ 638 | 639 | A base common implementation of the configure ice 640 | 641 | ____ 642 | 643 | Has 46 line(s). Calls functions: 644 | 645 | ∞zinit-configure-base-hook 646 | |-- zinit.zsh/+zi-log 647 | `-- zinit.zsh/@zinit-substitute 648 | 649 | Uses feature(s): _eval_, _setopt_ 650 | 651 | Called by: 652 | 653 | ∞zinit-configure-e-hook 654 | ∞zinit-configure-hook 655 | 656 | ==== ∞zinit-configure-e-hook 657 | 658 | Has 1 line(s). Calls functions: 659 | 660 | ∞zinit-configure-e-hook 661 | `-- ∞zinit-configure-base-hook 662 | |-- zinit.zsh/+zi-log 663 | `-- zinit.zsh/@zinit-substitute 664 | 665 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 666 | 667 | ==== ∞zinit-configure-hook 668 | 669 | ____ 670 | 671 | The non-! version of configure'' ice. Runs in between 672 | of make'!' and make''. Configure script naturally runs 673 | before make. 674 | 675 | ____ 676 | 677 | Has 1 line(s). Calls functions: 678 | 679 | ∞zinit-configure-hook 680 | `-- ∞zinit-configure-base-hook 681 | |-- zinit.zsh/+zi-log 682 | `-- zinit.zsh/@zinit-substitute 683 | 684 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 685 | 686 | ==== ∞zinit-cp-hook 687 | 688 | Has 1 line(s). Calls functions: 689 | 690 | ∞zinit-cp-hook 691 | `-- ∞zinit-file-cp-mv-operation 692 | |-- zinit.zsh/+zi-log 693 | `-- zinit.zsh/@zinit-substitute 694 | 695 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 696 | 697 | ==== ∞zinit-extract-hook 698 | 699 | Has 10 line(s). Calls functions: 700 | 701 | ∞zinit-extract-hook 702 | |-- .zinit-extract 703 | |   |-- ziextract 704 | |   |   `-- zinit.zsh/+zi-log 705 | |   `-- zinit.zsh/+zi-log 706 | `-- zinit.zsh/@zinit-substitute 707 | 708 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 709 | 710 | ==== ∞zinit-file-cp-mv-operation 711 | 712 | Has 49 line(s). Calls functions: 713 | 714 | ∞zinit-file-cp-mv-operation 715 | |-- zinit.zsh/+zi-log 716 | `-- zinit.zsh/@zinit-substitute 717 | 718 | Uses feature(s): _setopt_ 719 | 720 | Called by: 721 | 722 | ∞zinit-cp-hook 723 | ∞zinit-mv-hook 724 | 725 | ==== ∞zinit-make-base-hook 726 | 727 | ____ 728 | 729 | A base common implementation of the make ice 730 | 731 | ____ 732 | 733 | Has 57 line(s). Calls functions: 734 | 735 | ∞zinit-make-base-hook 736 | |-- zinit.zsh/+zi-log 737 | `-- zinit.zsh/@zinit-substitute 738 | 739 | Uses feature(s): _eval_, _setopt_ 740 | 741 | Called by: 742 | 743 | ∞zinit-make-e-hook 744 | ∞zinit-make-ee-hook 745 | ∞zinit-make-hook 746 | 747 | ==== ∞zinit-make-e-hook 748 | 749 | Has 1 line(s). Calls functions: 750 | 751 | ∞zinit-make-e-hook 752 | `-- ∞zinit-make-base-hook 753 | |-- zinit.zsh/+zi-log 754 | `-- zinit.zsh/@zinit-substitute 755 | 756 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 757 | 758 | ==== ∞zinit-make-ee-hook 759 | 760 | Has 1 line(s). Calls functions: 761 | 762 | ∞zinit-make-ee-hook 763 | `-- ∞zinit-make-base-hook 764 | |-- zinit.zsh/+zi-log 765 | `-- zinit.zsh/@zinit-substitute 766 | 767 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 768 | 769 | ==== ∞zinit-make-hook 770 | 771 | Has 1 line(s). Calls functions: 772 | 773 | ∞zinit-make-hook 774 | `-- ∞zinit-make-base-hook 775 | |-- zinit.zsh/+zi-log 776 | `-- zinit.zsh/@zinit-substitute 777 | 778 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 779 | 780 | ==== ∞zinit-mv-hook 781 | 782 | Has 1 line(s). Calls functions: 783 | 784 | ∞zinit-mv-hook 785 | `-- ∞zinit-file-cp-mv-operation 786 | |-- zinit.zsh/+zi-log 787 | `-- zinit.zsh/@zinit-substitute 788 | 789 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 790 | 791 | ==== ∞zinit-ps-on-update-hook 792 | 793 | Has 18 line(s). Calls functions: 794 | 795 | ∞zinit-ps-on-update-hook 796 | `-- zinit.zsh/+zi-log 797 | 798 | Uses feature(s): _eval_ 799 | 800 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 801 | 802 | ==== ∞zinit-reset-hook 803 | 804 | Has 79 line(s). Calls functions: 805 | 806 | ∞zinit-reset-hook 807 | `-- zinit.zsh/+zi-log 808 | 809 | Uses feature(s): _eval_ 810 | 811 | Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). 812 | 813 | ==== compinit 814 | 815 | ____ 816 | 817 | Initialisation for new style completion. This mainly contains some helper 818 | functions and setup. Everything else is split into different files that 819 | will automatically be made autoloaded (see the end of this file). The 820 | names of the files that will be considered for autoloading are those that 821 | begin with an underscores (like `_condition). 822 | 823 | The first line of each of these files is read and must indicate what 824 | should be done with its contents: 825 | 826 | `#compdef ' 827 | 828 | ____ 829 | 830 | Has 573 line(s). Doesn't call other functions. 831 | 832 | Uses feature(s): _autoload_, _bindkey_, _compdef_, _compdump_, _eval_, _read_, _setopt_, _unfunction_, _zle_, _zstyle_ 833 | 834 | Called by: 835 | 836 | .zinit-compinit 837 | 838 | -------------------------------------------------------------------------------- /doc/zsdoc/zinit-side.zsh.adoc: -------------------------------------------------------------------------------- 1 | 2 | NAME 3 | 4 | zinit-side.zsh - a shell script 5 | 6 | Documentation automatically generated with `zshelldoc' 7 | 8 | == FUNCTIONS 9 | .zinit-any-colorify-as-uspl2 10 | .zinit-compute-ice 11 | .zinit-countdown 12 | .zinit-exists-physically 13 | .zinit-exists-physically-message 14 | .zinit-first 15 | .zinit-store-ices 16 | .zinit-two-paths 17 | 18 | === DETAILS 19 | 20 | ==== Script Body 21 | 22 | Has 1 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.). 23 | 24 | ==== .zinit-any-colorify-as-uspl2 25 | 26 | ____ 27 | 28 | Returns ANSI-colorified "user/plugin" string, from any supported 29 | plugin spec (user---plugin, user/plugin, user plugin, plugin). 30 | 31 | $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) 32 | $2 - plugin (only when $1 - i.e. user - given) 33 | 34 | $REPLY - ANSI-colorified "user/plugin" string 35 | 36 | ____ 37 | 38 | Has 22 line(s). Calls functions: 39 | 40 | .zinit-any-colorify-as-uspl2 41 | |-- zinit.zsh/.zinit-any-to-pid 42 | `-- zinit.zsh/.zinit-any-to-user-plugin 43 | 44 | Called by: 45 | 46 | .zinit-exists-physically-message 47 | zinit-autoload.zsh/.zinit-clear-completions 48 | zinit-autoload.zsh/.zinit-compiled 49 | zinit-autoload.zsh/.zinit-create 50 | zinit-autoload.zsh/.zinit-exists-message 51 | zinit-autoload.zsh/.zinit-get-completion-owner-uspl2col 52 | zinit-autoload.zsh/.zinit-list-bindkeys 53 | zinit-autoload.zsh/.zinit-recently 54 | zinit-autoload.zsh/.zinit-search-completions 55 | zinit-autoload.zsh/.zinit-show-completions 56 | zinit-autoload.zsh/.zinit-show-times 57 | zinit-autoload.zsh/.zinit-unload 58 | zinit-autoload.zsh/.zinit-update-all-parallel 59 | zinit-autoload.zsh/.zinit-update-or-status-all 60 | zinit-autoload.zsh/.zinit-update-or-status 61 | zinit-install.zsh/.zinit-install-completions 62 | zinit-install.zsh/.zinit-setup-plugin-dir 63 | zinit.zsh/.zinit-formatter-pid 64 | 65 | ==== .zinit-compute-ice 66 | 67 | ____ 68 | 69 | Computes ICE array 70 | - input 71 | - static 72 | - saved 73 | taking priorities into account. 74 | Can also pack resulting ices into ZINIT_SICE (see $2). 75 | Returns filepath to snippet directory and optional snippet file name (only 76 | valid if ICE[svn] is not set). 77 | 78 | $1 - URL (also plugin-spec) 79 | $2 - "pack" or "nopack" or "pack-nf" - packing means ICE 80 | wins with static ice; "pack-nf" means that disk-ices will 81 | be ignored (no-file?) 82 | $3 - name of output associative array, "ICE" is the default 83 | $4 - name of output string parameter, to hold path to directory ("local_dir") 84 | $5 - name of output string parameter, to hold filename ("filename") 85 | $6 - name of output string parameter, to hold is-snippet 0/1-bool ("is_snippet") 86 | 87 | $REPLY - snippet directory filepath 88 | 89 | ____ 90 | 91 | Has 110 line(s). Calls functions: 92 | 93 | .zinit-compute-ice 94 | |-- .zinit-exists-physically-message 95 | |   |-- .zinit-any-colorify-as-uspl2 96 | |   |   |-- zinit.zsh/.zinit-any-to-pid 97 | |   |   `-- zinit.zsh/.zinit-any-to-user-plugin 98 | |   |-- .zinit-exists-physically 99 | |   |   `-- zinit.zsh/.zinit-any-to-user-plugin 100 | |   |-- zinit.zsh/+zi-log 101 | |   |-- zinit.zsh/.zinit-any-to-pid 102 | |   `-- zinit.zsh/.zinit-any-to-user-plugin 103 | |-- .zinit-two-paths 104 | |   |-- .zinit-first 105 | |   |   |-- zinit.zsh/.zinit-any-to-pid 106 | |   |   |-- zinit.zsh/.zinit-any-to-user-plugin 107 | |   |   |-- zinit.zsh/.zinit-find-other-matches 108 | |   |   `-- zinit.zsh/.zinit-get-object-path 109 | |   `-- zinit.zsh/.zinit-get-object-path 110 | |-- zinit.zsh/.zinit-any-to-user-plugin 111 | `-- zinit.zsh/.zinit-pack-ice 112 | 113 | Uses feature(s): _setopt_ 114 | 115 | Called by: 116 | 117 | zinit-autoload.zsh/.zinit-compile-plugin 118 | zinit-autoload.zsh/.zinit-edit 119 | zinit-autoload.zsh/.zinit-recall 120 | zinit-autoload.zsh/.zinit-uncompile-plugin 121 | zinit-autoload.zsh/.zinit-update-or-status-snippet 122 | zinit-autoload.zsh/.zinit-update-or-status 123 | 124 | ==== .zinit-countdown 125 | 126 | ____ 127 | 128 | Displays a countdown 5...4... etc. 129 | 130 | $REPLY - 1 if Ctrl-C is pressed, otherwise 0 131 | 132 | ____ 133 | 134 | Has 20 line(s). Calls functions: 135 | 136 | .zinit-countdown 137 | `-- zinit.zsh/+zi-log 138 | 139 | Uses feature(s): _trap_ 140 | 141 | Called by: 142 | 143 | zinit-install.zsh/∞zinit-atclone-hook 144 | zinit-install.zsh/∞zinit-atpull-e-hook 145 | zinit-install.zsh/∞zinit-atpull-hook 146 | 147 | ==== .zinit-exists-physically 148 | 149 | ____ 150 | 151 | Checks if directory of given plugin exists in PLUGIN_DIR. 152 | 153 | $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) 154 | $2 - plugin (only when $1 - i.e. user - given) 155 | 156 | ____ 157 | 158 | Has 8 line(s). Calls functions: 159 | 160 | .zinit-exists-physically 161 | `-- zinit.zsh/.zinit-any-to-user-plugin 162 | 163 | Called by: 164 | 165 | .zinit-exists-physically-message 166 | zinit-autoload.zsh/.zinit-create 167 | zinit-autoload.zsh/.zinit-update-or-status 168 | 169 | ==== .zinit-exists-physically-message 170 | 171 | ____ 172 | 173 | Checks if directory of given plugin exists in PLUGIN_DIR, and outputs error 174 | message if it doesn't. 175 | 176 | $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) 177 | $2 - plugin (only when $1 - i.e. user - given) 178 | 179 | ____ 180 | 181 | Has 25 line(s). Calls functions: 182 | 183 | .zinit-exists-physically-message 184 | |-- .zinit-any-colorify-as-uspl2 185 | |   |-- zinit.zsh/.zinit-any-to-pid 186 | |   `-- zinit.zsh/.zinit-any-to-user-plugin 187 | |-- .zinit-exists-physically 188 | |   `-- zinit.zsh/.zinit-any-to-user-plugin 189 | |-- zinit.zsh/+zi-log 190 | |-- zinit.zsh/.zinit-any-to-pid 191 | `-- zinit.zsh/.zinit-any-to-user-plugin 192 | 193 | Uses feature(s): _setopt_ 194 | 195 | Called by: 196 | 197 | .zinit-compute-ice 198 | zinit-autoload.zsh/.zinit-changes 199 | zinit-autoload.zsh/.zinit-glance 200 | zinit-autoload.zsh/.zinit-stress 201 | zinit-autoload.zsh/.zinit-update-or-status 202 | zinit-install.zsh/.zinit-install-completions 203 | 204 | ==== .zinit-first 205 | 206 | ____ 207 | 208 | Finds the main file of plugin. There are multiple file name formats, they are 209 | ordered in order starting from more correct ones, and matched. 210 | .zinit-load-plugin() has similar code parts and doesn't call .zinit-first() – 211 | for performance. Obscure matching is done in .zinit-find-other-matches, here 212 | and in .zinit-load(). Obscure = non-standard main-file naming convention. 213 | 214 | $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) 215 | $2 - plugin (only when $1 - i.e. user - given) 216 | 217 | ____ 218 | 219 | Has 20 line(s). Calls functions: 220 | 221 | .zinit-first 222 | |-- zinit.zsh/.zinit-any-to-pid 223 | |-- zinit.zsh/.zinit-any-to-user-plugin 224 | |-- zinit.zsh/.zinit-find-other-matches 225 | `-- zinit.zsh/.zinit-get-object-path 226 | 227 | Called by: 228 | 229 | .zinit-two-paths 230 | zinit-autoload.zsh/.zinit-compile-plugin 231 | zinit-autoload.zsh/.zinit-glance 232 | zinit-autoload.zsh/.zinit-stress 233 | 234 | ==== .zinit-store-ices 235 | 236 | ____ 237 | 238 | Saves ice mods in given hash onto disk. 239 | 240 | $1 - directory where to create or delete files 241 | $2 - name of hash that holds values 242 | $3 - additional keys of hash to store, space separated 243 | $4 - additional keys of hash to store, empty-meaningful ices, space separated 244 | $5 – URL, if applicable 245 | $6 – mode, svn=1, 0=single file 246 | 247 | ____ 248 | 249 | Has 30 line(s). Doesn't call other functions. 250 | 251 | Called by: 252 | 253 | zinit-autoload.zsh/.zinit-update-or-status 254 | zinit-install.zsh/.zinit-download-snippet 255 | zinit-install.zsh/.zinit-setup-plugin-dir 256 | 257 | ==== .zinit-two-paths 258 | 259 | ____ 260 | 261 | Obtains a snippet URL without specification if it is an SVN URL (points to 262 | directory) or regular URL (points to file), returns 2 possible paths for 263 | further examination 264 | 265 | $REPLY - two filepaths 266 | 267 | ____ 268 | 269 | Has 24 line(s). Calls functions: 270 | 271 | .zinit-two-paths 272 | |-- .zinit-first 273 | |   |-- zinit.zsh/.zinit-any-to-pid 274 | |   |-- zinit.zsh/.zinit-any-to-user-plugin 275 | |   |-- zinit.zsh/.zinit-find-other-matches 276 | |   `-- zinit.zsh/.zinit-get-object-path 277 | `-- zinit.zsh/.zinit-get-object-path 278 | 279 | Uses feature(s): _setopt_ 280 | 281 | Called by: 282 | 283 | .zinit-compute-ice 284 | zinit-autoload.zsh/.zinit-update-or-status 285 | 286 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG VERSION=latest 2 | FROM alpine:${VERSION} 3 | 4 | ARG PUSERNAME=user01 5 | ARG PUID=1000 6 | ARG PGID=1000 7 | ARG TERM=xterm-256color 8 | ARG ZINIT_ZSH_VERSION 9 | 10 | ENV PUSERNAME=${PUSERNAME} PUID=${PUID} PGID=${PGID} \ 11 | SHELL=/bin/zsh TERM=${TERM} ZINIT_ZSH_VERSION=${ZINIT_ZSH_VERSION} 12 | 13 | RUN apk --no-cache --virtual base add \ 14 | coreutils curl git libuser rsync sudo zsh && \ 15 | apk --no-cache --virtual zsh-build-tools add \ 16 | autoconf bash build-base ncurses-dev && \ 17 | apk --no-cache --virtual dev-tools add \ 18 | go jq nodejs-dev npm ruby-dev neovim 19 | 20 | RUN sed -ir 's#^(root:.+):/bin/ash#\1:/bin/zsh#' /etc/passwd && \ 21 | adduser -D -s /bin/zsh -u "${PUID}" -h "/home/${PUSERNAME}" \ 22 | "${PUSERNAME}" && \ 23 | printf "${PUSERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/user && \ 24 | mkdir -p /src /data /data-static && \ 25 | chown -R "${PUID}:${PGID}" /data /data-static && \ 26 | ln -sfv /src/docker/zshenv /home/${PUSERNAME}/.zshenv && \ 27 | ln -sfv /src/docker/zshrc /home/${PUSERNAME}/.zshrc 28 | 29 | WORKDIR /home/${PUSERNAME} 30 | VOLUME ["/src", "/data"] 31 | 32 | COPY --chown=${PUSERNAME} . /src 33 | 34 | USER ${PUSERNAME} 35 | 36 | # Fetch keys config and store it outside of ZINIT[HOME_DIR] since it might get 37 | # overridden at runtime (the /data volume) 38 | RUN ZINIT_HOME_DIR=/data-static ZSH_NO_INIT=1 \ 39 | zsh -ils -c -- '@zinit-scheduler burst' 40 | 41 | CMD ["/bin/zsh"] 42 | -------------------------------------------------------------------------------- /docker/init.zsh: -------------------------------------------------------------------------------- 1 | # Fix permissions on /data 2 | if [[ -z "$QUIET" ]] 3 | then 4 | echo "Setting owner of /data to ${PUID}:${PGID}" >&2 5 | fi 6 | 7 | sudo chown "${PUID}:${PGID}" /data 8 | sudo chown -R "${PUID}:${PGID}" /data 9 | 10 | # sync files between /data-static and /data 11 | if [[ -z "$NOTHING_FANCY" ]] 12 | then 13 | if [[ -z "$QUIET" ]] 14 | then 15 | echo "Copying files from /data-static to /data" >&2 16 | fi 17 | rsync -raq /data-static/ /data 18 | fi 19 | 20 | # Local Variables: 21 | # mode: Shell-Script 22 | # sh-indentation: 2 23 | # indent-tabs-mode: nil 24 | # sh-basic-offset: 2 25 | # End: 26 | # vim: ft=zsh sw=2 ts=2 et 27 | -------------------------------------------------------------------------------- /docker/utils.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | zinit::setup() { 4 | source /src/zinit.zsh 5 | } 6 | 7 | zinit::reload() { 8 | local zf 9 | for zf in /src/*.zsh 10 | do 11 | source "$zf" 12 | done 13 | } 14 | 15 | zinit::setup-keys() { 16 | zinit snippet OMZL::key-bindings.zsh 17 | } 18 | 19 | zinit::setup-annexes() { 20 | zinit light-mode compile'*handler' for \ 21 | zdharma-continuum/zinit-annex-bin-gem-node \ 22 | zdharma-continuum/zinit-annex-default-ice \ 23 | zdharma-continuum/zinit-annex-meta-plugins \ 24 | zdharma-continuum/zinit-annex-patch-dl \ 25 | zdharma-continuum/zinit-annex-readurl \ 26 | zdharma-continuum/zinit-annex-rust \ 27 | zdharma-continuum/zinit-annex-submods \ 28 | zdharma-continuum/zinit-annex-unscope 29 | } 30 | 31 | zinit::setup-annexes-extra() { 32 | # Dependencies 33 | sudo apk add ruby-dev grep tree 34 | zinit::install-zshelldoc 35 | 36 | zinit light-mode compile'*handler' for \ 37 | zdharma-continuum/zinit-annex-man \ 38 | zdharma-continuum/zinit-annex-test 39 | } 40 | 41 | zinit::install-zshelldoc() { 42 | zinit light-mode \ 43 | make"PREFIX=$ZPFX install" \ 44 | for zdharma-continuum/zshelldoc 45 | } 46 | 47 | zinit::setup-minimal() { 48 | zinit wait lucid light-mode for \ 49 | atinit"zicompinit; zicdreplay" \ 50 | zdharma-continuum/fast-syntax-highlighting \ 51 | atload"_zsh_autosuggest_start" \ 52 | zsh-users/zsh-autosuggestions \ 53 | blockf atpull'zinit creinstall -q .' \ 54 | zsh-users/zsh-completions 55 | } 56 | 57 | zinit::pack-zsh() { 58 | local version="$1" 59 | 60 | zinit pack"$version" for zsh 61 | } 62 | 63 | # Local Variables: 64 | # mode: Shell-Script 65 | # sh-indentation: 2 66 | # indent-tabs-mode: nil 67 | # sh-basic-offset: 2 68 | # End: 69 | # vim: ft=zsh sw=2 ts=2 et 70 | -------------------------------------------------------------------------------- /docker/zshenv: -------------------------------------------------------------------------------- 1 | # Make sure TERM is set 2 | # Without a TERM value some ices might be ignored 3 | # https://github.com/zdharma-continuum/zinit/issues/97 4 | export TERM=${TERM:-xterm-256color} 5 | # Set SHELL 6 | export SHELL=${SHELL:-${commands[zsh]}} 7 | 8 | typeset -Ag ZINIT 9 | 10 | # ZINIT_HOME_DIR is used at build time to force the installation of plugins 11 | # etc to /data-static 12 | export ZINIT[HOME_DIR]=${ZINIT_HOME_DIR:-/data} 13 | export ZINIT[BIN_DIR]=/src 14 | 15 | # Local Variables: 16 | # mode: Shell-Script 17 | # sh-indentation: 2 18 | # indent-tabs-mode: nil 19 | # sh-basic-offset: 2 20 | # End: 21 | # vim: ft=zsh sw=2 ts=2 et 22 | -------------------------------------------------------------------------------- /docker/zshrc: -------------------------------------------------------------------------------- 1 | # Initialization. Trigger stuff that only needs to be run once, at startup. 2 | if [[ "$$" == 1 ]] && [[ -z "$ZSH_NO_INIT" ]] 3 | then 4 | source /src/docker/init.zsh 5 | fi 6 | 7 | # load zinit 8 | source /src/zinit.zsh 9 | autoload -Uz _zinit 10 | (( ${+_comps} )) && _comps[zinit]=_zinit 11 | 12 | # load zinit setup utility functions 13 | source /src/docker/utils.zsh 14 | 15 | # Add ZPFX/bin and GOPATH/bin to PATH 16 | typeset -U path 17 | path=("${ZPFX:-${HOME}/.local/share/zinit/polaris}/bin" "${HOME}/go/bin" $path) 18 | 19 | # Install custom zsh version 20 | if [[ -n "$ZINIT_ZSH_VERSION" ]] 21 | then 22 | zinit::pack-zsh "$ZINIT_ZSH_VERSION" 23 | fi 24 | 25 | source /src/docker/zshrc-fancy 26 | 27 | # Source init file 28 | INIT_FILE="/init.zsh" 29 | if [[ -r "$INIT_FILE" ]] 30 | then 31 | source "$INIT_FILE" 32 | fi 33 | 34 | # Local Variables: 35 | # mode: Shell-Script 36 | # sh-indentation: 2 37 | # indent-tabs-mode: nil 38 | # sh-basic-offset: 2 39 | # End: 40 | # vim: ft=zsh sw=2 ts=2 et 41 | 42 | -------------------------------------------------------------------------------- /docker/zshrc-fancy: -------------------------------------------------------------------------------- 1 | [[ -n "$NOTHING_FANCY" ]] && return 2 | 3 | # Annexes 4 | zinit::setup-annexes 5 | 6 | # Setup keys 7 | zinit::setup-keys 8 | 9 | # Aliases 10 | alias ls="ls --color=auto" 11 | alias vim="nvim" 12 | alias re-init="source /init.zsh" 13 | 14 | # History 15 | HISTFILE=${HOME}/.local/share/zsh/history 16 | HISTSIZE=1000 17 | SAVEHIST=1000 18 | setopt extended_history 19 | setopt hist_expire_dups_first 20 | setopt hist_ignore_dups 21 | setopt hist_ignore_space 22 | setopt hist_verify 23 | setopt share_history 24 | 25 | mkdir -p ${HISTFILE:A:h} 26 | 27 | # Completions 28 | autoload -Uz compinit 29 | compinit 30 | zinit cdreplay -q 31 | 32 | # Local Variables: 33 | # mode: Shell-Script 34 | # sh-indentation: 2 35 | # indent-tabs-mode: nil 36 | # sh-basic-offset: 2 37 | # End: 38 | # vim: ft=zsh sw=2 ts=2 et 39 | 40 | -------------------------------------------------------------------------------- /scripts/docker-build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | build() { 4 | cd "$( 5 | cd "$(dirname "$0")" > /dev/null 2>&1 6 | pwd -P 7 | )" || exit 9 8 | 9 | local image_name="${1:-zinit}" 10 | local tag="${2:-latest}" 11 | local zsh_version="${3}" 12 | shift 3 13 | 14 | local dockerfile="../docker/Dockerfile" 15 | 16 | if [[ -n $zsh_version ]]; then 17 | tag="zsh${zsh_version}-${tag}" 18 | fi 19 | 20 | echo -e "\e[34mBuilding image: ${image_name}\e[0m" >&2 21 | 22 | local -a args 23 | [[ -n $NO_CACHE ]] && args+=(--no-cache "$@") 24 | 25 | if docker build \ 26 | --build-arg "PUSERNAME=$(id -u -n)" \ 27 | --build-arg "PUID=$(id -u)" \ 28 | --build-arg "PGID=$(id -g)" \ 29 | --build-arg "TERM=${TERM:-xterm-256color}" \ 30 | --build-arg "ZINIT_ZSH_VERSION=${zsh_version}" \ 31 | --file "$dockerfile" \ 32 | --tag "${image_name}:${tag}" \ 33 | "${args[@]}" \ 34 | "$(realpath ..)"; then 35 | { 36 | echo -e "\e[34mTo use this image for zunit tests run: \e[0m" 37 | echo -e "\e[34mexport CONTAINER_IMAGE=\"${image_name}\" CONTAINER_TAG=\"${tag}\"\e[0m" 38 | echo -e "\e[34mzunit run --verbose\e[0m" 39 | } >&2 40 | else 41 | echo -e "\e[31m❌ Container failed to build.\e[0m" >&2 42 | return 1 43 | fi 44 | } 45 | 46 | if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then 47 | BUILD_ZSH_VERSION="${BUILD_ZSH_VERSION:-}" 48 | CONTAINER_IMAGE="${CONTAINER_IMAGE:-ghcr.io/zdharma-continuum/zinit}" 49 | CONTAINER_TAG="${CONTAINER_TAG:-latest}" 50 | NO_CACHE="${NO_CACHE:-}" 51 | 52 | while [[ -n $* ]]; do 53 | case "$1" in 54 | --image | -i) 55 | CONTAINER_IMAGE="$2" 56 | shift 2 57 | ;; 58 | --no-cache | -N) 59 | NO_CACHE=1 60 | shift 61 | ;; 62 | --zsh-version | -zv | --zv) 63 | BUILD_ZSH_VERSION="${2}" 64 | shift 2 65 | ;; 66 | *) 67 | break 68 | ;; 69 | esac 70 | done 71 | 72 | build "${CONTAINER_IMAGE}" "${CONTAINER_TAG}" "${BUILD_ZSH_VERSION}" "$@" 73 | fi 74 | 75 | # Local Variables: 76 | # mode: Shell-Script 77 | # sh-indentation: 2 78 | # indent-tabs-mode: nil 79 | # sh-basic-offset: 2 80 | # End: 81 | # vim: ft=bash sw=2 ts=2 et 82 | -------------------------------------------------------------------------------- /scripts/docker-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | parent_process() { 4 | local ppid pcmd 5 | ppid="$(ps -o ppid= -p "$$" | awk '{ print $1 }')" 6 | 7 | if [[ -z $ppid ]]; then 8 | echo "Failed to determine parent process" >&2 9 | return 1 10 | fi 11 | 12 | if pcmd="$(ps -o cmd= -p "$ppid")"; then 13 | echo "$pcmd" 14 | return 15 | fi 16 | return 1 17 | } 18 | 19 | running_interactively() { 20 | if [[ -n $CI ]]; then 21 | return 1 22 | fi 23 | 24 | if ! [[ -t 1 ]]; then 25 | # return false if running non-interactively, unless run with zunit 26 | parent_process | grep -q zunit 27 | fi 28 | } 29 | 30 | create_init_config_file() { 31 | local tempfile 32 | 33 | if [[ -z $* ]]; then 34 | return 1 35 | fi 36 | 37 | tempfile="$(mktemp)" 38 | echo "$*" > "$tempfile" 39 | # DIRTYFIX perms... 40 | chmod 666 "$tempfile" 41 | echo "$tempfile" 42 | } 43 | 44 | run() { 45 | local image="${CONTAINER_IMAGE:-ghcr.io/zdharma-continuum/zinit}" 46 | local tag="${CONTAINER_TAG:-latest}" 47 | local init_config="$1" 48 | shift 49 | 50 | local -a args=(--rm) 51 | 52 | local cruntime=docker 53 | local sudo_cmd 54 | if [[ -z $CI ]] && command -v podman > /dev/null 2>&1; then 55 | cruntime=podman 56 | # rootless containers are a PITA 57 | # https://www.tutorialworks.com/podman-rootless-volumes/ 58 | sudo_cmd=sudo 59 | fi 60 | 61 | if running_interactively; then 62 | args+=(--tty=true --interactive=true) 63 | fi 64 | 65 | if [[ -n $init_config ]]; then 66 | if [[ -r $init_config ]]; then 67 | args+=(--volume "${init_config}:/init.zsh") 68 | else 69 | echo "❌ Init config file is not readable" >&2 70 | return 1 71 | fi 72 | fi 73 | 74 | if [[ -n $CONTAINER_WORKDIR ]]; then 75 | args+=(--workdir "$CONTAINER_WORKDIR") 76 | fi 77 | 78 | # Inherit TERM 79 | if [[ -n $TERM ]]; then 80 | args+=(--env "TERM=${TERM}") 81 | fi 82 | 83 | if [[ -n ${CONTAINER_ENV[*]} ]]; then 84 | local e 85 | for e in "${CONTAINER_ENV[@]}"; do 86 | args+=(--env "${e}") 87 | done 88 | fi 89 | 90 | if [[ -n ${CONTAINER_VOLUMES[*]} ]]; then 91 | local vol 92 | for vol in "${CONTAINER_VOLUMES[@]}"; do 93 | # shellcheck disable=2076 94 | if [[ ! " ${args[*]} " =~ " --volume ${vol} " ]]; then 95 | args+=(--volume "${vol}") 96 | fi 97 | done 98 | fi 99 | 100 | local -a cmd=("$@") 101 | 102 | if [[ -n $WRAP_CMD ]]; then 103 | local zsh_opts="ilsc" 104 | [[ -n $ZSH_DEBUG ]] && zsh_opts="x${zsh_opts}" 105 | cmd=(zsh "-${zsh_opts}" "${cmd[*]}") 106 | fi 107 | 108 | if [[ -n $DEBUG ]]; then 109 | { 110 | # The @Q below is necessary to keep the quotes intact 111 | # https://stackoverflow.com/a/12985353/1872036 112 | echo -e "🚀 \e[35mRunning command" 113 | echo -e "\$ ${cruntime} run ${args[*]} ${image}:${tag} ${cmd[*]@Q}\e[0m" 114 | } >&2 115 | fi 116 | 117 | ${sudo_cmd} "${cruntime}" run "${args[@]}" "${image}:${tag}" "${cmd[@]}" 118 | } 119 | 120 | if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then 121 | CONTAINER_ENV=() 122 | CONTAINER_IMAGE="${CONTAINER_IMAGE:-ghcr.io/zdharma-continuum/zinit}" 123 | CONTAINER_TAG="${CONTAINER_TAG:-latest}" 124 | CONTAINER_VOLUMES=() 125 | CONTAINER_WORKDIR="${CONTAINER_WORKDIR:-}" 126 | DEBUG="${DEBUG:-}" 127 | INIT_CONFIG_VAL="${INIT_CONFIG_VAL:-}" 128 | PRESET="${PRESET:-}" 129 | WRAP_CMD="${WRAP_CMD:-}" 130 | ZSH_DEBUG="${ZSH_DEBUG:-}" 131 | 132 | while [[ -n $* ]]; do 133 | case "$1" in 134 | # Fetch init config from clipboard (Linux only) 135 | --xsel | -b) 136 | INIT_CONFIG_VAL="$(xsel -b)" 137 | shift 138 | ;; 139 | -c | --config | --init-config | --init) 140 | INIT_CONFIG_VAL="$2" 141 | shift 2 142 | ;; 143 | -f | --config-file | --init-config-file | --file) 144 | if ! [[ -r $2 ]]; then 145 | echo "Unable to read from file: $2" >&2 146 | exit 2 147 | fi 148 | INIT_CONFIG_VAL="$(cat "$2")" 149 | shift 2 150 | ;; 151 | -d | --debug) 152 | DEBUG=1 153 | shift 154 | ;; 155 | -D | --dev | --devel) 156 | DEVEL=1 157 | shift 158 | ;; 159 | --docs) 160 | PRESET=docs 161 | shift 162 | ;; 163 | -i | --image) 164 | CONTAINER_IMAGE="$2" 165 | shift 2 166 | ;; 167 | -t | --tag) 168 | CONTAINER_TAG="$2" 169 | shift 2 170 | ;; 171 | # Additional container env vars 172 | -e | --env | --environment) 173 | CONTAINER_ENV+=("$2") 174 | shift 2 175 | ;; 176 | # Additional container volumes 177 | -v | --volume) 178 | CONTAINER_VOLUMES+=("$2") 179 | shift 2 180 | ;; 181 | # Whether to wrap the command in zsh -silc 182 | -w | --wrap) 183 | WRAP_CMD=1 184 | shift 185 | ;; 186 | --tests | --zunit | -z) 187 | PRESET=zunit 188 | shift 189 | ;; 190 | # Whether to enable debug tracing of zinit (zsh -x) 191 | # Only applies to wrapped commands (--w|--wrap) 192 | --zsh-debug | -x | -Z) 193 | ZSH_DEBUG=1 194 | shift 195 | ;; 196 | *) 197 | break 198 | ;; 199 | esac 200 | done 201 | 202 | GIT_ROOT_DIR="$(git rev-parse --show-toplevel)" 203 | CMD=("$@") 204 | 205 | case "$PRESET" in 206 | zunit) 207 | # Mount root of the repo to /src 208 | # Mount /tmp/zunit-zinit to /data 209 | CONTAINER_VOLUMES+=( 210 | "${GIT_ROOT_DIR}:/src" 211 | "${TMPDIR:-/tmp}/zunit-zinit:/data" 212 | ) 213 | CONTAINER_ENV+=( 214 | "QUIET=1" 215 | "NOTHING_FANCY=1" 216 | ) 217 | ;; 218 | docs) 219 | # Mount root of the repo to /src 220 | CONTAINER_VOLUMES+=( 221 | "${GIT_ROOT_DIR}:/src" 222 | ) 223 | CONTAINER_ENV+=( 224 | "QUIET=1" 225 | "NOTHING_FANCY=1" 226 | "LC_ALL=en_US.UTF-8" 227 | ) 228 | CONTAINER_WORKDIR=/src 229 | # shellcheck disable=2016 230 | INIT_CONFIG_VAL='zinit nocompile make'\''prefix=$ZPFX all install'\'' for zdharma-continuum/zshelldoc' 231 | # shellcheck disable=2016 232 | CMD=(zsh -ilsc 233 | 'sudo chown -R "$(id -u):$(id -g)" /src && 234 | @zinit-scheduler burst && 235 | sudo apk add tree && 236 | make -C /src doc') 237 | ;; 238 | esac 239 | 240 | if INIT_CONFIG="$(create_init_config_file "$INIT_CONFIG_VAL")"; then 241 | trap 'rm -vf $INIT_CONFIG' EXIT INT 242 | fi 243 | 244 | if [[ -n $DEVEL ]]; then 245 | # Mount root of the repo to /src 246 | CONTAINER_VOLUMES+=( 247 | "${GIT_ROOT_DIR}:/src" 248 | ) 249 | fi 250 | 251 | run "$INIT_CONFIG" "${CMD[@]}" 252 | fi 253 | 254 | # Local Variables: 255 | # mode: Shell-Script 256 | # sh-indentation: 2 257 | # indent-tabs-mode: nil 258 | # sh-basic-offset: 2 259 | # End: 260 | # vim: ft=bash sw=2 ts=2 et 261 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | { # Colors 4 | COLOR_RESET='' 5 | COLOR_BOLD_RED='' 6 | COLOR_BOLD_GREEN='' 7 | COLOR_BOLD_YELLOW='' 8 | COLOR_BOLD_BLUE='' 9 | COLOR_BOLD_MAGENTA='' 10 | COLOR_BOLD_CYAN='' 11 | 12 | # The over-the-top fancy ones 13 | COLOR_PALE_MAGENTA='' 14 | COLOR_BOLD_WHITE_ON_BLACK='' 15 | } 16 | 17 | echo_fancy() { 18 | emoji="$1" 19 | color="$2" 20 | shift 2 21 | 22 | msg="" 23 | # prepend emoji, unless NO_EMOJI is set 24 | if [ -z "$NO_EMOJI" ]; then 25 | msg="$emoji" 26 | fi 27 | 28 | # wrap every word in color (needed in case there are custom colors in 29 | # the message itself), unless NO_COLOR is set 30 | for str in "$@"; do 31 | # FIXME: NO_COLOR only applies if there are no colors in the msg 32 | if [ -z "$NO_COLOR" ]; then 33 | msg="${msg}${color}" 34 | fi 35 | msg="${msg}${str}" 36 | done 37 | 38 | # Actual output 39 | echo "${msg}${COLOR_RESET}" >&2 40 | # fake "local" vars 41 | unset emoji color str msg 42 | } 43 | 44 | echo_info() { 45 | echo_fancy "🔵" "${COLOR_BOLD_BLUE}" "INFO: ${*}" 46 | } 47 | 48 | echo_success() { 49 | echo_fancy "✅" "${COLOR_BOLD_GREEN}" "SUCCESS: ${*}" 50 | } 51 | 52 | echo_warning() { 53 | echo_fancy "🚧" "${COLOR_BOLD_YELLOW}" "WARNING: ${*}" 54 | } 55 | 56 | echo_error() { 57 | echo_fancy "❌" "${COLOR_BOLD_RED}" "ERROR: ${*}" 58 | } 59 | 60 | check_dependencies() { 61 | zsh_min_version=5.8 62 | if ! zsh -sfc \ 63 | 'autoload is-at-least; 64 | is-at-least $1 $ZSH_VERSION' "$zsh_min_version"; then 65 | echo_warning "ZSH version 5.5+ is recommended for zinit." \ 66 | "It'll still work, but be warned." 67 | fi 68 | 69 | if ! command -v git > /dev/null 2>&1; then 70 | echo_error "${COLOR_BOLD_GREEN}git${COLOR_RESET} is not installed" 71 | exit 1 72 | fi 73 | 74 | unset zsh_min_version 75 | } 76 | 77 | show_environment() { 78 | echo_info "About to setup zinit from $ZINIT_REPO" \ 79 | "(branch: $ZINIT_BRANCH - commit: ${ZINIT_COMMIT:-N/A})" \ 80 | "to ${ZINIT_INSTALL_DIR}" 81 | } 82 | 83 | create_zinit_home() { 84 | if ! test -d "${ZINIT_HOME}"; then 85 | mkdir -p "${ZINIT_HOME}" 86 | chmod g-w "${ZINIT_HOME}" 87 | chmod o-w "${ZINIT_HOME}" 88 | fi 89 | } 90 | 91 | create_zinit_tmpdir() { 92 | # use -d instead of --directory for macos (BSD) compatibility 93 | ZINIT_TMPDIR="$(mktemp -d)" 94 | if [ ! -d "$ZINIT_TMPDIR" ]; then 95 | echo_error "Tempdir creation failed. This ain't good" 96 | exit 1 97 | fi 98 | 99 | trap 'rm -rvf "$ZINIT_TMPDIR"' EXIT INT 100 | } 101 | 102 | # Get the download-progress bar tool 103 | download_git_output_processor() { 104 | url="https://raw.githubusercontent.com/${ZINIT_REPO}/${ZINIT_COMMIT:-${ZINIT_BRANCH}}/share/git-process-output.zsh" 105 | script_path="${ZINIT_TMPDIR}/git-process-output.zsh" 106 | 107 | echo_info "Fetching git-process-output.zsh from $url" 108 | if command -v curl > /dev/null 2>&1; then 109 | curl -fsSL -o "$script_path" "$url" 110 | elif command -v wget > /dev/null 2>&1; then 111 | wget -q -O "$script_path" "$url" 112 | fi 113 | 114 | # shellcheck disable=2181 115 | if [ "$?" -eq 0 ]; then 116 | chmod a+x "$script_path" 2> /dev/null 117 | echo_success 'Download finished!' 118 | else 119 | echo_warning "Download failed." 120 | fi 121 | 122 | unset url script_path 123 | } 124 | 125 | zinit_git_exec() { 126 | command git -C "${ZINIT_INSTALL_DIR}" "$@" 127 | } 128 | 129 | zinit_checkout_ref() { 130 | ref="${ZINIT_BRANCH}" 131 | git_obj_type="branch" 132 | 133 | if [ -n "$ZINIT_COMMIT" ]; then 134 | ref="$ZINIT_COMMIT" 135 | git_obj_type="commit" 136 | fi 137 | 138 | if zinit_git_exec checkout "$ref" > /dev/null 2>&1; then 139 | echo_success "Checked out $git_obj_type $ref" 140 | else 141 | echo_error "Failed to check out $git_obj_type $ref" 142 | fi 143 | 144 | unset ref git_obj_type 145 | } 146 | 147 | zinit_current_version() { 148 | zinit_git_exec describe --tags 2> /dev/null 149 | } 150 | 151 | zinit_update() { 152 | cd "${ZINIT_INSTALL_DIR}" || { 153 | echo_error "Failed to cd to ${ZINIT_INSTALL_DIR}" 154 | exit 1 155 | } 156 | 157 | echo_info "Updating ${COLOR_BOLD_CYAN}zinit${COLOR_RESET} in" \ 158 | "in ${COLOR_BOLD_MAGENTA}${ZINIT_INSTALL_DIR}" 159 | { # Clean up repo 160 | zinit_git_exec clean -d -f -f 161 | zinit_git_exec reset --hard HEAD 162 | } > /dev/null 2>&1 163 | 164 | # fetch our branch (to ensure the target commit exists locally) 165 | zinit_git_exec fetch origin "$ZINIT_BRANCH" 166 | 167 | zinit_checkout_ref 168 | if zinit_git_exec pull origin "$ZINIT_BRANCH"; then 169 | echo_success "Updated zinit to $(zinit_current_version)" 170 | fi 171 | } 172 | 173 | zinit_install() { 174 | cd "${ZINIT_HOME}" || { 175 | echo_error "Failed to cd to ${ZINIT_HOME}" 176 | exit 1 177 | } 178 | 179 | echo_info "Installing ${COLOR_BOLD_CYAN}zinit${COLOR_RESET} to " \ 180 | "${COLOR_BOLD_MAGENTA}${ZINIT_INSTALL_DIR}" 181 | { 182 | command git clone --progress --branch "$ZINIT_BRANCH" \ 183 | "https://github.com/${ZINIT_REPO}" \ 184 | "${ZINIT_REPO_DIR_NAME}" 2>&1 | { 185 | "${ZINIT_TMPDIR}/git-process-output.zsh" || cat 186 | } 187 | } 2> /dev/null 188 | 189 | zinit_checkout_ref 190 | 191 | if [ -d "${ZINIT_REPO_DIR_NAME}" ]; then 192 | echo_success "Zinit succesfully installed to " \ 193 | "${COLOR_BOLD_GREEN}${ZINIT_INSTALL_DIR}" 194 | echo_info "Zinit Version: ${COLOR_BOLD_GREEN}$(zinit_current_version)" 195 | else 196 | echo_error "Failed to install Zinit to ${COLOR_BOLD_YELLOW}${ZINIT_INSTALL_DIR}" 197 | fi 198 | } 199 | 200 | # Modify .zshrc 201 | edit_zshrc() { 202 | rc_update=1 203 | if grep -E '(zinit|zplugin)\.zsh' "${ZSHRC}" > /dev/null 2>&1; then 204 | echo_warning "${ZSHRC} already contains zinit commands. Not making any changes." 205 | rc_update=0 206 | fi 207 | 208 | if [ $rc_update -eq 1 ]; then 209 | echo_info "Updating ${ZSHRC} (10 lines of code, at the bottom)" 210 | zinit_home_escaped=${ZINIT_HOME//$HOME/\$HOME} 211 | command cat <<- EOF >> "$ZSHRC" 212 | 213 | ### Added by Zinit's installer 214 | if [[ ! -f ${zinit_home_escaped}/${ZINIT_REPO_DIR_NAME}/zinit.zsh ]]; then 215 | print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}${ZINIT_REPO}%F{220})…%f" 216 | command mkdir -p "${zinit_home_escaped}" && command chmod g-rwX "${zinit_home_escaped}" 217 | command git clone https://github.com/${ZINIT_REPO} "${zinit_home_escaped}/${ZINIT_REPO_DIR_NAME}" && \\ 218 | print -P "%F{33} %F{34}Installation successful.%f%b" || \\ 219 | print -P "%F{160} The clone has failed.%f%b" 220 | fi 221 | 222 | source "${zinit_home_escaped}/${ZINIT_REPO_DIR_NAME}/zinit.zsh" 223 | autoload -Uz _zinit 224 | (( \${+_comps} )) && _comps[zinit]=_zinit 225 | EOF 226 | fi 227 | 228 | unset rc_update zinit_home_escaped 229 | } 230 | 231 | query_for_annexes() { 232 | zshrc_annex_file="$(mktemp)" 233 | command cat <<- EOF >> "$zshrc_annex_file" 234 | 235 | # Load a few important annexes, without Turbo 236 | # (this is currently required for annexes) 237 | zinit light-mode for \\ 238 | zdharma-continuum/zinit-annex-as-monitor \\ 239 | zdharma-continuum/zinit-annex-bin-gem-node \\ 240 | zdharma-continuum/zinit-annex-patch-dl \\ 241 | zdharma-continuum/zinit-annex-rust 242 | 243 | EOF 244 | # Ask user if we should add the annexes to their zshrc 245 | # If NO_INPUT is set, but NO_ANNEXES is the annexes bit gets appended to the 246 | # config (ie. default to yes if NO_INPUT, unless NO_ANNEXES) 247 | reply=n 248 | if [ -n "$NO_INPUT" ]; then 249 | [ -z "$NO_ANNEXES" ] && reply=y 250 | else 251 | echo "${COLOR_PALE_MAGENTA}${COLOR_RESET} Would you like to add 4 useful plugins" \ 252 | "- the most useful annexes (Zinit extensions that add new" \ 253 | "functions-features to the plugin manager) to the zshrc as well?" \ 254 | "It will be the following snippet:" 255 | command cat "$zshrc_annex_file" 256 | # shellcheck disable=2059 257 | printf "${COLOR_PALE_MAGENTA}${COLOR_RESET} Enter y/n and press Return: " 258 | read -r reply 259 | fi 260 | 261 | if [ "$reply" = y ] || [ "$reply" = Y ]; then 262 | command cat "$zshrc_annex_file" >> "$ZSHRC" 263 | echo_info "Installing annexes" 264 | zsh -ic "@zinit-scheduler burst" 265 | echo_success 'Done!' 266 | else 267 | echo_warning "Skipped the annexes." 268 | fi 269 | 270 | command cat <<- EOF >> "$ZSHRC" 271 | ### End of Zinit's installer chunk 272 | EOF 273 | unset reply zshrc_annex_file 274 | } 275 | 276 | display_tutorial() { 277 | command cat <<- EOF 278 | 279 | 🌻 ${COLOR_BOLD_WHITE_ON_BLACK}Welcome!${COLOR_RESET} 280 | 281 | Now to get started you can check out the following: 282 | 283 | - The ${COLOR_BOLD_WHITE_ON_BLACK}README${COLOR_RESET} section on the ice-modifiers: 284 | 🧊 https://github.com/${ZINIT_REPO}#ice-modifiers 285 | - There's also an ${COLOR_BOLD_WHITE_ON_BLACK}introduction${COLOR_RESET} to Zinit on the wiki: 286 | 📚 https://zdharma-continuum.github.io/zinit/wiki/INTRODUCTION/ 287 | - The ${COLOR_BOLD_WHITE_ON_BLACK}For-Syntax${COLOR_RESET} article on the wiki, which highlights some best practices: 288 | 📖 https://zdharma-continuum.github.io/zinit/wiki/For-Syntax/ 289 | 290 | 💁 Need help? 291 | - 💬 Get in touch with us on Gitter: https://gitter.im/zdharma-continuum 292 | - 🔖 Or on GitHub: https://github.com/zdharma-continuum 293 | EOF 294 | } 295 | 296 | # Globals. Can be overridden. 297 | ZINIT_REPO="${ZINIT_REPO:-zdharma-continuum/zinit}" 298 | ZINIT_BRANCH="${ZINIT_BRANCH:-main}" 299 | ZINIT_COMMIT="${ZINIT_COMMIT:-}" # no default value 300 | ZINIT_HOME="${ZINIT_HOME:-${XDG_DATA_HOME:-${HOME}/.local/share}/zinit}" 301 | ZINIT_REPO_DIR_NAME="${ZINIT_REPO_DIR_NAME:-zinit.git}" 302 | ZINIT_INSTALL_DIR=${ZINIT_INSTALL_DIR:-${ZINIT_HOME}/${ZINIT_REPO_DIR_NAME}} 303 | ZSHRC="${ZSHRC:-${ZDOTDIR:-${HOME}}/.zshrc}" 304 | 305 | show_environment 306 | check_dependencies 307 | create_zinit_home 308 | create_zinit_tmpdir 309 | download_git_output_processor 310 | 311 | if [ -d "${ZINIT_INSTALL_DIR}/.git" ]; then 312 | zinit_update 313 | ZINIT_UPDATE=1 314 | else 315 | zinit_install 316 | fi 317 | 318 | if [ -z "$NO_EDIT" ]; then 319 | edit_zshrc 320 | [ -z "$ZINIT_UPDATE" ] && query_for_annexes 321 | fi 322 | 323 | if [ -z "$NO_TUTORIAL" ]; then 324 | display_tutorial 325 | fi 326 | 327 | # Local Variables: 328 | # mode: Shell-Script 329 | # sh-indentation: 2 330 | # indent-tabs-mode: nil 331 | # sh-basic-offset: 2 332 | # End: 333 | # vim: ft=bash sw=2 ts=2 et 334 | -------------------------------------------------------------------------------- /share/git-process-output.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # 3 | # Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors 4 | # Copyright (c) 2021-2022 zdharma-continuum and contributors 5 | 6 | emulate -LR zsh 7 | 8 | setopt typesetsilent extendedglob warncreateglobal 9 | 10 | { typeset -g COLS="$(tput cols)" } 2>/dev/null 11 | 12 | if (( COLS < 10 )); then 13 | COLS=40 14 | fi 15 | 16 | # Credit to molovo/revolver for the ideas 17 | progress_frames='0.1 ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏' 18 | integer -g cur_frame=1 19 | typeset -F SECONDS=0 last_time=0 20 | 21 | # Alpine Linux doesn't have tput; FreeBSD and Dragonfly BSD have termcap 22 | if whence tput &> /dev/null; then 23 | if [[ $OSTYPE == freebsd* ]] || [[ $OSTYPE == dragonfly* ]]; then 24 | # termcap commands 25 | ZINIT_CNORM='tput ve' 26 | ZINIT_CIVIS='tput vi' 27 | else 28 | # terminfo is more common 29 | ZINIT_CNORM='tput cnorm' 30 | ZINIT_CIVIS='tput civis' 31 | fi 32 | fi 33 | 34 | if (( $+ZINIT_CNORM )); then 35 | trap $ZINIT_CNORM EXIT INT TERM 36 | fi 37 | 38 | local first=1 39 | 40 | # Code by leoj3n 41 | timeline() { 42 | local sp='▚▞'; sp="${sp:$2%2:1}" 43 | # Maximal width is 24 characters 44 | local bar="$(print -f "%.$2s█%0$(($3-$2-1))s" "████████████████████████" "")" 45 | 46 | local -a frames_splitted 47 | frames_splitted=( ${(@zQ)progress_frames} ) 48 | if (( SECONDS - last_time >= frames_splitted[1] )); then 49 | (( cur_frame = (cur_frame+1) % (${#frames_splitted}+1-1) )) 50 | (( cur_frame = cur_frame ? cur_frame : 1 )) 51 | last_time=$SECONDS 52 | fi 53 | 54 | print -nr -- ${frames_splitted[cur_frame+1]}" " 55 | print -nPr "%F{183}" 56 | print -f "%s %s" "${bar// /░}" "" 57 | print -nPr "%f" 58 | } 59 | 60 | # $1 - n. of objects 61 | # $2 - packed objects 62 | # $3 - total objects 63 | # $4 - receiving percentage 64 | # $5 - resolving percentage 65 | print_my_line() { 66 | local col="%F{155}" col3="%F{155}" col4="%F{155}" col5="%F{155}" 67 | [[ -n "${4#...}" && -z "${5#...}" ]] && col3="%F{81}" 68 | [[ -n "${5#...}" ]] && col4="%F{81}" 69 | 70 | if (( COLS >= 70 )); then 71 | print -Pnr -- "${col}OBJ%f: $1, ${col}PACK%f: $2/$3${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} " 72 | elif (( COLS >= 60 )); then 73 | print -Pnr -- "${col}OBJ%f: $1, ${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} " 74 | else 75 | print -Pnr -- "${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} " 76 | fi 77 | 78 | print -n $'\015' 79 | } 80 | 81 | print_my_line_compress() { 82 | local col="%F{155}" col3="%F{155}" col4="%F{155}" col5="%F{155}" 83 | [[ -n "${4#...}" && -z "${5#...}" && -z "${6#...}" ]] && col3="%F{81}" 84 | [[ -n "${5#...}" && -z "${6#...}" ]] && col4="%F{81}" 85 | [[ -n "${6#...}" ]] && col5="%F{81}" 86 | if (( COLS >= 80 )); then 87 | print -Pnr -- "${col}OBJ%f: $1, ${col}PACK%f: $2/$3, ${col3}COMPR%f: $4%%${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} " 88 | elif (( COLS >= 65 )); then 89 | print -Pnr -- "${col}OBJ%f: $1, ${col3}COMPR%f: $4%%${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} " 90 | else 91 | print -Pnr -- "${col}OBJ%f: $1, ${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} " 92 | fi 93 | print -n $'\015' 94 | } 95 | 96 | integer have_1_counting=0 have_2_total=0 have_3_receiving=0 have_4_deltas=0 have_5_compress=0 97 | integer counting_1=0 total_2=0 total_packed_2=0 receiving_3=0 deltas_4=0 compress_5=0 98 | integer loop_count=0 99 | 100 | IFS='' 101 | 102 | [[ $+ZINIT_CIVIS == 1 && -n $TERM ]] && eval $ZINIT_CIVIS 103 | 104 | if [[ -n $TERM ]]; then 105 | 106 | { command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r/\n/' || gstdbuf -o0 gtr '\r' '\n' || cat } |& while read -r line; do 107 | (( ++ loop_count )) 108 | if [[ "$line" = "Cloning into"* ]]; then 109 | print $line 110 | continue 111 | elif [[ "$line" = (#i)*user*name* || "$line" = (#i)*password* ]]; then 112 | print $line 113 | continue 114 | elif [[ "$line" = remote:*~*(Counting|Total|Compressing|Enumerating)* || "$line" = fatal:* ]]; then 115 | print $line 116 | continue 117 | fi 118 | if [[ "$line" = (#b)"remote: Counting objects:"[\ ]#([0-9]##)(*) ]]; then 119 | have_1_counting=1 120 | counting_1="${match[1]}" 121 | fi 122 | if [[ "$line" = (#b)"remote: Enumerating objects:"[\ ]#([0-9]##)(*) ]]; then 123 | have_1_counting=1 124 | counting_1="${match[1]}" 125 | fi 126 | if [[ "$line" = (#b)*"remote: Total"[\ ]#([0-9]##)*"pack-reused"[\ ]#([0-9]##)* ]]; then 127 | have_2_total=1 128 | total_2="${match[1]}" total_packed_2="${match[2]}" 129 | fi 130 | if [[ "$line" = (#b)"Receiving objects:"[\ ]#([0-9]##)%([[:blank:]]#\(([0-9]##)/([0-9]##)\)|)* ]]; then 131 | have_3_receiving=1 132 | receiving_3="${match[1]}" 133 | if [[ -n "${match[2]}" ]]; then 134 | have_2_total=1 135 | total_packed_2="${match[3]}" total_2="${match[4]}" 136 | fi 137 | fi 138 | 139 | if [[ "$line" = (#b)"Resolving deltas:"[\ ]#([0-9]##)%* ]]; then 140 | have_4_deltas=1 141 | deltas_4="${match[1]}" 142 | fi 143 | 144 | if [[ "$line" = (#b)"remote: Compressing objects:"[\ ]#([0-9]##)"%"(*) ]]; then 145 | have_5_compress=1 146 | compress_5="${match[1]}" 147 | fi 148 | 149 | if (( loop_count >= 2 )); then 150 | integer pr 151 | (( pr = have_4_deltas ? deltas_4 / 10 : ( have_3_receiving ? receiving_3 / 10 : ( have_5_compress ? compress_5 / 10 : ((( loop_count - 1 )/14 ) % 10) + 1 )) )) 152 | timeline "" $pr 11 153 | if (( have_5_compress )); then 154 | print_my_line_compress "${${${(M)have_1_counting:#1}:+$counting_1}:-...}" \ 155 | "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \ 156 | "${${${(M)have_2_total:#1}:+$total_2}:-0}" \ 157 | "${${${(M)have_5_compress:#1}:+$compress_5}:-...}" \ 158 | "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \ 159 | "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}" 160 | else 161 | print_my_line "${${${(M)have_1_counting:#1}:+$counting_1}:-...}" \ 162 | "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \ 163 | "${${${(M)have_2_total:#1}:+$total_2}:-0}" \ 164 | "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \ 165 | "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}" 166 | fi 167 | fi 168 | done 169 | 170 | else 171 | grep fatal: 172 | fi 173 | 174 | print 175 | 176 | [[ $+ZINIT_CNORM == 1 && -n $TERM ]] && eval $ZINIT_CNORM 177 | 178 | unset ZINIT_CNORM ZINIT_CIVIS 179 | 180 | # Local Variables: 181 | # mode: Shell-Script 182 | # sh-indentation: 2 183 | # indent-tabs-mode: nil 184 | # sh-basic-offset: 2 185 | # End: 186 | # vim: ft=zsh sw=2 ts=2 et 187 | -------------------------------------------------------------------------------- /share/rpm2cpio.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # 3 | # -*- mode: sh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- 4 | # 5 | # Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors 6 | # Copyright (c) 2021-2022 zdharma-continuum and contributors 7 | 8 | emulate -R zsh -o extendedglob 9 | 10 | local pkg=$1 11 | if [[ -z $pkg || ! -e $pkg ]]; then 12 | print -u2 -Pr "%F{160}rpm2cpio.sh%f: no package supplied" 13 | exit 1 14 | fi 15 | 16 | local leadsize=96 17 | local o=$(( $leadsize + 8 )) 18 | set -- ${(s: :)$(od -j $o -N 8 -t u1 $pkg)} 19 | local i=$(( 256 * ( 256 * ( 256 * $2 + $3 ) + $4 ) + $5 )) 20 | local d=$(( 256 * ( 256 * ( 256 * $6 + $7 ) + $8 ) + $9 )) 21 | 22 | sigsize=$(( 8 + 16 * $i + $d )) 23 | o=$(( $o + $sigsize + ( 8 - ( $sigsize % 8 ) ) % 8 + 8 )) 24 | set -- ${(s: :)$(od -j $o -N 8 -t u1 $pkg)} 25 | i=$(( 256 * ( 256 * ( 256 * $2 + $3 ) + $4 ) + $5 )) 26 | d=$(( 256 * ( 256 * ( 256 * $6 + $7 ) + $8 ) + $9 )) 27 | 28 | local hdrsize=$(( 8 + 16 * $i + $d )) 29 | o=$(( $o + $hdrsize )) 30 | local -a UNPACKCMD 31 | UNPACKCMD=( dd if=$pkg ibs=$o skip=1 ) 32 | 33 | local COMPRESSION="$($=UNPACKCMD | file -)" 34 | local -a DECOMPRESSCMD 35 | 36 | if [[ $COMPRESSION == (#i)*gzip* ]]; then 37 | DECOMPRESSCMD=( gunzip ) 38 | elif [[ $COMPRESSION == (#i)*bzip2* ]]; then 39 | DECOMPRESSCMD=( bunzip2 ) 40 | elif [[ $COMPRESSION == (#i)*xz* ]]; then 41 | DECOMPRESSCMD=( unxz ) 42 | elif [[ $COMPRESSION == (#i)*cpio* ]]; then 43 | DECOMPRESSCMD=( cat ) 44 | else 45 | DECOMPRESSCMD=( $(which unlzma 2>/dev/null) ) 46 | if [[ $DECOMPRESSCMD != /* ]]; then 47 | DECOMPRESSCMD=( $(which lzmash 2>/dev/null) ) 48 | if [[ $DECOMPRESSCMD == /* ]]; then 49 | DECOMPRESSCMD=( lzmash -d -c ) 50 | else 51 | DECOMPRESSCMD=( cat ) 52 | fi 53 | fi 54 | fi 55 | 56 | command "$UNPACKCMD[@]" 2>/dev/null | command "$DECOMPRESSCMD[@]" 57 | 58 | # Local Variables: 59 | # mode: Shell-Script 60 | # sh-indentation: 2 61 | # indent-tabs-mode: nil 62 | # sh-basic-offset: 2 63 | # End: 64 | # vim: ft=zsh sw=2 ts=2 et 65 | -------------------------------------------------------------------------------- /share/template-plugin/template-script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # 3 | # Copyright (c) YEAR USER_NAME 4 | 5 | # An example of type-agnostic script/function, i.e.: the file can be run as a +x 6 | # script or as an autoload function. 7 | 8 | # Set the base and typically useful options 9 | emulate -LR zsh 10 | setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes noautopushd 11 | 12 | # Run as script? ZSH_SCRIPT is a Zsh 5.3 addition 13 | if [[ $0 != template-script || -n $ZSH_SCRIPT ]]; then 14 | # Handle $0 according to the Zsh Plugin Standard: 15 | # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html 16 | 0=${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}} 17 | 0=${${(M)0##/*}:-$PWD/$0} 18 | 19 | # Such global variable is expected to be typeset'd -g in the plugin.zsh 20 | # file. Here it's restored in case of the function being run as a script. 21 | typeset -gA Plugins 22 | Plugins[MY_PLUGIN_DIR]=${0:h} 23 | 24 | # In case of the script using other scripts from the plugin, either set up 25 | # $fpath and autoload, or add the directory to $PATH. 26 | fpath+=( $Plugins[MY_PLUGIN_DIR] ) 27 | autoload … 28 | 29 | # OR 30 | path+=( $Plugins[MY_PLUGIN_DIR] ) 31 | fi 32 | 33 | # The script/function contents possibly using $Plugins[MY_PLUGIN_DIR] … 34 | # … 35 | 36 | # Use alternate marks [[[ and ]]] as the original ones can confuse nested 37 | # substitutions, e.g.: ${${${VAR}}} 38 | 39 | # Local Variables: 40 | # mode: Shell-Script 41 | # sh-indentation: 2 42 | # indent-tabs-mode: nil 43 | # sh-basic-offset: 2 44 | # End: 45 | # vim: ft=zsh sw=2 ts=2 et foldmarker=[[[,]]] foldmethod=marker 46 | -------------------------------------------------------------------------------- /share/template-plugin/zsh.gitignore: -------------------------------------------------------------------------------- 1 | # Zsh compiled script + zrecompile backup 2 | *.zwc 3 | *.zwc.old 4 | 5 | # Zsh completion-optimization dumpfile 6 | *zcompdump* 7 | 8 | # Zsh zcalc history 9 | .zcalc_history 10 | 11 | # A popular plugin manager's files 12 | ._zinit 13 | .zinit_lastupd 14 | 15 | # zdharma/zshelldoc tool's files 16 | zsdoc/data 17 | 18 | # ohmyzsh/ohmyzsh/plugins/per-directory-history plugin's files 19 | # (when set-up to store the history in the local directory) 20 | .directory_history 21 | 22 | # MichaelAquilina/zsh-autoswitch-virtualenv plugin's files 23 | # (for Zsh plugins using Python) 24 | .venv 25 | 26 | # Zunit tests' output 27 | /tests/_output/* 28 | !/tests/_output/.gitkeep 29 | -------------------------------------------------------------------------------- /share/zsh.ctags: -------------------------------------------------------------------------------- 1 | # 2 | # Language: Zsh 3 | # 4 | 5 | --langdef=zsh 6 | --langmap=zsh:.zsh 7 | 8 | # 9 | # 1. Detect variables 10 | # 2. … and function names. 11 | # 12 | 13 | --kinddef-zsh=v,var,variables 14 | --kinddef-zsh=f,fun,functions 15 | 16 | --_tabledef-zsh=main 17 | --_tabledef-zsh=vardef 18 | --_tabledef-zsh=comment 19 | --_tabledef-zsh=equal 20 | 21 | # Feature: Zsh variable detection 22 | --_mtable-regex-zsh=main/^\s*(local|typeset|declare|integer|float|readonly)\s+(-\w+\s+)*///{tenter=vardef} 23 | # Feature: Zsh function name detection 24 | --_mtable-regex-zsh=main/^\s*(function\s+|)([[:alnum:]:@∞.+-]+)\(\s*\)\s*([\{]|[\n]+[\{])/\2/f/ 25 | --_mtable-regex-zsh=main/^\s*[\#][^\n]*///{tenter=comment} 26 | --_mtable-regex-zsh=main/.// 27 | 28 | --_mtable-regex-zsh=comment/[\n]///{tleave} 29 | --_mtable-regex-zsh=comment/.// 30 | 31 | --_mtable-regex-zsh=equal/([\"][^\"]*[\"])///{exclusive}{tleave} 32 | --_mtable-regex-zsh=equal/([\'][^\']*[\'])///{exclusive}{tleave} 33 | --_mtable-regex-zsh=equal/([\$][\(][\(])([^\)][^\)])*([^\)]){0,1}([\)][\)])///{exclusive}{tleave} 34 | --_mtable-regex-zsh=equal/([\$][\(])([^\)]*)([\)])///{exclusive}{tleave} 35 | --_mtable-regex-zsh=equal/([\(])([^\)]*)([\)])///{exclusive}{tleave} 36 | # Try to match sequences of ${…}\w${…}… 37 | --_mtable-regex-zsh=equal/([\$][\{])((([^\}]*[\}][^\s][\$][\{])*[^\}]*)|[^\}]*)([\}])///{exclusive}{tleave} 38 | --_mtable-regex-zsh=equal/[^\s\n]+///{exclusive}{tleave}{_advanceTo=0start}  39 | --_mtable-regex-zsh=equal/[\n\s]///{exclusive}{tleave}{_advanceTo=0start} 40 | 41 | # Match with required ="… 42 | --_mtable-regex-zsh=vardef/([a-zA-Z_]\w*)([\=])/\1/v/{exclusive}{tenter=equal} 43 | --_mtable-regex-zsh=vardef/([a-zA-Z_]\w*)/\1/v/{exclusive} 44 | --_mtable-regex-zsh=vardef/[\x5C][\n]///{exclusive} 45 | --_mtable-regex-zsh=vardef/([\n;\}\)\|\&])///{tleave}{exclusive} 46 | --_mtable-regex-zsh=vardef/^\s*[\#][^\n]*///{tenter=comment}{exclusive} 47 | --_mtable-regex-zsh=vardef/.// 48 | -------------------------------------------------------------------------------- /tests/_output/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zdharma-continuum/zinit/9a3e5c97975accfdde54e4a5810150212a41b898/tests/_output/.gitkeep -------------------------------------------------------------------------------- /tests/_support/annex_test_assertions: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | is_annex() { 4 | local annex="zinit-annex-${1}" 5 | run zinit load zdharma-continuum/${annex} 6 | assert ${state} equals 0 7 | zinit cd zdharma-continuum/${annex} 8 | assert ${PWD}/${${annex}//zinit-annex/z-a}.plugin.zsh is_file 9 | assert ${PWD}/${${annex}//zinit-annex/z-a}.plugin.zsh is_readable 10 | } 11 | 12 | load_bin_gem_node(){ 13 | run zinit load @zdharma-continuum/zinit-annex-bin-gem-node 14 | zinit default-ice from'gh-r' 15 | } 16 | -------------------------------------------------------------------------------- /tests/_support/bootstrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | # emulate -L zsh 4 | # setopt no_global_rcs no_rcs no_aliases extended_glob null_glob 5 | 6 | emulate zsh 7 | setopt no_global_rcs no_rcs no_aliases extended_glob 8 | 9 | # Log functions [[[ 10 | function error(){ print -P "%F{red}[ERROR]%f: ${1}" && return 1; } 11 | function info() { print -P "%F{green}[INFO]%f:%F{cyan} ${1} %f"; } 12 | function warn() { print -P "%F{yellow}[WARN]%f: ${1}"; } 13 | # ]]] 14 | # Create Zunit test environment [[[ 15 | GIT_REPO=$(git rev-parse --show-toplevel) 16 | 17 | _mktemp_cmd='mktemp' 18 | if (( ${+commands[gmktemp]} )); then 19 | _mktemp_cmd='gmktemp' 20 | fi 21 | TMP_ZUNIT=$(${_mktemp_cmd} --directory --tmpdir="${GIT_REPO}/tests/_support") 22 | if [[ ! -d ${TMP_ZUNIT} ]]; then 23 | error "zunit temp dir not found" 24 | exit 1 25 | fi 26 | 27 | typeset -gx zi_test_dir="${TMP_ZUNIT}" 28 | typeset -gxAUH ZINIT=() 29 | ZINIT+=( 30 | BIN_DIR "${zi_test_dir}/zinit.git" 31 | COMPLETIONS_DIR "${zi_test_dir}/completions" SNIPPETS_DIR "${zi_test_dir}/snippets" 32 | HOME_DIR "${zi_test_dir}" PLUGINS_DIR "${zi_test_dir}/plugins" 33 | ZCOMPDUMP_PATH "${zi_test_dir}/zcompdump" ZPFX "${zi_test_dir}/polaris" 34 | POLARIS "${zi_test_dir}/polaris" 35 | ) 36 | typeset -gxH ZPFX= 37 | ZPFX="${zi_test_dir}/polaris" 38 | 39 | command git diff > ${ZINIT[HOME_DIR]}/unstaged.diff 40 | # info 'creating test env' 41 | git clone \ 42 | --quiet \ 43 | --depth=1 \ 44 | --dissociate \ 45 | --no-hardlinks \ 46 | --reference "${GIT_REPO}" \ 47 | file://${GIT_REPO:A} \ 48 | "${ZINIT[BIN_DIR]}" >/dev/null 49 | if (( $? != 0 )); then 50 | error "Unable to copy ${GIT_REPO} to ${TMP_ZUNIT}" >&2 51 | exit 1 52 | fi 53 | 54 | if [[ -s $ZINIT[HOME_DIR]/unstaged.diff ]]; then 55 | ( 56 | git -C "${ZINIT[BIN_DIR]}" apply "${ZINIT[HOME_DIR]}/unstaged.diff" && \ 57 | chmod g-rwX "${ZINIT[HOME_DIR]}" && \ 58 | zcompile "${ZINIT[BIN_DIR]}/zinit.zsh" >/dev/null 59 | ) >/dev/null 60 | fi 61 | (( $? != 0 )) && { error "Unable to copy ${GIT_REPO} to ${TMP_ZUNIT}" >&2; exit 1 } 62 | 63 | hash -f 64 | builtin hash -d zinit="${zi_test_dir}" 65 | builtin hash -d zpfx="${zi_test_dir}/polaris" 66 | builtin hash -d plugins="${zi_test_dir}/plugins" 67 | source "${zi_test_dir}/zinit.git/zinit.zsh" 68 | (( $? != 0 )) && { error "Unable to source zinit" >&2; exit 1 } 69 | hash -f 70 | builtin hash -d zinit="${zi_test_dir}" 71 | builtin hash -d zpfx="${zi_test_dir}/polaris" 72 | builtin hash -d plugins="${zi_test_dir}/plugins" 73 | 74 | { 75 | zinit for \ 76 | @zdharma-continuum/zinit-annex-bin-gem-node \ 77 | @zdharma-continuum/zinit-annex-binary-symlink \ 78 | @zdharma-continuum/zinit-annex-default-ice \ 79 | @zdharma-continuum/zinit-annex-linkman 80 | }>/dev/null 81 | 82 | zinit zstatus 83 | -------------------------------------------------------------------------------- /tests/_support/gen-ghr-test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # 3 | # Easily generate gh-r Zunit tests. 4 | # 5 | # Usage: 6 | # gen-ghr-test [...] 7 | # 8 | # Note: Tests might require slight adjustments to the lbin or id-as ice 9 | # 10 | (){ 11 | local flag_help 12 | local -a usage=( 13 | "gen-ghr-test [-h|--help]" 14 | "gen-ghr-test []" 15 | ) 16 | 17 | # -D pulls parsed flags out of $@ 18 | # -E allows flags/args and positionals to be mixed, which we don't want in this example 19 | # -F says fail if we find a flag that wasn't defined 20 | # -M allows us to map option aliases (ie: h=flag_help -help=h) 21 | # -K allows us to set default values without zparseopts overwriting them 22 | # Remember that the first dash is automatically handled, so long options are -opt, not --opt 23 | 24 | zmodload zsh/zutil 25 | zparseopts -D -F -K -- \ 26 | {h,-help}=flag_help \ 27 | || return 1 28 | 29 | [[ -z "$flag_help" ]] || { print -l $usage; return 0 } 30 | 31 | (( !$# )) && { 32 | builtin print -P -- "%F{red}Error%f gen-ghr-test requires one or more arguments" 33 | return 1 34 | } 35 | 36 | local repo description bin_name 37 | for repo in $@; do 38 | bin_name="${repo:t}" 39 | description="$(gh search repos "${repo}" --limit 1 --json description -q '.[].[]')" 40 | cat <<- EOF 41 | @test '${bin_name}' { # ${description} 42 | run zinit for @${repo}; assert \$state equals 0 43 | local $bin_name="\$ZBIN/${bin_name}"; assert "\$${bin_name}" is_executable 44 | run "\$${bin_name}" --version; assert \$state equals 0 45 | } 46 | EOF 47 | done 48 | } $@ 49 | 50 | # vim: set expandtab filetype=zsh shiftwidth=2 softtabstop=2 tabstop=2: 51 | -------------------------------------------------------------------------------- /tests/annexes.zunit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zunit 2 | 3 | @setup { 4 | load "${PWD}/tests/_support/annex_test_assertions" 5 | } 6 | 7 | @test 'zinit-annex-bin-gem-node' { 8 | is_annex "bin-gem-node" 9 | } 10 | @test 'zinit-annex-binary-symlink' { 11 | is_annex "binary-symlink" 12 | } 13 | @test 'zinit-annex-man' { 14 | is_annex "man" 15 | } 16 | @test 'zinit-annex-meta-plugins' { 17 | is_annex "meta-plugins" 18 | } 19 | @test 'zinit-annex-patch-dl' { 20 | is_annex "patch-dl" 21 | } 22 | @test 'zinit-annex-pull' { 23 | is_annex 'pull' 24 | } 25 | @test 'zinit-annex-readurl' { 26 | is_annex 'readurl' 27 | } 28 | @test 'zinit-annex-rust' { 29 | is_annex 'rust' 30 | } 31 | @test 'zinit-annex-submods' { 32 | is_annex 'submods' 33 | } 34 | @test 'zinit-annex-test' { 35 | is_annex 'test' 36 | } 37 | @test 'zinit-annex-unscope' { 38 | is_annex 'unscope' 39 | } 40 | 41 | # vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=marker 42 | -------------------------------------------------------------------------------- /tests/commands.zunit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zunit 2 | # vim:ft=zsh:sw=4:sts=4:et:foldmarker={,}:foldmethod=marker 3 | # 4 | # zdharma-continuum/zinit/tests/commands.zunit 5 | # Copyright (c) 2016-2021 Sebastian Gniazdowski 6 | # Copyright (c) 2021-2024 zdharma-continuum 7 | # Homepage: https://github.com/zdharma-continuum/zinit 8 | # License: MIT License 9 | # 10 | 11 | @setup { 12 | typeset -gx HOME="$zi_test_dir" 13 | typeset -gx ZBIN="$zi_test_dir/polaris/bin" 14 | } 15 | 16 | @test 'help' { 17 | for cmd in 'help' '-h' '--help'; do 18 | run zinit $cmd 19 | assert $output contains '—— help – usage information' 20 | assert $state equals 0 21 | done 22 | run zinit -help 23 | assert $output contains 'Unknown subcommand' 24 | assert $state equals 1 25 | } 26 | 27 | @test 'delete --help' { 28 | run zinit delete --help 29 | assert $output contains 'zinit delete [options] [plugins...]' 30 | assert $state equals 0 31 | } 32 | @test 'delete --all' { 33 | run zinit as'completion' is-snippet for @'https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker' 34 | assert $state equals 0 35 | } 36 | @test 'delete a snippet' { 37 | run zinit id-as'git.zsh' is-snippet for @'OMZL::git.zsh' 38 | run zinit delete --yes 'git.zsh' 39 | assert $state equals 0 40 | } 41 | @test 'delete a plugin' { 42 | run zinit from'gh-r' as'program' id-as mv'shfmt* -> shfmt' for @'mvdan/sh' 43 | run zinit delete --yes sh 44 | assert $state equals 0 45 | } 46 | @test 'delete a program' { 47 | run zinit as'program' cp'wd.sh->wd' mv'_wd.sh->_wd' pick'wd' completions for @'mfaerevaag/wd' 48 | assert $state equals 0 49 | run return ${+commands[wd]}; assert $state equals 0 50 | run zinit delete --yes mfaerevaag/wd 51 | } 52 | 53 | @test 'plugins' { 54 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit plugins) 55 | assert $state equals 0 56 | assert $output contains "==> 5 Plugins" 57 | assert $output contains 'Loaded: L | Unloaded: U' 58 | } 59 | @test 'plugins with keyword' { 60 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit plugins zdharma) 61 | assert $state equals 0 62 | assert $output contains "==> 4 Plugins matching 'zdharma'" 63 | } 64 | 65 | @test 'self-update' { 66 | run zinit self-update 67 | assert $output contains 'Already up-to-date.' 68 | assert $state equals 0 69 | } 70 | @test 'set-debug' { 71 | ZINIT+=(DEBUG 'true') 72 | run +zi-log -n '{dbg} message' 73 | assert $output contains '[debug]'; assert $state equals 0 74 | } 75 | @test 'unset-dbg' { 76 | run +zi-log -n '{dbg} message'; assert $output contains '' 77 | run +zi-log -n '{m} message' 78 | assert $output contains 'message'; assert $state equals 0 79 | } 80 | -------------------------------------------------------------------------------- /tests/compile.zunit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zunit 2 | # vim:ft=zsh:sw=4:sts=4:et:foldmarker={,}:foldmethod=marker 3 | 4 | @setup { 5 | typeset -gx HOME="$zi_test_dir" 6 | typeset -gx ZBIN="$zi_test_dir/polaris/bin" 7 | } 8 | 9 | @test 'compile ice - multiple files' { 10 | run zinit for compile'h*~*zwc' id-as'hsmw-compile-ice' @zdharma-continuum/history-search-multi-word 11 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit compile hsmw-compile-ice) 12 | assert $output contains "==> Compiling 4 files history-search-multi-word, history-search-multi-word.plugin.zsh, hsmw-context-main, hsmw-highlight [OK]" 13 | assert $state equals 0 14 | } 15 | @test 'compile ice - single file' { 16 | run zinit for id-as'hsmw-no-compile-ice' @zdharma-continuum/history-search-multi-word 17 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit compile hsmw-no-compile-ice) 18 | assert $state equals 0 19 | assert $output contains "==> Compiling history-search-multi-word.plugin.zsh [OK]" 20 | } 21 | @test 'compile ice' { 22 | run zinit light @zdharma-continuum/history-search-multi-word 23 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit compile zdharma-continuum/history-search-multi-word) 24 | assert $state equals 0 25 | assert $output contains "==> Compiling history-search-multi-word.plugin.zsh [OK]" 26 | } 27 | 28 | @test 'compile cmd' { 29 | run zinit for id-as"compile-command" @zdharma-continuum/history-search-multi-word 30 | 31 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit compile --quiet compile-command) 32 | assert $state equals 0 33 | assert $output contains "==> Compiling history-search-multi-word.plugin.zsh [OK]" 34 | 35 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit compiled) 36 | assert $state equals 0 37 | assert $output contains 'compile-command:' 38 | 39 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit uncompile --quiet compile-command) 40 | assert $state equals 0; assert $output contains '==> Uncompiling compile-command [OK]' 41 | } 42 | @test 'compiled cmd' { 43 | zinit uncompile --all --quiet 44 | run zinit compiled; assert $state equals 0 45 | assert $output contains 'No compiled plugins' 46 | } 47 | @test 'uncompile cmd' { 48 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit compile -q compile-command) 49 | assert $state equals 0 50 | run perl -pe 's/\x1b\[[0-9;]*[mG]//g' <(zinit uncompile -q compile-command) 51 | assert $state equals 0 52 | assert $output contains '==> Uncompiling compile-command [OK]' 53 | } 54 | -------------------------------------------------------------------------------- /tests/ices.zunit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zunit 2 | 3 | @setup { 4 | ZPLUGINS=$ZINIT[PLUGINS_DIR] 5 | function _zunit_assert_not_exists(){ 6 | local file_path=$1 7 | if [[ "${file_path:0:1}" != "/" ]]; then # relative path - prepend the test directory 8 | filepath="${testdir}/${file_path}" 9 | fi 10 | [[ ! -e "$file_path" ]] && return 0 11 | exit "found '${file_path}'" 12 | } 13 | } 14 | 15 | @test 'mv' { 16 | run zinit as"null" id-as"test/mv" mv"readme.md -> mv.md" for zdharma-continuum/null 17 | assert $state equals 0 18 | assert "$ZPLUGINS/test---mv/mv.md" is_file 19 | assert "$ZPLUGINS/test---mv/mv.md" is_readable 20 | assert "$ZPLUGINS/test---mv/readme.md" not_exists 21 | } 22 | @test 'cp' { 23 | run zinit as"null" id-as"test/cp" cp"readme.md -> cp.md" for zdharma-continuum/null 24 | assert $state equals 0 25 | assert "$ZPLUGINS/test---cp/cp.md" is_file 26 | assert "$ZPLUGINS/test---cp/cp.md" is_readable 27 | assert "$ZPLUGINS/test---cp/readme.md" is_file 28 | } 29 | @test 'atclone' { 30 | run zinit as"null" id-as"test/atclone" atclone"mv readme.md atclone.md" for zdharma-continuum/null 31 | assert $state equals 0 32 | assert "$ZPLUGINS/test---atclone/atclone.md" is_file 33 | assert "$ZPLUGINS/test---atclone/atclone.md" is_readable 34 | assert "$ZPLUGINS/test---atclone/readme.md" not_exists 35 | } 36 | @test 'make' { 37 | run zinit as"null" id-as"test/make" atclone"printf 'all:\n\ttouch whatever\n' > Makefile" make"all" for zdharma-continuum/null 38 | assert $state equals 0 39 | assert "$ZPLUGINS/test---make/whatever" is_file 40 | } 41 | @test 'completions' { 42 | run zinit as"null" id-as"test/completions" atclone"touch _whatever" completions for zdharma-continuum/null 43 | assert $state equals 0 44 | assert "$ZPLUGINS/test---completions/_whatever" is_file 45 | assert "$ZINIT[COMPLETIONS_DIR]/_whatever" is_file 46 | } 47 | @test 'completions-overwrite' { 48 | # if both are given, the completions wins 49 | run zinit as"null" id-as"test/completions-overwrite" atclone"touch _whatever2" nocompletions completions for zdharma-continuum/null 50 | assert $state equals 0 51 | assert "$ZPLUGINS/test---completions-overwrite/_whatever2" is_file 52 | assert "$ZINIT[COMPLETIONS_DIR]/_whatever2" is_file 53 | } 54 | @test 'completions-ignored' { 55 | # only the _valid file should be installed as a completion 56 | run zinit as"null" id-as"test/ignored_completions" atclone"touch __init__.py _valid" completions for zdharma-continuum/null 57 | assert $state equals 0 58 | assert "$ZPLUGINS/test---ignored_completions/_valid" is_file 59 | assert "$ZPLUGINS/test---ignored_completions/__init__.py" is_file 60 | assert "$ZINIT[COMPLETIONS_DIR]/_valid" is_file 61 | COMPS=( "$ZINIT[COMPLETIONS_DIR]"/_* ) 62 | assert __init__.py is_not_value_in $COMPS 63 | } 64 | 65 | # vim:ft=zsh:sw=2:sts=2:et:foldmarker=\ {,}:foldmethod=marker 66 | -------------------------------------------------------------------------------- /tests/plugins.zunit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zunit 2 | 3 | @setup { 4 | HOME="$zi_test_dir" 5 | typeset -gx ZBIN="$zi_test_dir/polaris/bin" 6 | } 7 | 8 | # @test 'cmatrix' { 9 | # run zinit build for @abishekvashok/cmatrix; 10 | # local cmatrix="$ZBIN/cmatrix"; assert "$cmatrix" is_executable 11 | # run "$cmatrix" -V; assert $state equals 0 12 | # # ensure cmake artifacts are deleted 13 | # zinit delete --yes abishekvashok/cmatrix; assert $state equals 0 14 | # run "$cmatrix"; assert $state equals 127 15 | # } 16 | @test 'figlet' { 17 | run zinit make for @cmatsuoka/figlet; assert $state equals 0 18 | local figlet="$ZBIN/figlet"; assert "$figlet" is_executable 19 | run "$figlet" -I 1; assert $state equals 0 20 | } 21 | @test 'htop' { 22 | run zinit build for @htop-dev/htop; assert $state equals 0 23 | local htop="$ZBIN/htop"; assert "$htop" is_executable 24 | run "$htop" --version; assert $state equals 0 25 | } 26 | @test 'bash' { 27 | run zinit build for @bminor/bash; assert $state equals 0 28 | local bash="$ZBIN/bash"; assert $bash is_executable 29 | run "$bash" --version; assert $state equals 0 30 | } 31 | @test 'ctags' { 32 | run zinit build for @universal-ctags/ctags; assert $state equals 0 33 | local ctags="$ZBIN/ctags"; assert "$ctags" is_executable 34 | run "$ctags" --version; assert $state equals 0 35 | } 36 | @test 'lua-format' { 37 | run zinit cmake for @Koihik/LuaFormatter; assert $state equals 0 38 | local lua_format="$ZBIN/lua-format"; assert "$lua_format" is_executable 39 | run "$lua_format" --version; assert $state equals 0 40 | run zinit delete --yes Koihik/LuaFormatter; assert $state equals 0 41 | run "$lua_format" --version; assert $state equals 127 42 | } 43 | @test 'jq' { 44 | run zinit build for @jqlang/jq; assert $state equals 0 45 | local jq="$ZBIN/jq"; assert "$jq" is_executable 46 | run "$jq" --version; assert $state equals 0 47 | } 48 | @test 'ncurses' { 49 | run zinit configure'--enable-widec --enable-termcap' make for @mirror/ncurses; assert $state equals 0 50 | local ncurses="$ZBIN/clear"; assert "$ncurses" is_executable 51 | run "$ncurses" -V; assert $state equals 0 52 | run zinit delete --yes mirror/ncurses; assert $state equals 0 53 | run "$ncurses" -V; assert $state equals 127 54 | } 55 | @test 'neofetch' { 56 | run zinit make for @dylanaraps/neofetch; assert $state equals 0 57 | local neofetch="$ZBIN/neofetch"; assert "$neofetch" is_executable 58 | run "$neofetch" --version; assert $state equals 1; assert $output contains 'Neofetch' 59 | } 60 | @test 'neovim-make' { 61 | run zinit make for @neovim/neovim; assert $state equals 0 62 | local neovim="$ZBIN/nvim"; assert $neovim is_executable 63 | run "$neovim" --version; assert $state equals 0 64 | 65 | nvim_ver="$($neovim --version | head -n1 | awk '{print $2}')"; 66 | nvim_commit="$(git --work-tree=$ZINIT[PLUGINS_DIR]/neovim---neovim rev-parse --short HEAD)"; 67 | print -lPr " " "nvim ver: %F{blue}$nvim_ver%f" "nvim commit sha: %F{blue}$nvim_commit%f" "check: [[ %F{blue}$nvim_ver%f = %F{blue}*$nvim_commit(#e)%f ]]" 68 | [[ $nvim_ver = *$nvim_commit(#e) ]] && print -P "%F{green}ok%f" 69 | run zinit delete --yes neovim/neovim; assert $state equals 0 70 | run "$neovim" --version; assert $state equals 127 71 | } 72 | # @test 'neovim-cmake' { 73 | # run zinit cmake for @neovim/neovim; assert $state equals 0 74 | # local neovim="$ZBIN/nvim"; assert $neovim is_executable 75 | # run "$neovim" --version; assert $state equals 0 76 | # 77 | # nvim_ver="$($neovim --version | head -n1 | awk '{print $2}')"; 78 | # nvim_commit="$(git --work-tree=$ZINIT[PLUGINS_DIR]/neovim---neovim rev-parse --short HEAD)"; 79 | # print -lPr " " "nvim ver: %F{blue}$nvim_ver%f" "nvim commit sha: %F{blue}$nvim_commit%f" "check: [[ %F{blue}$nvim_ver%f = %F{blue}*$nvim_commit(#e)%f ]]" 80 | # [[ $nvim_ver = *$nvim_commit(#e) ]] && print -P "%F{green}ok%f" 81 | # 82 | # run zinit delete --yes neovim/neovim; assert $state equals 0 83 | # } 84 | @test 'tmux' { 85 | if [[ $OSTYPE =~ 'darwin*' ]]; then 86 | run zinit configure'--disable-utf8proc' make for @tmux/tmux; assert $state equals 0 87 | else 88 | run zinit build for @tmux/tmux; assert $state equals 0 89 | fi 90 | local tmux="$ZBIN/tmux"; assert $tmux is_executable 91 | run "$tmux" -V; assert $state equals 0 92 | run zinit delete --yes tmux/tmux; assert $state equals 0 93 | run "$tmux" -V; assert $state equals 127 94 | } 95 | @test 'vim' { 96 | run zinit build for @vim/vim; assert $state equals 0 97 | local vim="$ZBIN/vim"; assert $vim is_executable 98 | run "$vim" --version; assert $state equals 0 99 | # run zinit delete --yes vim/vim; assert $state equals 0 100 | } 101 | @test 'zsh' { 102 | # run zinit configure'--with-tcsetpgrp' make'install.bin' for @zsh-users/zsh; assert $state equals 0 103 | run zinit configure'--with-tcsetpgrp' atclone"./Util/preconfig" make'install.bin' for @zsh-users/zsh; assert $state equals 0 104 | local zsh="$ZBIN/zsh"; assert $zsh is_executable 105 | run "$zsh" --version; assert $state equals 0 106 | run zinit delete --yes zsh-users/zsh; assert $state equals 0 107 | run "$zsh" --version; assert $state equals 127 108 | } 109 | 110 | # =========== 111 | # Flaky tests 112 | # =========== 113 | # @test 'stow' { 114 | # run zinit configure'--without-pmdir' make for @aspiers/stow; assert $state equals 0 115 | # local stow="$ZBIN/stow"; assert "$stow" is_executable 116 | # run "$stow" --version; assert $state equals 0 117 | # } 118 | # @test 'zsh-completions' { 119 | # run zinit light-mode for zsh-users/zsh-completions 120 | # zinit cd zsh-users/zsh-completions 121 | # run zinit creinstall -q .; assert $state equals 0 122 | # local broken_completions=($(echo "$ZINIT[COMPLETIONS_DIR]"/*(-@N))); assert "$#broken_completions[@]" equals 0 123 | # } 124 | 125 | # vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=indent 126 | -------------------------------------------------------------------------------- /tests/snippets.zunit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zunit 2 | 3 | @setup { 4 | GH_RAW_URL='https://raw.githubusercontent.com' 5 | setup_snippet_ok() { # state=$1, output=$2, file=$3 6 | assert $1 equals 0 7 | assert $2 contains "Setting up snippet" 8 | assert $3 is_file; assert $3 is_readable 9 | } 10 | install_completion(){ 11 | zinit for as'completion' nocompile id-as"$1" is-snippet "$GH_RAW_URL/$2" 12 | } 13 | } 14 | 15 | @test 'OMZL::spectrum.zsh' { 16 | run zinit snippet OMZL::spectrum.zsh 17 | setup_snippet_ok $state $output "$ZINIT[SNIPPETS_DIR]/OMZL::spectrum.zsh/OMZL::spectrum.zsh" 18 | } 19 | @test 'OMZP::git' { 20 | run zinit snippet OMZP::git 21 | setup_snippet_ok $state $output "$ZINIT[SNIPPETS_DIR]/OMZP::git/OMZP::git" 22 | } 23 | @test 'PZTM::environment' { 24 | run zinit snippet PZTM::environment 25 | setup_snippet_ok $state $output "$ZINIT[SNIPPETS_DIR]/PZTM::environment/PZTM::environment" 26 | } 27 | 28 | @test 'bat-completion' { 29 | run install_completion 'bat-completion/_bat' 'sharkdp/bat/master/assets/completions/bat.zsh.in' 30 | setup_snippet_ok $state $output "$ZINIT[COMPLETIONS_DIR]"/_bat 31 | } 32 | @test 'brew-completion' { 33 | run install_completion 'brew-completion/_brew' 'Homebrew/brew/master/completions/zsh/_brew' 34 | setup_snippet_ok $state $output "$ZINIT[COMPLETIONS_DIR]"/_brew 35 | } 36 | @test 'docker-completion' { 37 | run install_completion 'docker-completion/_docker' 'docker/cli/master/contrib/completion/zsh/_docker' 38 | setup_snippet_ok $state $output "$ZINIT[COMPLETIONS_DIR]"/_docker 39 | } 40 | @test 'exa-completion' { 41 | run install_completion 'exa-completion/_exa' 'ogham/exa/master/completions/zsh/_exa' 42 | setup_snippet_ok $state $output "$ZINIT[COMPLETIONS_DIR]"/_exa 43 | } 44 | @test 'fd-completion' { 45 | run install_completion 'fd-completion/_fd' 'sharkdp/fd/master/contrib/completion/_fd' 46 | setup_snippet_ok $state $output "$ZINIT[COMPLETIONS_DIR]"/_fd 47 | } 48 | @test 'tldr-completion::snippet' { 49 | run install_completion 'tldr-completion/_tldr' 'tealdeer-rs/tealdeer/main/completion/zsh_tealdeer' 50 | setup_snippet_ok $state $output "$ZINIT[COMPLETIONS_DIR]"/_tldr 51 | zinit delete --yes tldr-completion/_tldr; zinit cclear 52 | } 53 | @test 'tldr-completion::gh-r' { 54 | artifact="$ZINIT[PLUGINS_DIR]/tldr-completion---gh-r" 55 | run zinit for as"completion" from"gh-r" id-as'tldr-completion/gh-r' bpick"completions_zsh" mv"completions_zsh -> _tldr_ghr" pick"_tldr_ghr" @tealdeer-rs/tealdeer 56 | assert $state equals 0 57 | assert "$artifact/_tldr_ghr" is_file 58 | assert $artifact/_tldr_ghr is_readable 59 | assert "$ZINIT[COMPLETIONS_DIR]"/_tldr_ghr is_file 60 | assert "$ZINIT[COMPLETIONS_DIR]"/_tldr_ghr is_readable 61 | } 62 | @test 'zinit local snippet symlink' { 63 | mkdir -p "${ZINIT[HOME_DIR]}/external" 64 | local actual="${ZINIT[HOME_DIR]}/external/mysnippet.zsh" 65 | cat<$actual 66 | alias foo=date 67 | EOF 68 | run zinit is-snippet link nocompile id-as'mysnippet' for $actual 69 | 70 | assert $state equals 0 71 | assert "$output" contains "Setting up snippet" 72 | assert "$output" contains "Linking" 73 | 74 | local artifact="${ZINIT[SNIPPETS_DIR]}/mysnippet/mysnippet" 75 | assert $artifact is_link 76 | assert $artifact is_readable 77 | 78 | local link="$(readlink "$artifact")" 79 | local target="$(cd ${artifact:h}; cd ${link:h}; pwd)/${link:t}" 80 | assert $target same_as $actual 81 | } 82 | 83 | 84 | # vim:ft=zsh:sw=2:sts=2:et:foldmarker=@test,}:foldmethod=marker 85 | -------------------------------------------------------------------------------- /zi-browse-symbol: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # This is a Zle widget file. In general, it is s used as (without setup 3 | # provided by the plugin): 4 | # 5 | # autoload browse-symbol 6 | # zle -N browse-symbol 7 | # zle -N browse-symbol-backwards browse-symbol 8 | # zle -N browse-symbol-pbackwards browse-symbol 9 | # zle -N browse-symbol-pforwards browse-symbol 10 | # bindkey "^T" browse-symbol 11 | # 12 | # This will bind to Ctrl-T. The plugin binds to Ctrl-O Ctrl-K. 13 | # 14 | # Example zstyles: 15 | # zstyle ":plugin:zinit:symbol-search" page-size 5 16 | # zstyle ":plugin:zinit:symbol-search" highlight-color "fg=magenta,bold" 17 | # zstyle ":plugin:zinit:symbol-search" heading-color "fg=18,bold" 18 | # zstyle ":plugin:zinit:symbol-search" title-color "fg=180,bold" 19 | # zstyle ":plugin:zinit:symbol-search" arrow-color "fg=180,bg=39,bold" 20 | # zstyle ":plugin:zinit:symbol-search" func-color "fg=208,bold" 21 | # zstyle ":plugin:zinit:symbol-search" var-color "fg=174,bg=39,bold" 22 | # zstyle ":plugin:zinit:symbol-search" macro-color "fg=39,bold" 23 | # zstyle ":plugin:zinit:symbol-search" eqdol-color "fg=183,bg=39,bold" 24 | 25 | emulate -L zsh 26 | setopt typesetsilent extendedglob noshortloops localtraps warncreateglobal 27 | 28 | # When an error, then no cursor keys bindings 29 | zmodload zsh/terminfo 2>/dev/null 30 | zmodload zsh/termcap 2>/dev/null 31 | 32 | typeset -gA TAG 33 | integer -g __tfind_spe_index 34 | integer -g __tfind_spe_restart __tfind_spe_call_count __tfind_spe_funct __tfind_spe_sort 35 | typeset -g __tfind_page_size __tfind_high_color __tfind_heading_color \ 36 | __tfind_title_color __tfind_arrow_color __tfind_func_color \ 37 | __tfind_var_color __tfind_eqdol_color __tfind_macro_color 38 | typeset -gaU __tfind_spe_found 39 | typeset -ga __tfind_tag_data 40 | typeset -g __tfind_git_or_project __tfind_outside_git 41 | local mbegin mend match 42 | local MATCH 43 | integer MBEGIN MEND 44 | 45 | (( __tfind_spe_call_count ++ )) 46 | trap '(( __tfind_spe_call_count -- )); return 0;' INT 47 | 48 | _tfind_find_index() { 49 | local q 50 | local -a p 51 | # Read tags file 52 | p=( (../)#TAGS(N) ) 53 | TAG[file]=${${(On)p}[1]} 54 | [[ -f ./TAGS ]] && TAG[file]=$PWD/TAGS 55 | if [[ -n $TAG[file] ]]; then 56 | TAG[git-or-project]=${${TAG[file]:a}:h:t} 57 | else 58 | TAG[git-or-project]="" 59 | #TAG[file]= 60 | fi 61 | 62 | # Pre-process found index 63 | TAG[file-pp]=${TAG[file]/TAGS/.TAGS}.z 64 | if [[ -n $TAG[file] && -f $TAG[file] && ( ! -f $TAG[file-pp] || $TAG[file] -nt $TAG[file-pp]) ]] 65 | then 66 | local sed_ 67 | (( $+commands[sed] )) && sed_=sed 68 | (( $+commands[gsed] )) && sed_=gsed 69 | # Generate simplified file – append the filename at each line, 70 | # so that it's not only at the preamble line 71 | command $sed_ -r -n $'/^\x0c$/ { n; s/,[^,]*$//;s/^/\x02/; h; d;}; G; y/\\n/,/; p' $TAG[file] >! $TAG[file-pp] 72 | fi 73 | 74 | # Read index, and as index is found, establish git main dir for it 75 | __tfind_outside_git=$TAG[file]:h 76 | if [[ -n $TAG[file] && -f $TAG[file-pp] ]]; then 77 | __tfind_tag_data=( ${"${(@f)"$(<${TAG[file-pp]})"}"##[[:space:]]##} ) 78 | # Cleanup functions and their preambles 79 | __tfind_tag_data=( ${__tfind_tag_data[@]/(#b)(\([^\)]#\))[[:space:]]#[\{]*($'\x7f')/$match[1]$match[2]} ) 80 | __tfind_tag_data=( ${__tfind_tag_data[@]/(#b)[[:space:]]\#*($'\x7f')/$match[1]} ) 81 | __tfind_outside_git="${PWD%/${$(git rev-parse --quiet --show-prefix 2>/dev/null)%/}}" 82 | if [[ -d $__tfind_outside_git && -n ${${(M)PWD##$__tfind_outside_git}##$HOME} ]]; then 83 | TAG[git-or-project]=$__tfind_outside_git:t 84 | TAG[repo-dir]=$__tfind_outside_git 85 | else 86 | TAG[git-or-project]=$TAG[file]:h 87 | TAG[repo-dir]=$TAG[file]:h 88 | fi 89 | return 0 90 | fi 91 | return 1 92 | } 93 | 94 | _tfind_error_msg() 95 | { 96 | integer buflen=$#BUFFER 97 | if [[ -z $TAG[repo-dir] || $TAG[repo-dir] == . ]]; then 98 | POSTDISPLAY=$'\n'"Symbol index NOT found, NO DATA to show, sleeping…" 99 | local search_buffer= 100 | elif [[ $#__tfind_tag_data -eq 0 ]]; then 101 | POSTDISPLAY=$'\n'"The index file contains NO symbol data, forced sleeping..." 102 | local search_buffer= 103 | elif [[ $#__tfind_spe_found -eq 0 && $search_buffer == [[:space:]]# ]]; then 104 | POSTDISPLAY=$'\n'"No items found" 105 | elif [[ $search_buffer != [[:space:]]# && $#__tfind_spe_found -eq 0 ]]; then 106 | POSTDISPLAY=$'\n'"Found 0 matches for query: $search_buffer" 107 | else 108 | return 1 109 | fi 110 | region_highlight+=("$buflen $(( $buflen+$#POSTDISPLAY-$#search_buffer )) fg=179,bold") 111 | region_highlight+=("$(( $buflen+$#POSTDISPLAY-$#search_buffer )) $(( $buflen+$#POSTDISPLAY )) fg=39,bold") 112 | # Number? 113 | [[ -n ${#${(MS)POSTDISPLAY##<->##}} ]] && \ 114 | region_highlight+=("$((buflen+7)) $((buflen+7+${#${(MS)POSTDISPLAY##<->##}})) fg=39,bold") 115 | return 0 116 | 117 | } 118 | _tfind_main() { 119 | local match mbegin mend 120 | local MATCH 121 | integer MBEGIN MEND buflen=${#BUFFER} 122 | TAG[fun-xt-chars]='+.:@\/→↓←↑\$,_\--' 123 | # First call or restart? 124 | if [[ $__tfind_spe_call_count -le 1 || $__tfind_spe_restart = 1 ]]; then 125 | if [[ $__tfind_spe_call_count -le 1 ]]; then 126 | # Read configuration data 127 | zstyle -s ":plugin:zinit:symbol-search" page-size __tfind_page_size || __tfind_page_size=$(( LINES / 3 )) 128 | zstyle -s ":plugin:zinit:symbol-search" highlight-color __tfind_high_color || __tfind_high_color="fg=39,bold" 129 | zstyle -s ":plugin:zinit:symbol-search" heading-color __tfind_heading_color || __tfind_heading_color="fg=69,bold" 130 | zstyle -s ":plugin:zinit:symbol-search" title-color __tfind_title_color || __tfind_title_color="fg=208,bold" 131 | zstyle -s ":plugin:zinit:symbol-search" arrow-color __tfind_arrow_color || __tfind_arrow_color="fg=227,bg=69,bold" 132 | zstyle -s ":plugin:zini t:symbol-search" var-color __tfind_var_color || __tfind_var_color="fg=127,bold" 133 | zstyle -s ":plugin:zinit:symbol-search" func-color __tfind_func_color || __tfind_func_color="fg=70,bold" 134 | zstyle -s ":plugin:zinit:symbol-search" macro-color __tfind_macro_color || __tfind_macro_color="fg=208,bold" 135 | zstyle -s ":plugin:zinit:symbol-search" eqdol-color __tfind_eqdol_color || __tfind_eqdol_color="fg=69,bold" 136 | 137 | # Find the index to operate on, git dir, etc. 138 | _tfind_find_index || { _tfind_error_msg && return;} 139 | fi 140 | 141 | # '0' will get changed into $to_display limit 142 | [[ $WIDGET = *-symbol || $WIDGET = *-pforwards ]] && __tfind_spe_index=1 143 | [[ $WIDGET = *-backwards || $WIDGET = *-pbackwards ]] && __tfind_spe_index=0 144 | __tfind_spe_found=() 145 | __tfind_spe_restart=0 146 | else 147 | # Consecutive call 148 | [[ $WIDGET = *-symbol ]] && (( __tfind_spe_index ++ )) 149 | [[ $WIDGET = *-backwards ]] && (( __tfind_spe_index -- )) 150 | [[ $WIDGET = *-pforwards ]] && (( __tfind_spe_index = __tfind_spe_index + __tfind_page_size )) 151 | [[ $WIDGET = *-pbackwards ]] && (( __tfind_spe_index = __tfind_spe_index - __tfind_page_size )) 152 | fi 153 | 154 | # Find history entries matching pattern *word1*~^*word2*~^*word3* etc. 155 | local search_buffer="${BUFFER%% ##}" search_pattern="" csearch_pattern="" 156 | search_buffer="${${search_buffer## ##}%% ##}" 157 | search_buffer="${search_buffer//(#m)[][*?|#~^()><\\]/\\$MATCH}" 158 | search_pattern="*${search_buffer// ##/*~^*}*" 159 | csearch_pattern="${search_buffer// ##/|}" 160 | 161 | if [[ $#__tfind_spe_found -eq 0 ]]; then 162 | # The repeat will make the matching work on a fresh heap arena 163 | repeat 1; do 164 | # Match only before ^? ($'\177') 165 | __tfind_spe_found=( "${(@M)__tfind_tag_data:#(#i)$~search_pattern*$'\177'*}" ) 166 | ((__tfind_spe_funct)) && __tfind_spe_found=(${(M)__tfind_spe_found:#[[:alnum:]$TAG[fun-xt-chars]]##[[:space:]]#\([^\)]#\)[[:space:]]#(\{|)*}) 167 | ((__tfind_spe_sort)) && __tfind_spe_found=(${(no)__tfind_spe_found}) 168 | done 169 | fi 170 | 171 | if ((!$#__tfind_spe_found)); then 172 | _tfind_error_msg && return 173 | fi 174 | 175 | # 176 | # Pagination, index value guards 177 | # 178 | 179 | integer page_size=$__tfind_page_size 180 | integer max_index="$#__tfind_spe_found" 181 | [[ $page_size -gt $max_index ]] && page_size=$max_index 182 | [[ $__tfind_spe_index -le 0 ]] && __tfind_spe_index=$max_index 183 | [[ $__tfind_spe_index -gt $max_index ]] && __tfind_spe_index=1 184 | integer page_start_idx=$(( ((__tfind_spe_index-1)/page_size)*page_size+1 )) 185 | integer on_page_idx=$(( (__tfind_spe_index-1) % page_size + 1 )) 186 | 187 | # 188 | # Prepare display 189 | # 190 | 191 | typeset -a disp_list 192 | disp_list=( "${(@)__tfind_spe_found[page_start_idx,page_start_idx+page_size-1]}" ) 193 | 194 | # Remove meta-data from the entries 195 | disp_list=( "${(@)disp_list//$'\177'*/}" ) 196 | 197 | # All entries should have multilines replaced 198 | disp_list=( "${(@)disp_list//$'\n'/\\n}" ) 199 | # ... and truncated to display width, and 200 | # also preceeded by two spaces 201 | disp_list=( "${(@)disp_list/(#m)*/ ${MATCH[1,COLUMNS-8]}}" ) 202 | 203 | local p=$'\n' 204 | local entry=$disp_list[on_page_idx] 205 | entry[1]='»' 206 | disp_list[on_page_idx]=$entry 207 | 208 | # 209 | # Detect where "> .." entry starts 210 | # 211 | 212 | local txt_before="${(F)${(@)disp_list[1,on_page_idx-1]}}" 213 | 214 | # 215 | # Colorify 216 | # 217 | local noun=${${${__tfind_spe_funct:#0}:+function}:-symbol} 218 | local preamble=$'\n'"View of ${noun}s for repo: «««${(U)TAG[git-or-project]}»»» located at: $TAG[repo-dir]:h"$'\n'"${(C)noun} no. #$__tfind_spe_index. Found $max_index ${noun}s in the index."$'\n' \ 219 | key="Ctrl-f to toggle functions-ONLY view. Alt-s to toggle sort."$'\n' 220 | preamble+=$key 221 | 222 | local text="${(F)disp_list}" 223 | integer offset=${#preamble}+$buflen 224 | 225 | POSTDISPLAY="$preamble$text" 226 | 227 | region_highlight=( "$(( offset + ${#txt_before} )) $(( offset + ${#txt_before} + ${#entry} + 1 )) underline" ) 228 | 229 | color_att() { local c;if (($4==0)){c=$__tfind_title_color;} elif (($4==1)){c=$__tfind_high_color;} elif (($4==4)){c=$__tfind_var_color;} elif (($4==7)){c=$__tfind_func_color;} elif (($4==9)){c=$__tfind_eqdol_color;} elif (($4==10)){c=$__tfind_macro_color;} else {c=$__tfind_arrow_color;}; region_highlight_+=("$(($1+$2-1)) $(($1+$3)) $c"); } 230 | functions -M coloratt 4 4 color_att 231 | local -a region_highlight_ 232 | # Also highlight project name 233 | local h="$(( 30+buflen+__tfind_spe_funct*2 )) $(( 30+$buflen+${#TAG[git-or-project]}+__tfind_spe_funct*2 )) $__tfind_title_color" 234 | local q="$buflen $offset $__tfind_heading_color" 235 | region_highlight+=( $q $h ) 236 | : "${preamble//(#b)no. ([^.]##)./$((coloratt(buflen,mbegin[1],mend[1],0)))}" 237 | : "${preamble//(#b)Found ([0-9]##)/$((coloratt(buflen,mbegin[1],mend[1],1)))}" 238 | : "${preamble//(#b)» located at: ([^$p]##)/$((coloratt(buflen,mbegin[1],mend[1],1)))}" 239 | : "${preamble//(#b)(Ctrl-f)/$((coloratt(buflen,mbegin[1],mend[1],0)))}" 240 | : "${preamble//(#b)(Alt-s)/$((coloratt(buflen,mbegin[1],mend[1],0)))}" 241 | : "${text//((#s)|$p)(#b)(»)/$((coloratt(offset,mbegin[1],mend[1],3)))}" 242 | # Basic syntax highlighting - a few keywords like C/Java type names 243 | : "${text//(#b)((([[:space:]\(\{\[]int|double|enum|short|long|(u|w|g|gu)(int|char|long|short)(8|16|32|64|128|max|)(_t|)|char|(|un)signed|FILE|const|restrict|size_t|va_list|ptrdiff_t|off_t|gboolean|gpointer|gconstpointer|typedef|static|struct|union)[[:space:]])|[a-zA-Z_]##_t|local|integer|float|declare|typeset|readonly)/$((coloratt(offset,mbegin[1],mend[1],4)))}" 244 | : "${text//(#b)(=)/$((coloratt(offset,mbegin[1],mend[1],9)))}" 245 | : "${text//(#b)(\#[[:space:]]#(include|define|if|endif))/$((coloratt(offset,mbegin[1],mend[1],10)))}" 246 | : "${text//(#b)(\$<->#)/$((coloratt(offset,mbegin[1],mend[1],9)))}" 247 | : "${text//(#b)([[:alnum:]$TAG[fun-xt-chars]]##)[[:space:]]#\([^\)]#\)/$((coloratt(offset,mbegin[1],mend[1],7)))}" 248 | : "${text//(#b)\#[[:space:]]#(include|define)[[:space:]]##([[:alnum:]_]##)[^[:alnum:]_]/$((coloratt(offset,mbegin[2],mend[2],7)))}" 249 | if [[ -n $search_pattern ]]; then 250 | : "${(f)${(S)text//*(#bi)(${~csearch_pattern})/$((coloratt(offset,mbegin[1],mend[1],1)))}}" 251 | fi 252 | 253 | functions +M color_att 254 | unfunction color_att 255 | region_highlight+=( $region_highlight_ ) 256 | } 257 | 258 | 259 | _tfind_functions() { 260 | __tfind_spe_funct=1-__tfind_spe_funct 261 | __tfind_spe_restart=1 262 | _tfind_simulate_widget 263 | } 264 | _tfind_sort() { 265 | __tfind_spe_sort=1-__tfind_spe_sort 266 | __tfind_spe_restart=1 267 | _tfind_simulate_widget 268 | } 269 | _tfind_simulate_widget() { 270 | (( __tfind_spe_call_count ++ )) 271 | _tfind_main 272 | } 273 | 274 | _tfind_self_insert() { 275 | [[ $#KEYS ]] && __tfind_spe_restart=1 276 | LBUFFER+="${KEYS[-1]}" 277 | _tfind_simulate_widget 278 | } 279 | 280 | _tfind_backward_delete_char() { 281 | [[ $#LBUFFER ]] && __tfind_spe_restart=1 282 | LBUFFER="${LBUFFER%?}" 283 | _tfind_simulate_widget 284 | } 285 | 286 | _tfind_delete_char() { 287 | [[ $#RBUFFER ]] && __tfind_spe_restart=1 288 | RBUFFER="${RBUFFER#?}" 289 | _tfind_simulate_widget 290 | } 291 | 292 | _tfind_cancel_accept() { 293 | BUFFER="" 294 | __tfind_spe_index=-1 295 | zle .accept-line 296 | } 297 | 298 | _tfind_main 299 | 300 | if [[ $__tfind_spe_call_count -eq 1 ]]; then 301 | # Make the tfind keymap a copy of the current main 302 | bindkey -N tfind emacs 303 | 304 | local down_widget="${${${WIDGET%-backwards}%-pbackwards}-pforwards}" 305 | local up_widget="${down_widget}-backwards" 306 | local pdown_widget="${down_widget}-pforwards" 307 | local pup_widget="${down_widget}-pbackwards" 308 | 309 | # Manual, termcap, terminfo 310 | bindkey -M tfind '^[OA' $up_widget 311 | bindkey -M tfind '^[OB' $down_widget 312 | bindkey -M tfind '^[[A' $up_widget 313 | bindkey -M tfind '^[[B' $down_widget 314 | [[ -n "$termcap[ku]" ]] && bindkey -M tfind "$termcap[ku]" $up_widget 315 | [[ -n "$termcap[kd]" ]] && bindkey -M tfind "$termcap[kd]" $down_widget 316 | [[ -n "$termcap[kD]" ]] && bindkey -M tfind "$termcap[kD]" delete-char 317 | [[ -n "$terminfo[kcuu1]" ]] && bindkey -M tfind "$terminfo[kcuu1]" $up_widget 318 | [[ -n "$terminfo[kcud1]" ]] && bindkey -M tfind "$terminfo[kcud1]" $down_widget 319 | [[ -n "$terminfo[kdch1]" ]] && bindkey -M tfind "$terminfo[kdch1]" delete-char 320 | 321 | # More bindkeys, to remove influence of overloading plugins (sy-h, suggestions) 322 | # Left/Right cursor keys 323 | bindkey -M tfind '^[[D' .backward-char 324 | bindkey -M tfind '^[[C' .forward-char 325 | [[ -n "$termcap[kl]" ]] && bindkey -M tfind "$termcap[kl]" .backward-char 326 | [[ -n "$termcap[kr]" ]] && bindkey -M tfind "$termcap[kr]" .forward-char 327 | [[ -n "$terminfo[kcub1]" ]] && bindkey -M tfind "$terminfo[kcub1]" .backward-char 328 | [[ -n "$terminfo[kcuf1]" ]] && bindkey -M tfind "$terminfo[kcuf1]" .forward-char 329 | # Now Home/End keys, first few recorded in my .zshrc during the years sequences 330 | bindkey -M tfind "\e[1~" .beginning-of-line 331 | bindkey -M tfind "\e[7~" .beginning-of-line 332 | bindkey -M tfind "\e[H" .beginning-of-line 333 | bindkey -M tfind "\e[4~" .end-of-line 334 | bindkey -M tfind "\e[F" .end-of-line 335 | bindkey -M tfind "\e[8~" .end-of-line 336 | [[ -n "$termcap[kh]" ]] && bindkey -M tfind "$termcap[kh]" .beginning-of-line 337 | [[ -n "$termcap[@7]" ]] && bindkey -M tfind "$termcap[@7]" .end-of-line 338 | [[ -n "$terminfo[khome]" ]] && bindkey -M tfind "$terminfo[khome]" .beginning-of-line 339 | [[ -n "$terminfo[kend]" ]] && bindkey -M tfind "$terminfo[kend]" .end-of-line 340 | # The same for Ctrl-E, Ctrl-F 341 | bindkey -M tfind '^A' .beginning-of-line 342 | bindkey -M tfind '^E' .end-of-line 343 | # Additional keys 344 | bindkey -M tfind '^[b' .backward-word 345 | bindkey -M tfind '^[B' .backward-word 346 | bindkey -M tfind '^[f' .forward-word 347 | bindkey -M tfind '^[F' .forward-word 348 | bindkey -M tfind '^[w' .forward-word 349 | bindkey -M tfind '^[W' .forward-word 350 | 351 | # Additional keys 352 | bindkey -M tfind '^P' $up_widget 353 | bindkey -M tfind '^N' $down_widget 354 | 355 | # Page Up, Page Down keys 356 | [[ -n "$termcap[kP]" ]] && bindkey -M tfind "$termcap[kP]" $pup_widget 357 | [[ -n "$termcap[kN]" ]] && bindkey -M tfind "$termcap[kN]" $pdown_widget 358 | [[ -n "$terminfo[kpp]" ]] && bindkey -M tfind "$terminfo[kpp]" $pup_widget 359 | [[ -n "$terminfo[knp]" ]] && bindkey -M tfind "$terminfo[knp]" $pdown_widget 360 | 361 | # Needed for Fedora 23, zsh-5.1.1 362 | bindkey -M tfind ' ' self-insert 363 | 364 | # Removal of default Ctrl-R binding 365 | bindkey -M tfind '^R' $down_widget 366 | # If one would like to re-open 367 | bindkey -M tfind '^O' $down_widget 368 | 369 | # Substitute self-insert, backward-delete-char, delete-char 370 | zle -A self-insert saved-self-insert 371 | zle -A backward-delete-char saved-backward-delete-char 372 | zle -A delete-char saved-delete-char 373 | zle -N self-insert _tfind_self_insert 374 | zle -N backward-delete-char _tfind_backward_delete_char 375 | zle -N delete-char _tfind_delete_char 376 | zle -N tfind-functions _tfind_functions 377 | zle -N tfind-sort _tfind_sort 378 | 379 | # Override ourselves with what we actually are 380 | # because zsh-autosuggestions change us 381 | zle -A $down_widget saved-$down_widget 382 | zle -A $up_widget saved-$up_widget 383 | zle -N $down_widget _tfind_simulate_widget 384 | zle -N $up_widget _tfind_simulate_widget 385 | 386 | zle -A $pdown_widget saved-$pdown_widget 387 | zle -A $pup_widget saved-$pup_widget 388 | zle -N $pdown_widget _tfind_simulate_widget 389 | zle -N $pup_widget _tfind_simulate_widget 390 | if (( $+widgets[zle-line-pre-redraw] )); then 391 | zle -A zle-line-pre-redraw saved-pre-redraw 392 | zle -D zle-line-pre-redraw 393 | fi 394 | local selected_editor cd_at_edit tagtext tagline taglinebyte tagfile 395 | local -a comm 396 | comm=() 397 | 398 | # Add Ctrl-V, ESC bindings to cancel search 399 | # A workaround for Zsh versions like 5.0.2 400 | zle -N _tfind_cancel_accept 401 | bindkey -M tfind "^[" _tfind_cancel_accept 402 | bindkey -M tfind "^f" tfind-functions 403 | bindkey -M tfind "\es" tfind-sort 404 | 405 | local redrawbkp=0 406 | # Trap INT to manually interrupt Zle to work around a bug 407 | trap 'zle && zle .send-break' INT 408 | if zle .recursive-edit -K tfind; then 409 | if ((__tfind_spe_index<=0)); then 410 | : 411 | else 412 | zstyle -s ":plugin:zinit:symbol-search" editor selected_editor || selected_editor=${VISUAL:-${EDITOR:-mcedit}} 413 | zstyle -T ":plugin:zinit:symbol-search" cd_at_edit && cd_at_edit=yes || cd_at_edit=no 414 | (( ! $+commands[$selected_editor] )) && selected_editor=vim 415 | (( ! $+commands[$selected_editor] )) && selected_editor=nano 416 | (( ! $+commands[$selected_editor] )) && selected_editor=emacs 417 | 418 | tagtext=$__tfind_spe_found[__tfind_spe_index] 419 | if [[ $tagtext = (#b)[^$'\177']#$'\177'[^$'\1']#$'\1'([^$'\2']#)$'\2'(*) ]]; then 420 | taglinebyte=${match[1]} 421 | tagline=${taglinebyte%%,*} 422 | 423 | # CD vs absolute path 424 | if [[ $match[2] != /* && -n $TAG[repo-dir] ]]; then 425 | tagfile=$TAG[repo-dir]/$match[2] 426 | else 427 | tagfile=$match[2] 428 | fi 429 | [[ ! -f $tagfile && -f $match[2] ]] && tagfile=$match[2] 430 | # Editor command 431 | case "$selected_editor" in 432 | (vim|vi|gvim|mvim|nvim) 433 | comm+=( $selected_editor "+$tagline" -- "${(q)tagfile}" ) 434 | ;; 435 | (emacs|emacsclient) 436 | comm+=( $selected_editor "+$tagline" -- "${(q)tagfile}" ) 437 | ;; 438 | (gedit) 439 | comm+=( $selected_editor "+$tagline" -- "${(q)tagfile}" ) 440 | ;; 441 | (nano) 442 | comm+=( $selected_editor "+$tagline" -- "${(q)tagfile}" ) 443 | ;; 444 | (mcedit) 445 | comm+=( $selected_editor "+$tagline" -- "${(q)tagfile}" ) 446 | ;; 447 | (*) 448 | comm+=( $selected_editor "+$tagline" -- "${(q)tagfile}" ) 449 | ;; 450 | esac 451 | fi 452 | fi 453 | else 454 | BUFFER="" 455 | fi 456 | POSTDISPLAY= 457 | 458 | # Restore self-insert, backward-delete-char, delete-char 459 | zle -A saved-self-insert self-insert 460 | zle -A saved-backward-delete-char backward-delete-char 461 | zle -A saved-delete-char delete-char 462 | zle -D saved-self-insert saved-backward-delete-char saved-delete-char 463 | 464 | # Restore ourselves 465 | zle -A saved-$down_widget $down_widget 466 | zle -A saved-$up_widget $up_widget 467 | zle -D saved-$down_widget saved-$up_widget 468 | 469 | zle -A saved-$pdown_widget $pdown_widget 470 | zle -A saved-$pup_widget $pup_widget 471 | zle -D saved-$pdown_widget saved-$pup_widget 472 | 473 | if (( $+widgets[saved-pre-redraw] )); then 474 | zle -A saved-pre-redraw zle-line-pre-redraw 475 | zle -D saved-pre-redraw 476 | fi 477 | 478 | # Full reinitialisation at next call 479 | __tfind_spe_call_count=0 480 | 481 | # Free memory 482 | __tfind_spe_found=() 483 | __tfind_tag_data=() 484 | region_highlight=() 485 | 486 | # Is there a command to run? 487 | if [[ $#comm != 0 ]]; then 488 | local auto_run 489 | zstyle -T ":plugin:zinit" auto_run && auto_run=yes || auto_run=no 490 | BUFFER=$comm[*] 491 | CURSOR=$buflen 492 | [[ $auto_run = yes ]] && zle .accept-line 493 | fi 494 | elif (( __tfind_spe_call_count > 0 )); then 495 | (( __tfind_spe_call_count -- )) 496 | fi 497 | 498 | # Local Variables: 499 | # mode: Shell-Script 500 | # sh-indentation: 2 501 | # indent-tabs-mode: nil 502 | # sh-basic-offset: 2 503 | # End: 504 | # vim: ft=zsh sw=2 ts=2 et 505 | -------------------------------------------------------------------------------- /zinit-additional.zsh: -------------------------------------------------------------------------------- 1 | # -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- 2 | # Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors. 3 | 4 | # FUNCTION: :zinit-tmp-subst-source [[[ 5 | :zinit-tmp-subst-source() { 6 | local -a ___substs ___ab 7 | ___substs=( "${(@s.;.)ICE[subst]}" ) 8 | if [[ -n ${(M)___substs:#*\\(#e)} ]] { 9 | local ___prev 10 | ___substs=( ${___substs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${___prev:+$___prev\;}}${match[3]}${${___prev::=${match[2]:+${___prev:+$___prev\;}}${match[2]}}:+}} ) 11 | } 12 | 13 | # Load the plugin 14 | if [[ ! -r $1 ]] { 15 | +zi-log "{error}source: Couldn't read the script {obj}${1}{error}" \ 16 | ", cannot substitute {data}${ICE[subst]}{error}.{rst}" 17 | } 18 | 19 | local ___data="$(<$1)" 20 | 21 | () { 22 | builtin emulate -LR zsh -o extendedglob -o interactivecomments ${=${options[xtrace]:#off}:+-o xtrace} 23 | local ___subst ___tabspc=$'\t' 24 | for ___subst ( "${___substs[@]}" ) { 25 | ___ab=( "${(@)${(@)${(@s:->:)___subst}##[[:space:]]##}%%[[:space:]]##}" ) 26 | ___ab[2]=${___ab[2]//(#b)\\([[:digit:]])/\${match[${match[1]}]}} 27 | builtin eval "___data=\"\${___data//(#b)\${~___ab[1]}/${___ab[2]}}\"" 28 | } 29 | ___data="() { ${(F)${(@)${(f)___data[@]}:#[$___tabspc]#\#*}} ; } \"\${@[2,-1]}\"" 30 | } 31 | 32 | builtin eval "$___data" 33 | } # ]]] 34 | # FUNCTION: .zinit-service [[[ 35 | # Handles given service, i.e. obtains lock, runs it, or waits if no lock 36 | # 37 | # $1 - type "p" or "s" (plugin or snippet) 38 | # $2 - mode - for plugin (light or load) 39 | # $3 - id - URL or plugin ID or alias name (from id-as'') 40 | .zinit-service() { 41 | builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} 42 | setopt extendedglob warncreateglobal typesetsilent noshortloops 43 | 44 | local ___tpe="$1" ___mode="$2" ___id="$3" ___fle="${ZINIT[SERVICES_DIR]}/${ICE[service]}.lock" ___fd ___cmd ___tmp ___lckd ___strd=0 45 | { builtin print -n >! "$___fle"; } 2>/dev/null 1>&2 46 | [[ ! -e ${___fle:r}.fifo ]] && command mkfifo "${___fle:r}.fifo" 2>/dev/null 1>&2 47 | [[ ! -e ${___fle:r}.fifo2 ]] && command mkfifo "${___fle:r}.fifo2" 2>/dev/null 1>&2 48 | 49 | typeset -gx ZSRV_WORK_DIR="${ZINIT[SERVICES_DIR]}" ZSRV_ID="${ICE[service]}" # should be also set by other p-m 50 | 51 | while (( 1 )); do 52 | ( 53 | while (( 1 )); do 54 | [[ ! -f ${___fle:r}.stop ]] && if (( ___lckd )) || zsystem 2>/dev/null 1>&2 flock -t 1 -f ___fd -e $___fle; then 55 | ___lckd=1 56 | if (( ! ___strd )) || [[ $___cmd = RESTART ]]; then 57 | [[ $___tpe = p ]] && { ___strd=1 58 | .zinit-load "$___id" "" "$___mode" 0; 59 | } 60 | [[ $___tpe = s ]] && { ___strd=1 61 | .zinit-load-snippet "$___id" "" 0; 62 | } 63 | fi 64 | ___cmd= 65 | while (( 1 )); do builtin read -t 32767 ___cmd <>"${___fle:r}.fifo" && break; done 66 | else 67 | return 0 68 | fi 69 | 70 | [[ $___cmd = (#i)NEXT ]] && { kill -TERM "$ZSRV_PID"; builtin read -t 2 ___tmp <>"${___fle:r}.fifo2"; kill -HUP "$ZSRV_PID"; exec {___fd}>&-; ___lckd=0; ___strd=0; builtin read -t 10 ___tmp <>"${___fle:r}.fifo2"; } 71 | [[ $___cmd = (#i)STOP ]] && { kill -TERM "$ZSRV_PID"; builtin read -t 2 ___tmp <>"${___fle:r}.fifo2"; kill -HUP "$ZSRV_PID"; ___strd=0; builtin print >! "${___fle:r}.stop"; } 72 | [[ $___cmd = (#i)QUIT ]] && { kill -HUP ${sysparams[pid]}; return 1; } 73 | [[ $___cmd != (#i)RESTART ]] && { ___cmd=; builtin read -t 1 ___tmp <>"${___fle:r}.fifo2"; } 74 | done 75 | ) || break 76 | builtin read -t 1 ___tmp <>"${___fle:r}.fifo2" 77 | done >>! "$ZSRV_WORK_DIR/$ZSRV_ID".log 2>&1 78 | } # ]]] 79 | # FUNCTION: .zinit-wrap-track-functions [[[ 80 | .zinit-wrap-track-functions() { 81 | local user="$1" plugin="$2" id_as="$3" f 82 | local -a wt 83 | wt=( ${(@s.;.)ICE[wrap-track]} ) 84 | for f in ${wt[@]}; do 85 | functions[${f}-zinit-bkp]="${functions[$f]}" 86 | eval " 87 | function $f { 88 | ZINIT[CUR_USR]=\"$user\" ZINIT[CUR_PLUGIN]=\"$plugin\" ZINIT[CUR_USPL2]=\"$id_as\" 89 | .zinit-add-report \"\${ZINIT[CUR_USPL2]}\" \"Note: === Starting to track function: $f ===\" 90 | .zinit-diff \"\${ZINIT[CUR_USPL2]}\" begin 91 | .zinit-tmp-subst-on load 92 | functions[${f}]=\${functions[${f}-zinit-bkp]} 93 | ${f} \"\$@\" 94 | .zinit-tmp-subst-off load 95 | .zinit-diff \"\${ZINIT[CUR_USPL2]}\" end 96 | .zinit-add-report \"\${ZINIT[CUR_USPL2]}\" \"Note: === Ended tracking function: $f ===\" 97 | ZINIT[CUR_USR]= ZINIT[CUR_PLUGIN]= ZINIT[CUR_USPL2]= 98 | }" 99 | done 100 | } # ]]] 101 | 102 | # 103 | # debug command 104 | # 105 | 106 | # FUNCTION: .zinit-debug-clear [[[ 107 | # Clear latest debug report 108 | .zinit-debug-clear() { 109 | { 110 | .zinit-clear-report-for _dtrace/_dtrace 111 | +zi-log '{m} Cleared debug report' 112 | } || { 113 | +zi-log '{e} Failed to clear debug report' 114 | return 1 115 | } 116 | } # ]]] 117 | # FUNCTION: .zinit-debug-report [[[ 118 | # Displays debug report (data recorded in interactive session). 119 | .zinit-debug-report() { 120 | if [[ ${ZINIT[DTRACE]} = 1 ]]; then 121 | +zi-log "{e} Debug mode active, stop it first via {cmd}zinit debug stop{rst}" 122 | else 123 | (( ${+functions[.zinit-unload]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-autoload.zsh" || return 1 124 | .zinit-show-report "_dtrace/_dtrace" 125 | fi 126 | } # ]]] 127 | # FUNCTION: .zinit-debug-revert [[[ 128 | # Revert changes made during debug mode 129 | .zinit-debug-revert() { 130 | if [[ ${ZINIT[DTRACE]} = 1 ]]; then 131 | +zi-log "{e} Debug mode is active. To stop, run {cmd}zinit debug stop{rst}" 132 | else 133 | (( ${+functions[.zinit-unload]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-autoload.zsh" || return 1 134 | .zinit-unload _dtrace _dtrace 135 | +zi-log "{m} Reverted changes detected during debug mode" 136 | fi 137 | } # ]]] 138 | # FUNCTION: .zinit-debug-start [[[ 139 | # Start debug mode 140 | .zinit-debug-start() { 141 | if [[ $ZINIT[DTRACE] = 1 ]]; then 142 | +zi-log "{e} Debug mode currently active" 143 | return 1 144 | fi 145 | (){ 146 | ZINIT[DTRACE]=1 147 | .zinit-diff _dtrace/_dtrace begin 148 | .zinit-tmp-subst-on dtrace 149 | } 150 | if (( $? == 0 )); then 151 | +zi-log "{i} Started debug mode" 152 | return 0 153 | fi 154 | } # ]]] 155 | # FUNCTION: .zinit-debug-status [[[ 156 | # Revert changes made during debug mode 157 | .zinit-debug-status() { 158 | +zi-log -n '{m} Debug mode: ' 159 | (( ZINIT[DTRACE] )) && +zi-log 'running' || +zi-log 'stopped' 160 | } # ]]] 161 | # FUNCTION: .zinit-debug-stop [[[ 162 | # Stop debug mode 163 | .zinit-debug-stop() { 164 | if [[ $ZINIT[DTRACE] = 0 ]]; then 165 | +zi-log '{e} Debug mode not active' 166 | return 0 167 | else 168 | ZINIT[DTRACE]=0 169 | (){ 170 | .zinit-tmp-subst-off dtrace # turn of shadowing 171 | .zinit-diff _dtrace/_dtrace end # get end data to diff later 172 | } 173 | if (( $? == 0 )); then 174 | +zi-log '{i} Stopped debug mode' 175 | return 0 176 | fi 177 | fi 178 | } # ]]] 179 | # FUNCTION: +zinit-debug [[[ 180 | # Debug command entry point 181 | +zinit-debug(){ 182 | emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} 183 | setopt extendedglob noksharrays nokshglob nullglob typesetsilent warncreateglobal 184 | local o_help cmd 185 | local -a usage=( 186 | 'Usage:' 187 | ' zinit debug [options] [command]' 188 | ' ' 189 | 'Options:' 190 | ' -h, --help Show list of command-line options' 191 | ' ' 192 | 'Commands:' 193 | ' clear Clear debug report' 194 | ' report Show debug report' 195 | ' revert Revert changes made during debug mode' 196 | ' start Start debug mode' 197 | ' status Current debug status' 198 | ' stop Stop debug mode' 199 | ) 200 | zmodload zsh/zutil 201 | zparseopts -D -F -K -- \ 202 | {h,-help}=o_help \ 203 | || return 1 204 | 205 | (( $#o_help )) && { 206 | print -l -- $usage 207 | return 0 208 | } 209 | 210 | cmd="$1" 211 | if (( ! $+functions[.zinit-debug-${cmd}] )); then 212 | print -l -- $usage 213 | return 1 214 | else 215 | .zinit-debug-${cmd} "${(@)@:2}" 216 | fi 217 | } # ]]] 218 | 219 | # vim: ft=zsh sw=4 ts=4 et foldmarker=[[[,]]] foldmethod=marker 220 | -------------------------------------------------------------------------------- /zinit-side.zsh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | # 3 | # Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors 4 | # Copyright (c) 2021-2022 zdharma-continuum and contributors 5 | 6 | # FUNCTION: .zinit-any-colorify-as-uspl2 [[[ 7 | # Returns ANSI-colorified "user/plugin" string, from any supported 8 | # plugin spec (user---plugin, user/plugin, user plugin, plugin). 9 | # 10 | # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) 11 | # $2 - plugin (only when $1 - i.e. user - given) 12 | # 13 | # $REPLY - ANSI-colorified "user/plugin" string 14 | .zinit-any-colorify-as-uspl2() { 15 | .zinit-any-to-user-plugin "$1" "$2" 16 | local user="${reply[-2]}" plugin="${reply[-1]}" 17 | if [[ "$user" = "%" ]]; then 18 | .zinit-any-to-pid "" $plugin 19 | REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--plugins--/OMZP::}" 20 | REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--plugins/OMZP}" 21 | REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--lib--/OMZL::}" 22 | REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--lib/OMZL}" 23 | REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--themes--/OMZT::}" 24 | REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--themes/OMZT}" 25 | REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--/OMZ::}" 26 | REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk/OMZ}" 27 | REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk--modules--/PZTM::}" 28 | REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk--modules/PZTM}" 29 | REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk--/PZT::}" 30 | REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk/PZT}" 31 | REPLY="${REPLY/(#b)%([A-Z]##)(#c0,1)(*)/%$ZINIT[col-uname]$match[1]$ZINIT[col-pname]$match[2]$ZINIT[col-rst]}" 32 | elif [[ $user == http(|s): ]]; then 33 | REPLY="${ZINIT[col-ice]}${user}/${plugin}${ZINIT[col-rst]}" 34 | else 35 | REPLY="${user:+${ZINIT[col-uname]}${user}${ZINIT[col-rst]}/}${ZINIT[col-pname]}${plugin}${ZINIT[col-rst]}" 36 | fi 37 | } # ]]] 38 | # FUNCTION: .zinit-compute-ice [[[ 39 | # Computes ICE array 40 | # - input 41 | # - static 42 | # - saved 43 | # taking priorities into account. 44 | # Can also pack resulting ices into ZINIT_SICE (see $2). 45 | # Returns filepath to snippet directory and optional snippet file name (only 46 | # valid if ICE[svn] is not set). 47 | # 48 | # $1 - URL (also plugin-spec) 49 | # $2 - "pack" or "nopack" or "pack-nf" - packing means ICE 50 | # wins with static ice; "pack-nf" means that disk-ices will 51 | # be ignored (no-file?) 52 | # $3 - name of output associative array, "ICE" is the default 53 | # $4 - name of output string parameter, to hold path to directory ("local_dir") 54 | # $5 - name of output string parameter, to hold filename ("filename") 55 | # $6 - name of output string parameter, to hold is-snippet 0/1-bool ("is_snippet") 56 | # 57 | # $REPLY - snippet directory filepath 58 | .zinit-compute-ice() { 59 | builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} 60 | setopt extendedglob typesetsilent warncreateglobal noshortloops 61 | 62 | local ___URL="${1%/}" ___pack="$2" ___is_snippet=0 63 | local ___var_name1="${3:-ZINIT_ICE}" ___var_name2="${4:-local_dir}" ___var_name3="${5:-filename}" ___var_name4="${6:-is_snippet}" 64 | 65 | # Copy from .zinit-recall 66 | local -a ice_order nval_ices 67 | ice_order=( 68 | ${(s.|.)ZINIT[ice-list]} 69 | # include all additional ices – after stripping them from the possible: '' 70 | ${(@)${(@Akons:|:)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/} 71 | ) 72 | nval_ices=( 73 | ${(s.|.)ZINIT[nval-ice-list]} 74 | # include only those additional ices, don't have the '' in their name, i.e. 75 | # aren't designed to hold value 76 | ${(@)${(@)${(@Akons:|:)ZINIT_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/} 77 | svn 78 | ) 79 | 80 | # strip whitespace from beginning of url 81 | ___URL="${${___URL#"${___URL%%[! $'\t']*}"}%/}" 82 | 83 | # snippet 84 | .zinit-two-paths "$___URL" 85 | local ___s_path="${reply[-4]}" ___s_svn="${reply[-3]}" ___path="${reply[-2]}" ___filename="${reply[-1]}" ___local_dir 86 | 87 | if [[ -d "$___s_path" || -d "$___path" ]]; then 88 | ___is_snippet=1 89 | else 90 | # plugin 91 | .zinit-any-to-user-plugin "$___URL" "" 92 | local ___user="${reply[-2]}" ___plugin="${reply[-1]}" 93 | ___s_path="" ___filename="" 94 | [[ "$___user" = "%" ]] && ___path="$___plugin" || ___path="${ZINIT[PLUGINS_DIR]}/${___user:+${___user}---}${___plugin//\//---}" 95 | .zinit-exists-physically-message "$___user" "$___plugin" || return 1 96 | fi 97 | 98 | [[ $___pack = pack* ]] && (( ${#ICE} > 0 )) && .zinit-pack-ice "${___user-$___URL}" "$___plugin" 99 | 100 | local -A ___sice 101 | local -a ___tmp 102 | 103 | ___tmp=( "${(z@)ZINIT_SICE[${___user-$___URL}${${___user:#(%|/)*}:+/}$___plugin]}" ) 104 | (( ${#___tmp[@]} > 1 && ${#___tmp[@]} % 2 == 0 )) && ___sice=( "${(Q)___tmp[@]}" ) 105 | 106 | if [[ "${+___sice[svn]}" = "1" || -n "$___s_svn" ]]; then 107 | if (( !___is_snippet && ${+___sice[svn]} == 1 )); then 108 | builtin print -r -- "The \`svn' ice is given, but the argument ($___URL) is a plugin" 109 | builtin print -r -- "(\`svn' can be used only with snippets)" 110 | return 1 111 | elif (( !___is_snippet )); then 112 | builtin print -r -- "Undefined behavior #1 occurred, please report at https://github.com/zdharma-continuum/zinit/issues" 113 | return 1 114 | fi 115 | if [[ -e "$___s_path" && -n "$___s_svn" ]]; then 116 | ___sice[svn]="" 117 | ___local_dir="$___s_path" 118 | else 119 | if [[ ! -e "$___path" ]] { 120 | builtin print -r -- "No such snippet, looked at paths (1): $___s_path, and: $___path"; 121 | return 1; 122 | } 123 | unset '___sice[svn]' 124 | ___local_dir="$___path" 125 | fi 126 | else 127 | if [[ -e "$___path" ]]; then 128 | unset '___sice[svn]' 129 | ___local_dir="$___path" 130 | else 131 | builtin print -r -- "No such snippet, looked at paths (2): $___s_path, and: $___path" 132 | return 1 133 | fi 134 | fi 135 | 136 | local ___zinit_path="$___local_dir/._zinit" 137 | # read disk-ice 138 | local -A ___mdata 139 | local ___key 140 | 141 | { 142 | for ___key in mode url is_release is_release{2..5} ${ice_order[@]}; do 143 | [[ -f "$___zinit_path/$___key" ]] && ___mdata[$___key]="$(<$___zinit_path/$___key)" 144 | done 145 | [[ "${___mdata[mode]}" = "1" ]] && ___mdata[svn]="" 146 | } 2>/dev/null 147 | 148 | # handle flag-ices; svn must be last 149 | for ___key in ${ice_order[@]}; do 150 | [[ $___key == (no|)compile ]] && continue 151 | 152 | if (( 0 == ${+ICE[no$___key]} && 0 == ${+___sice[no$___key]} )) { 153 | continue 154 | } 155 | # "If there is such ice currently, and there's no no* ice given, and 156 | # there's the no* ice in the static ice" – skip, don't unset. With 157 | # conjunction with the previous line this has the proper meaning: uset if 158 | # at least in one – current or static – ice there is the no* ice unless it 159 | # is the only in the static ice (unless there's on such ice "anyway"). 160 | if (( 1 == ${+ICE[$___key]} && 0 == ${+ICE[no$___key]} && 1 == ${+___sice[no$___key]} )) { 161 | continue 162 | } 163 | 164 | if [[ "$___key" = "svn" ]]; then 165 | command builtin print -r -- "0" >! "$___zinit_path/mode" 166 | ___mdata[mode]=0 167 | else 168 | command rm -f -- "$___zinit_path/$___key" 169 | fi 170 | 171 | unset "___mdata[$___key]" "___sice[$___key]" "ICE[$___key]" 172 | done 173 | 174 | # final decision, static ice vs. saved ice 175 | local -A ___MY_ICE 176 | for ___key in mode url is_release is_release{2..5} ${ice_order[@]}; do 177 | # The second sum is: if the pack is *not* pack-nf, then depending on the 178 | # disk availability, otherwise: no disk ice 179 | (( ${+___sice[$___key]} + ${${${___pack:#pack-nf*}:+${+___mdata[$___key]}}:-0} )) && ___MY_ICE[$___key]="${___sice[$___key]-${___mdata[$___key]}}" 180 | done 181 | # One more round for the special case – update, which ALWAYS needs the teleid 182 | # from the disk or static ice 183 | ___key=teleid; [[ "$___pack" = pack-nftid ]] && { 184 | (( ${+___sice[$___key]} + ${+___mdata[$___key]} )) && ___MY_ICE[$___key]="${___sice[$___key]-${___mdata[$___key]}}" 185 | } 186 | 187 | : ${(PA)___var_name1::="${(kv)___MY_ICE[@]}"} 188 | : ${(P)___var_name2::=$___local_dir} 189 | : ${(P)___var_name3::=$___filename} 190 | : ${(P)___var_name4::=$___is_snippet} 191 | 192 | return 0 193 | } # ]]] 194 | # FUNCTION: .zinit-countdown [[[ 195 | # Displays a countdown 5...4... etc. 196 | # 197 | # $REPLY - 1 if Ctrl-C is pressed, otherwise 0 198 | .zinit-countdown() { 199 | (( !${+ICE[countdown]} )) && return 0 200 | 201 | builtin emulate -L zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} 202 | trap "+zi-log \"{ehi}ABORTING, the ice {ice}$ice{ehi} not ran{rst}\"; return 1" INT 203 | 204 | local count=5 ice tpe="$1" 205 | 206 | ice="${ICE[$tpe]}" 207 | [[ $tpe = "atpull" && $ice = "%atclone" ]] && ice="${ICE[atclone]}" 208 | ice="{b}{ice}$tpe{ehi}:{rst}${ice//(#b)(\{[a-z0-9…–_-]##\})/\\$match[1]}" 209 | 210 | +zi-log -n "{hi}Running $ice{rst}{hi} ice in...{rst} " 211 | 212 | while (( -- count + 1 )) { 213 | +zi-log -n -- "{b}{error}"$(( count + 1 ))"{rst}{…}" 214 | sleep 1 215 | } 216 | 217 | +zi-log -r -- "{b}{error}0 {rst}{…}" 218 | return 0 219 | } # ]]] 220 | # FUNCTION: .zinit-exists-physically [[[ 221 | # Checks if directory of given plugin exists in PLUGIN_DIR. 222 | # 223 | # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) 224 | # $2 - plugin (only when $1 - i.e. user - given) 225 | .zinit-exists-physically() { 226 | .zinit-any-to-user-plugin "$1" "$2" 227 | if [[ ${reply[-2]} = % ]]; then 228 | [[ -d ${reply[-1]} ]] && return 0 || return 1 229 | else 230 | [[ -d ${ZINIT[PLUGINS_DIR]}/${reply[-2]:+${reply[-2]}---}${reply[-1]//\//---} ]] \ 231 | && return 0 \ 232 | || return 1 233 | fi 234 | } # ]]] 235 | # FUNCTION: .zinit-exists-physically-message [[[ 236 | # Checks if directory of given plugin exists in PLUGIN_DIR, and outputs error 237 | # message if it doesn't. 238 | # 239 | # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) 240 | # $2 - plugin (only when $1 - i.e. user - given) 241 | .zinit-exists-physically-message() { 242 | builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} 243 | builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes 244 | if ! .zinit-exists-physically "$1" "$2"; then 245 | .zinit-any-to-user-plugin "$1" "$2" 246 | if [[ $reply[1] = % ]]; then 247 | .zinit-any-to-pid "$1" "$2" 248 | local spec1=$REPLY 249 | if [[ $1 = %* ]]; then 250 | local spec2=%${1#%}${${1#%}:+${2:+/}}$2 251 | elif [[ -z $1 || -z $2 ]]; then 252 | local spec3=%${1#%}${2#%} 253 | fi 254 | else 255 | integer nospec=1 256 | fi 257 | .zinit-any-colorify-as-uspl2 "$1" "$2" 258 | 259 | +zi-log "{error}No such (plugin or snippet){rst}: $REPLY." 260 | 261 | [[ $nospec -eq 0 && $spec1 != $spec2 ]] \ 262 | && +zi-log "(expands to: {file}${spec2#%}{rst})." 263 | 264 | return 1 265 | fi 266 | return 0 267 | } # ]]] 268 | # FUNCTION: .zinit-first [[[ 269 | # Finds the main file of plugin. There are multiple file name formats, they are 270 | # ordered in order starting from more correct ones, and matched. 271 | # .zinit-load-plugin() has similar code parts and doesn't call .zinit-first() – 272 | # for performance. Obscure matching is done in .zinit-find-other-matches, here 273 | # and in .zinit-load(). Obscure = non-standard main-file naming convention. 274 | # 275 | # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) 276 | # $2 - plugin (only when $1 - i.e. user - given) 277 | .zinit-first() { 278 | .zinit-any-to-user-plugin "$1" "$2" 279 | local user="${reply[-2]}" plugin="${reply[-1]}" 280 | 281 | .zinit-any-to-pid "$1" "$2" 282 | .zinit-get-object-path plugin "$REPLY" 283 | integer ret=$? 284 | local dname="$REPLY" 285 | (( ret )) && { reply=( "$dname" "" ); return 1; } 286 | 287 | # look for file to compile - first look for the most common one (optimization) 288 | # then for other possibilities 289 | if [[ -e "$dname/$plugin.plugin.zsh" ]]; then 290 | reply=( "$dname/$plugin.plugin.zsh" ) 291 | else 292 | .zinit-find-other-matches "$dname" "$plugin" 293 | fi 294 | 295 | if [[ "${#reply}" -eq "0" ]]; then 296 | reply=( "$dname" "" ) 297 | return 1 298 | fi 299 | 300 | # take first entry (ksharrays resilience) 301 | reply=( "$dname" "${reply[-${#reply}]}" ) 302 | return 0 303 | } # ]]] 304 | # FUNCTION: .zinit-store-ices [[[ 305 | # Saves ice mods in given hash onto disk. 306 | # 307 | # $1 - directory where to create or delete files 308 | # $2 - name of hash that holds values 309 | # $3 - additional keys of hash to store, space separated 310 | # $4 - additional keys of hash to store, empty-meaningful ices, space separated 311 | # $5 – URL, if applicable 312 | # $6 – mode, svn=1, 0=single file 313 | .zinit-store-ices() { 314 | local ___pfx="$1" ___ice_var="$2" ___add_ices="$3" ___add_ices2="$4" 315 | local url="$5" mode="$6" 316 | 317 | # Copy from zinit-recall response 318 | local -a ice_order nval_ices 319 | ice_order=( 320 | ${(s.|.)ZINIT[ice-list]} 321 | # include all additional ices – after stripping them from the possible: '' 322 | ${(@)${(@Akons:|:)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/} 323 | ) 324 | nval_ices=( 325 | ${(s.|.)ZINIT[nval-ice-list]} 326 | # include only those additional ices, don't have the '' in their name, i.e. 327 | # aren't designed to hold value 328 | ${(@)${(@)${(@Akons:|:)ZINIT_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/} 329 | # must be last 330 | svn 331 | ) 332 | 333 | command mkdir -p "$___pfx" && echo '*' > "$___pfx/.gitignore" 334 | local ___key ___var_name 335 | # No nval_ices here 336 | for ___key in ${ice_order[@]:#(${(~j:|:)nval_ices[@]})} ${(s: :)___add_ices[@]}; do 337 | ___var_name="${___ice_var}[$___key]" 338 | (( ${(P)+___var_name} )) && builtin print -r -- "${(P)___var_name}" >! "$___pfx"/"$___key" 339 | done 340 | 341 | # Ices that even empty mean something 342 | for ___key in ${nval_ices[@]} ${(s: :)___add_ices2[@]}; do 343 | ___var_name="${___ice_var}[$___key]" 344 | if (( ${(P)+___var_name} )); then 345 | builtin print -r -- "${(P)___var_name}" >! "$___pfx"/"$___key" 346 | else 347 | command rm -f "$___pfx"/"$___key" 348 | fi 349 | done 350 | 351 | # url and mode are declared at the beginning of the body 352 | for ___key in url mode; do 353 | [[ -n "${(P)___key}" ]] && builtin print -r -- "${(P)___key}" >! "$___pfx"/"$___key" 354 | done 355 | } # ]]] 356 | # FUNCTION: .zinit-two-paths [[[ 357 | # Obtains a snippet URL without specification if it is an SVN URL (points to 358 | # directory) or regular URL (points to file), returns 2 possible paths for 359 | # further examination 360 | # 361 | # $REPLY - two filepaths 362 | .zinit-two-paths() { 363 | builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} 364 | setopt extendedglob typesetsilent warncreateglobal noshortloops 365 | 366 | local dirnameA dirnameB local_dirA local_dirB svn_dirA url1 url2 url=$1 367 | local -a fileB_there 368 | 369 | # remove leading whitespace and trailing / 370 | url="${${url#"${url%%[! $'\t']*}"}%/}" 371 | url1=$url 372 | url2=$url 373 | 374 | .zinit-get-object-path snippet "$url1" 375 | local_dirA=$reply[-3] dirnameA=$reply[-2] 376 | [[ -d "$local_dirA/$dirnameA/.svn" ]] && { 377 | svn_dirA=".svn" 378 | if { .zinit-first % "$local_dirA/$dirnameA"; } { 379 | fileB_there=( ${reply[-1]} ) 380 | } 381 | } 382 | 383 | .zinit-get-object-path snippet "$url2" 384 | local_dirB=$reply[-3] dirnameB=$reply[-2] 385 | 386 | [[ -z $svn_dirA ]] && fileB_there=( "$local_dirB/$dirnameB"/*~*.(zwc|md|js|html)(.-DOnN[1]) ) 387 | 388 | reply=( "$local_dirA/$dirnameA" "$svn_dirA" "$local_dirB/$dirnameB" "${fileB_there[1]##$local_dirB/$dirnameB/#}" ) 389 | } # ]]] 390 | 391 | # Local Variables: 392 | # mode: Shell-Script 393 | # sh-indentation: 2 394 | # indent-tabs-mode: nil 395 | # sh-basic-offset: 2 396 | # End: 397 | # vim: ft=zsh sw=2 ts=2 et foldmarker=[[[,]]] foldmethod=marker 398 | --------------------------------------------------------------------------------