Skip to content

Commit

Permalink
Merge pull request #61 from zdharma-continuum/installer-ng
Browse files Browse the repository at this point in the history
  • Loading branch information
alichtman committed Nov 17, 2021
2 parents 168b28a + 437b071 commit 5df5fb6
Show file tree
Hide file tree
Showing 7 changed files with 648 additions and 232 deletions.
213 changes: 213 additions & 0 deletions .github/workflows/installer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
name: zinit installer
on: [push, workflow_dispatch]

jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
scandir: './scripts'

zinit-installer:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
annexes: ["with-annexes", "without-annexes"]
runs-on: ${{ matrix.os }}
steps:
- name: Fix crlf (windows only)
if: startsWith(matrix.os, 'windows')
run: git config --global core.autocrlf input

- name: Check out repository code
uses: actions/checkout@v2

- name: Grab git slugs (short commit id, branch etc.)
uses: rlespinasse/github-slug-action@v3.x

- name: Install dependencies (ubuntu)
if: startsWith(matrix.os, 'ubuntu-latest')
run: |
sudo apt-get update
sudo apt-get install -y curl git zsh
- name: Install dependencies (macOS)
if: startsWith(matrix.os, 'macos')
run: |
brew install curl git zsh
- name: Install dependencies (windows)
if: startsWith(matrix.os, 'windows')
uses: egor-tensin/setup-cygwin@v3
with:
platform: x64
packages: curl git zsh

- name: Install zinit (linux/macOS, with annexes)
if: matrix.annexes == 'with-annexes' && !startsWith(matrix.os, 'windows')
run: |
export ZINIT_COMMIT="$GITHUB_SHA"
export ZINIT_REPO="$GITHUB_REPOSITORY"
export ZINIT_BRANCH="$GITHUB_REF_SLUG"
export NO_INPUT=true
sh -x ./scripts/install.sh
- name: Install zinit (linux/macOS, w/o annexes)
if: matrix.annexes == 'without-annexes' && !startsWith(matrix.os, 'windows')
run: |
export ZINIT_COMMIT="$GITHUB_SHA"
export ZINIT_REPO="$GITHUB_REPOSITORY"
export ZINIT_BRANCH="$GITHUB_REF_SLUG"
export NO_INPUT=true
export NO_ANNEXES=true
sh -x ./scripts/install.sh
- name: Install zinit (windows, with annexes)
if: matrix.annexes == 'with-annexes' && startsWith(matrix.os, 'windows')
shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
run: |
export ZINIT_COMMIT="$GITHUB_SHA"
export ZINIT_REPO="$GITHUB_REPOSITORY"
export ZINIT_BRANCH="$GITHUB_REF_SLUG"
export NO_INPUT=true
cd ${GITHUB_WORKSPACE}
sh -x ./scripts/install.sh
- name: Install zinit (windows, w/o annexes)
if: matrix.annexes == 'without-annexes' && startsWith(matrix.os, 'windows')
shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
run: |
export ZINIT_COMMIT="$GITHUB_SHA"
export ZINIT_REPO="$GITHUB_REPOSITORY"
export ZINIT_BRANCH="$GITHUB_REF_SLUG"
export NO_INPUT=true
export NO_ANNEXES=true
cd ${GITHUB_WORKSPACE}
sh -x ./scripts/install.sh
- name: Upload zshrc and zinit files (linux/macOS)
if: "!startsWith(matrix.os, 'windows')"
uses: actions/upload-artifact@v2
with:
name: zinit-config-${{ matrix.os }}-${{ matrix.annexes }}
path: |
~/.zshrc
~/.local/share/zinit
- name: Upload zshrc and zinit files (windows)
if: startsWith(matrix.os, 'windows')
uses: actions/upload-artifact@v2
with:
name: zinit-config-${{ matrix.os }}-${{ matrix.annexes }}
# cygpath -w ~ returns "C:\tools\cygwin\home\runneradmin"
# FIXME Why isn't the zinit.git/ dir not getting uploaded?
path: |
C:\tools\cygwin\home\runneradmin\.zshrc
C:\tools\cygwin\home\runneradmin\.local\.share\zinit\zinit.git
- name: Test zinit install (linux/macOS)
if: "!startsWith(matrix.os, 'windows')"
run: |
export TERM=xterm
zsh -silc 'zinit --help; exit $?'
- name: Test zinit install (windows)
shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
if: startsWith(matrix.os, 'windows')
run: |
export TERM=xterm
zsh -silc 'zinit --help; exit $?'
# TODO: DRY!
# Re-using steps in GH Actions is a pain though.
zinit-updater:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Fix crlf (windows only)
if: startsWith(matrix.os, 'windows')
run: git config --global core.autocrlf input

- name: Check out repository code
uses: actions/checkout@v2

- name: Grab git slugs (short commit id, branch etc.)
uses: rlespinasse/github-slug-action@v3.x

- name: Install dependencies (ubuntu)
if: startsWith(matrix.os, 'ubuntu-latest')
run: |
sudo apt-get update
sudo apt-get install -y curl git zsh
- name: Install dependencies (macOS)
if: startsWith(matrix.os, 'macos')
run: |
brew install curl git zsh
- name: Install dependencies (windows)
if: startsWith(matrix.os, 'windows')
uses: egor-tensin/setup-cygwin@v3
with:
platform: x64
packages: curl git zsh

- name: Install previous zinit version (linux/macOS, ${{ github.event.before }})
if: "!startsWith(matrix.os, 'windows')"
env:
PREVIOUS_COMMIT: ${{ github.event.before }}
run: |
export ZINIT_COMMIT="$PREVIOUS_COMMIT"
export ZINIT_REPO="$GITHUB_REPOSITORY"
export ZINIT_BRANCH="$GITHUB_REF_SLUG"
export NO_INPUT=true
./scripts/install.sh
- name: Install previous zinit version (windows, ${{ github.event.before }})
if: startsWith(matrix.os, 'windows')
env:
PREVIOUS_COMMIT: ${{ github.event.before }}
shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
run: |
export ZINIT_COMMIT="$PREVIOUS_COMMIT"
export ZINIT_REPO="$GITHUB_REPOSITORY"
export ZINIT_BRANCH="$GITHUB_REF_SLUG"
export NO_INPUT=true
cd ${GITHUB_WORKSPACE}
./scripts/install.sh
- name: Update zinit from ${{ github.event.before }} to ${{ github.sha }} (linux/macOS)
if: "!startsWith(matrix.os, 'windows')"
run: |
export ZINIT_COMMIT="$GITHUB_SHA"
export ZINIT_REPO="$GITHUB_REPOSITORY"
export ZINIT_BRANCH="$GITHUB_REF_SLUG"
export NO_INPUT=true
./scripts/install.sh
- name: Update zinit from ${{ github.event.before }} to ${{ github.sha }} (windows)
if: startsWith(matrix.os, 'windows')
shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
run: |
export ZINIT_COMMIT="$GITHUB_SHA"
export ZINIT_REPO="$GITHUB_REPOSITORY"
export ZINIT_BRANCH="$GITHUB_REF_SLUG"
export NO_INPUT=true
cd ${GITHUB_WORKSPACE}
./scripts/install.sh
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,30 @@ read it to get the most out of Zinit.
The easiest way to install Zinit is to execute:

```zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma-continuum/zinit/master/doc/install.sh)"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/install.sh)"
```

This will install Zinit in `~/.zinit/bin`.
This will install Zinit in `~/.local/share/zinit/zinit.git`.
`.zshrc` will be updated with three lines of code that will be added to the bottom.
The lines will be sourcing `zinit.zsh` and setting up completion for command `zinit`.

After installing and reloading the shell compile Zinit with `zinit self-update`.

### Manual Installation

To manually install Zinit clone the repo to e.g. `~/.zinit/bin`:
To manually install Zinit clone the repo to e.g. `~/.local/share/zinit/zinit.git`:

```sh
mkdir ~/.zinit
git clone https://github.com/zdharma-continuum/zinit.git ~/.zinit/bin
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
mkdir -p "$(dirname $ZINIT_HOME)"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
```

and source it from `.zshrc` (above [compinit](http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Initialization)):
and source `zinit.zsh` from your `.zshrc` (above [compinit](http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Initialization)):

```sh
source ~/.zinit/bin/zinit.zsh
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
source "${ZINIT_HOME}/zinit.zsh"
```

If you place the `source` below `compinit`, then add those two lines after the `source`:
Expand Down Expand Up @@ -920,7 +922,8 @@ after `compinit` will be called (and the original `compdef` function will become
available), to execute all detected `compdef` calls. To summarize:

```zsh
source ~/.zinit/bin/zinit.zsh
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
source "${ZINIT_HOME}/zinit.zsh"

zinit load "some/plugin"
...
Expand Down Expand Up @@ -963,7 +966,8 @@ helper functions (`zicompinit`,`zicdreplay` & `zicdclear` – see below for expl
of the last one). To summarize:

```zsh
source ~/.zinit/bin/zinit.zsh
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share/zinit}"
source "${ZINIT_HOME}/zinit.zsh"

# Load using the for-syntax
zinit wait lucid for \
Expand All @@ -982,7 +986,9 @@ before commands loading other plugins or snippets, and issue `zinit cdclear` (or
`zicdclear`, designed to be used in hooks like `atload''`):

```zsh
source ~/.zinit/bin/zinit.zsh
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
source "${ZINIT_HOME}/zinit.zsh"

zinit snippet OMZP::git
zinit cdclear -q # <- forget completions provided by Git plugin

Expand Down Expand Up @@ -1035,7 +1041,7 @@ To install just the binary Zinit module **standalone** (Zinit is not needed, the
other plugin manager), execute:

```zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma-continuum/zinit/master/doc/mod-install.sh)"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/mod-install.sh)"
```

This script will display what to add to `~/.zshrc` (2 lines) and show usage instructions.
Expand Down Expand Up @@ -1081,8 +1087,8 @@ declare -A ZINIT # initial Zinit's hash definition, if configuring before loadi

| Hash Field | Description |
| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ZINIT\[BIN_DIR\] | Where Zinit code resides, e.g.: "~/.zinit/bin" |
| ZINIT\[HOME_DIR\] | Where Zinit should create all working directories, e.g.: "~/.zinit" |
| ZINIT\[BIN_DIR\] | Where Zinit code resides, e.g.: "~/.local/share/zinit/zinit.git" |
| ZINIT\[HOME_DIR\] | Where Zinit should create all working directories, e.g.: "~/.local/share/zinit" |
| ZINIT\[MAN_DIR\] | Directory where plugins can store their manpages (`atclone"cp -vf myplugin.1 $ZINIT[MAN_DIR]/man1"`). If overridden, this directory will not necessarily be used by `man` (See #8). Default: `$ZPFX/man` |
| ZINIT\[PLUGINS_DIR\] | Override single working directory – for plugins, e.g. "/opt/zsh/zinit/plugins" |
| ZINIT\[COMPLETIONS_DIR\] | As above, but for completion files, e.g. "/opt/zsh/zinit/root_completions" |
Expand All @@ -1092,7 +1098,7 @@ declare -A ZINIT # initial Zinit's hash definition, if configuring before loadi
| ZINIT\[MUTE_WARNINGS\] | If set to `1`, then mutes some of the Zinit warnings, specifically the `plugin already registered` warning |
| ZINIT\[OPTIMIZE_OUT_DISK_ACCESSES\] | If set to `1`, then Zinit will skip checking if a Turbo-loaded object exists on the disk. By default Zinit skips Turbo for non-existing objects (plugins or snippets) to install them before the first prompt – without any delays, during the normal processing of `zshrc`. This option can give a performance gain of about 10 ms out of 150 ms (i.e.: Zsh will start up in 140 ms instead of 150 ms). |

There is also `$ZPFX`, set by default to `~/.zinit/polaris` – a directory
There is also `$ZPFX`, set by default to `~/.local/share/zinit/polaris` – a directory
where software with `Makefile`, etc. can be pointed to, by e.g. `atclone'./configure --prefix=$ZPFX'`.

## Non-GitHub (Local) Plugins
Expand Down Expand Up @@ -1135,7 +1141,7 @@ zinit as"null" wait"1" lucid for \

```

Target directory for installed files is `$ZPFX` (`~/.zinit/polaris` by default).
Target directory for installed files is `$ZPFX` (`~/.local/share/zinit/polaris` by default).

# Supporting

Expand Down
19 changes: 18 additions & 1 deletion doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
# Changelog
All notable changes to this project will be documented in this file.

* 16-11-2021
- A brand-new installer has been developed. A few new features have been
added. There are a bunch of new env vars you can set:

- `NO_INPUT=1`: non-interactive mode (`NO_INPUT=1`)
- `NO_EDIT=1`: do not modify `.zshrc`
- `ZSHRC=/home/user01/.config/zsh/zshrc`: custom path to your `.zshrc`
- `ZINIT_REPO=zdharma-continuum/zinit`: Install zinit from a custom GitHub repo
- `ZINIT_BRANCH=master`: zinit branch to install
- `ZINIT_COMMIT=master`: zinit commit to install (takes precedence over `ZINIT_BRANCH`)
- `ZINIT_INSTALL_DIR=~/.local/share/zinit/zinit.git`: Where to install the zinit repo

⚠️ Please note that the download URL for the installer has changed. It is now:
https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/install.sh

For more details check out [PR #61](https://github.com/zdharma-continuum/zinit/pull/61)

* 11-11-2021
- The annexes repos have been renamed to improve discoverability. They used to
be called `z-a-${name}` and have been renamed to `zinit-annex-${name}`. You
Expand Down Expand Up @@ -358,7 +375,7 @@ startup. Please note that these directories will not necessarily be part of your

In other words, instead of `wait'1'` you can enter `wait'1a'`,
`wait'1b'` and `wait'1c'` – to this way **impose order** on the loadings
**regardless of the order of `zplugin` commands**.
**regardless of the order of `zplugin` commands**.
* 26-05-2019
- Turbo-Mode now divides the scheduled events (i.e. loadings of plugins or snippets)
into packs of 5. In other words, after loading each series of 5 plugins or snippets
Expand Down
Loading

0 comments on commit 5df5fb6

Please sign in to comment.