diff --git a/.github/workflows/installer.yaml b/.github/workflows/installer.yaml new file mode 100644 index 000000000..8768a327d --- /dev/null +++ b/.github/workflows/installer.yaml @@ -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 diff --git a/README.md b/README.md index 9b6c3157d..239e4d74b 100644 --- a/README.md +++ b/README.md @@ -147,10 +147,10 @@ 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`. @@ -158,17 +158,19 @@ 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`: @@ -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" ... @@ -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 \ @@ -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 @@ -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. @@ -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" | @@ -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 @@ -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 diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 0721ef12f..9452251a7 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -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 @@ -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 diff --git a/doc/install.sh b/doc/install.sh deleted file mode 100755 index 40d2abe0e..000000000 --- a/doc/install.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/bin/sh - -# -# Clone or pull -# - -ZINIT_HOME="${ZINIT_HOME:-$ZPLG_HOME}" -if [ -z "$ZINIT_HOME" ]; then - ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit" -fi - -ZINIT_BIN_DIR_NAME="${ZINIT_BIN_DIR_NAME:-$ZPLG_BIN_DIR_NAME}" -if [ -z "$ZINIT_BIN_DIR_NAME" ]; then - ZINIT_BIN_DIR_NAME="zinit.git" -fi - -if ! test -d "$ZINIT_HOME"; then - mkdir -p "$ZINIT_HOME" - chmod g-w "$ZINIT_HOME" - chmod o-w "$ZINIT_HOME" -fi - -if ! command -v git >/dev/null 2>&1; then - echo "▓▒░ Something went wrong: git is not available, cannot proceed." - exit 1 -fi - -ZINIT_BRANCH="${ZINIT_BRANCH:-master}" -ZINIT_TMPDIR="$(mktemp -d)" # use -d instead of --directory for macos (BSD) compatibility -if [ ! -d "$ZINIT_TMPDIR" ]; then - echo "Tempdir creation failed. This ain't good." >&2 - exit 1 -fi - -# Get the download-progress bar tool -GIT_PROCESS_SCRIPT_URL="https://raw.githubusercontent.com/zdharma-continuum/zinit/${ZINIT_BRANCH}/share/git-process-output.zsh" -trap 'rm -rvf "$ZINIT_TMPDIR"' EXIT INT -if command -v curl >/dev/null 2>&1; then - curl -fsSL -o "${ZINIT_TMPDIR}/git-process-output.zsh" "$GIT_PROCESS_SCRIPT_URL" -elif command -v wget >/dev/null 2>&1; then - wget -q -O "${ZINIT_TMPDIR}/git-process-output.zsh" "$GIT_PROCESS_SCRIPT_URL" -fi -chmod a+x "${ZINIT_TMPDIR}/git-process-output.zsh" 2>/dev/null - -echo -if test -d "$ZINIT_HOME/$ZINIT_BIN_DIR_NAME/.git"; then - cd "$ZINIT_HOME/$ZINIT_BIN_DIR_NAME" || { echo "Failed to cd to $ZINIT_HOME/$ZINIT_BIN_DIR_NAME" >&2; exit 1; } - echo "▓▒░ Updating ZDHARMA-CONTINUUM Initiative Plugin Manager to $ZINIT_HOME/$ZINIT_BIN_DIR_NAME" - git pull origin "${ZINIT_BRANCH}" -else - cd "$ZINIT_HOME" || { echo "Failed to cd to $ZINIT_HOME" >&2; exit 1; } - echo "▓▒░ Installing ZDHARMA-CONTINUUM Initiative Plugin Manager to $ZINIT_HOME/$ZINIT_BIN_DIR_NAME" - { - git clone --progress --branch "$ZINIT_BRANCH" \ - https://github.com/zdharma-continuum/zinit.git \ - "$ZINIT_BIN_DIR_NAME" 2>&1 | { - "${ZINIT_TMPDIR}/git-process-output.zsh" || cat; - } - } 2>/dev/null - if [ -d "$ZINIT_BIN_DIR_NAME" ]; then - echo - echo "▓▒░ Zinit succesfully installed at $ZINIT_HOME/$ZINIT_BIN_DIR_NAME". - VERSION="$(command git -C "$ZINIT_HOME/$ZINIT_BIN_DIR_NAME" describe --tags 2>/dev/null)" - echo "▓▒░ Version: $VERSION" - else - echo - echo "▓▒░ Something went wrong, couldn't install Zinit to $ZINIT_HOME/$ZINIT_BIN_DIR_NAME" - fi -fi - -# -# Modify .zshrc -# -THE_ZDOTDIR="${ZDOTDIR:-$HOME}" -RCUPDATE=1 -if grep -E '(zinit|zplugin)\.zsh' "$THE_ZDOTDIR/.zshrc" >/dev/null 2>&1; then - echo "▓▒░ .zshrc already contains \`zinit …' commands – not making changes." - RCUPDATE=0 -fi - -if [ $RCUPDATE -eq 1 ]; then - echo "▓▒░ Updating $THE_ZDOTDIR/.zshrc (10 lines of code, at the bottom)" - ZINIT_HOME="$(echo "$ZINIT_HOME" | sed "s|$HOME|\$HOME|")" - command cat <<-EOF >> "$THE_ZDOTDIR/.zshrc" - -### Added by Zinit's installer -if [[ ! -f $ZINIT_HOME/$ZINIT_BIN_DIR_NAME/zinit.zsh ]]; then - print -P "%F{33}▓▒░ %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f" - command mkdir -p "$ZINIT_HOME" && command chmod g-rwX "$ZINIT_HOME" - command git clone https://github.com/zdharma-continuum/zinit "$ZINIT_HOME/$ZINIT_BIN_DIR_NAME" && \\ - print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \\ - print -P "%F{160}▓▒░ The clone has failed.%f%b" -fi - -source "$ZINIT_HOME/$ZINIT_BIN_DIR_NAME/zinit.zsh" -autoload -Uz _zinit -(( \${+_comps} )) && _comps[zinit]=_zinit -EOF - file="$(mktemp)" - command cat <<-EOF >>"$file" - -# Load a few important annexes, without Turbo -# (this is currently required for annexes) -zinit light-mode for \\ - zdharma-continuum/zinit-annex-rust \\ - zdharma-continuum/zinit-annex-as-monitor \\ - zdharma-continuum/zinit-annex-patch-dl \\ - zdharma-continuum/zinit-annex-bin-gem-node - -EOF -echo -echo "▓▒░ Would you like to add 4 useful plugins" \ - "- the most useful annexes (Zinit extensions that add new" \ - "functions-features to the plugin manager) to the zshrc as well?" \ - "It will be the following snippet:" - command cat "$file" - printf "▓▒░ Enter y/n and press Return: " - read -r input - if [ "$input" = y ] || [ "$input" = Y ]; then - command cat "$file" >> "$THE_ZDOTDIR"/.zshrc - echo - echo "▓▒░ Done." - echo - else - echo - echo "▓▒░ Done (skipped the annexes chunk)." - echo - fi - - command cat <<-EOF >> "$THE_ZDOTDIR/.zshrc" -### End of Zinit's installer chunk -EOF -fi - -command cat <<-EOF - -▓▒░ A quick intro to Zinit: below are all the available Zinit -▓▒░ ice-modifiers, grouped by their role by different colors): -▓▒░ -▓▒░ id-as'' as'' from'' wait'' trigger-load'' load'' unload'' -▓▒░ pick'' src'' multisrc'' pack'' param'' extract'' atclone'' -▓▒░ atpull'' atload'' atinit'' make'' mv'' cp'' reset'' -▓▒░ countdown'' compile'' nocompile'' nocd'' if'' has'' -▓▒░ cloneopts'' depth'' proto'' on-update-of'' subscribe'' -▓▒░ bpick'' cloneonly'' service'' notify'' wrap-track'' -▓▒░ bindmap'' atdelete'' ver'' - -▓▒░ No-value (flag-only) ices: -▓▒░ svn git silent lucid light-mode is-snippet blockf nocompletions -▓▒░ run-atpull reset-prompt trackbinds aliases sh bash ksh csh - -For more information see: -- The zdharma-continuum GitHub organization, which hosts zinit and all related components - - https://github.com/zdharma-continuum -- README section on the ice-modifiers: - - https://github.com/zdharma-continuum/zinit#ice-modifiers -- An introduction to Zinit on the wiki: - - https://zdharma-continuum.github.io/zinit/wiki/INTRODUCTION/ -- For-Syntax article on the wiki; it is less directly related to the ices but it explains how to use them conveniently: - - https://zdharma-continuum.github.io/zinit/wiki/For-Syntax/ -EOF diff --git a/doc/zinit.1 b/doc/zinit.1 index e8fe331c5..dd40718b2 100644 --- a/doc/zinit.1 +++ b/doc/zinit.1 @@ -120,7 +120,7 @@ New ice-mods \fBsh\fR,\fBbash\fR,\fBksh\fR,\fBcsh\fR that load plugins (and snip .RS 2 .nf zinit ice bash pick"bash_it.sh" \[rs] - atinit"BASH_IT=${ZPLGM\[lB]PLUGINS_DIR\[rB]}/Bash-it---bash-it" \[rs] + atinit"BASH_IT=${ZINIT\[lB]PLUGINS_DIR\[rB]}/Bash-it---bash-it" \[rs] atclone"yes n | ./install.sh" zinit load Bash-it/bash-it .fi @@ -172,7 +172,7 @@ The unloading of Zle widgets is now more smart \[en] it takes into account the c .RS 4 .IP \(bu 4 \fB--all\fR \[en] deletes all plugins and snippets (a purge, similar to \fBrm -rf -${ZPLGM\[lB]PLUGINS_DIR\[rB]} ${ZPLGM\[lB]SNIPPETS_DIR\[rB]}\fR) +${ZINIT\[lB]PLUGINS_DIR\[rB]} ${ZINIT\[lB]SNIPPETS_DIR\[rB]}\fR) .IP \(bu 4 \fB--clean\fR \[en] deletes only plugins and snippets that are \fBcurrently not loaded\fR in the current session. .RE 0 @@ -317,19 +317,20 @@ The easiest way to install zinit is to execute: .P .RS 2 .nf -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)" .fi .RE .P -This will install zinit in \fB~/.zinit/bin\fR. \fB.zshrc\fR will be updated with three lines of code that will be added to the bottom. The lines will be sourcing \fBzinit.zsh\fR and setting up completion for command \fBzinit\fR. After installing and reloading the shell compile zinit with \fBzinit self-update\fR. +This will install zinit in \fB~/.local/share/zinit/zinit.git\fR. \fB.zshrc\fR will be updated with a few lines of code that will be added to the bottom. The lines will be sourcing \fBzinit.zsh\fR and setting up completion for command \fBzinit\fR. After installing and reloading the shell compile zinit with \fBzinit self-update\fR. .SS "Option 2 - Manual Installation" .P -To manually install zinit clone the repo to e.g. \fB~/.zinit/bin\fR: +To manually install zinit clone the repo to e.g. \fB~/.local/share/zinit/zinit.git\fR: .P .RS 2 .nf -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" .fi .RE .P @@ -337,7 +338,8 @@ and source it from \fB.zshrc\fR (above compinit): .P .RS 2 .nf -source ~/.zinit/bin/zinit.zsh +ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" +source "${ZINIT_HOME}/zinit.zsh" .fi .RE .P @@ -374,7 +376,7 @@ zinit load zdharma/history-search-multi-word zinit ice pick"async.zsh" src"pure.zsh" zinit light sindresorhus/pure -# Binary release in archive, from GitHub-releases page. +# Binary release in archive, from GitHub-releases page. # After automatic unpacking it provides program "fzf". zinit ice from"gh-r" as"program" zinit load junegunn/fzf-bin @@ -444,12 +446,12 @@ tab(@); cb cb c l . Modifier@Description -\fBproto\fR@ Change protocol to \fBgit\fR,\fBftp\fR,\fBftps\fR,\fBssh\fR, \fBrsync\fR, etc. Default is \fBhttps\fR. \fBDoes not work with snippets.\fR +\fBproto\fR@ Change protocol to \fBgit\fR,\fBftp\fR,\fBftps\fR,\fBssh\fR, \fBrsync\fR, etc. Default is \fBhttps\fR. \fBDoes not work with snippets.\fR \fBfrom\fR@ Clone plugin from given site. Supported are \fBfrom"github"\fR (default), \fB..."github-rel"\fR, \fB..."gitlab"\fR, \fB..."bitbucket"\fR, \fB..."notabug"\fR (short names: \fBgh\fR, \fBgh-r\fR, \fBgl\fR, \fBbb\fR, \fBnb\fR). Can also be a full domain name (e.g. for GitHub enterprise). \fBDoes not work with snippets.\fR \fBver\fR@ Used with \fBfrom"gh-r"\fR (i.e. downloading a binary release, e.g. for use with \fBas"program"\fR) \[en] selects which version to download. Default is latest, can also be explicitly \fBver"latest"\fR. Works also with regular plugins, checkouts e.g. \fBver"abranch"\fR, i.e. a specific version. \fBDoes not work with snippets.\fR -\fBbpick\fR@ Used to select which release from GitHub Releases to download, e.g. \fBzplg ice from"gh-r" as"program" bpick"*Darwin*"; zplg load docker/compose\fR. \fBDoes not work with snippets.\fR +\fBbpick\fR@ Used to select which release from GitHub Releases to download, e.g. \fBzplg ice from"gh-r" as"program" bpick"*Darwin*"; zplg load docker/compose\fR. \fBDoes not work with snippets.\fR \fBdepth\fR@ Pass \fB--depth\fR to \fBgit\fR, i.e. limit how much of history to download. \fBDoes not work with snippets.\fR -\fBcloneopts\fR@ Pass the contents of \fBcloneopts\fR to \fBgit clone\fR. Defaults to \fB--recursive\fR i.e. Change cloning options. \fBDoes not work with snippets.\fR +\fBcloneopts\fR@ Pass the contents of \fBcloneopts\fR to \fBgit clone\fR. Defaults to \fB--recursive\fR i.e. Change cloning options. \fBDoes not work with snippets.\fR \fBsvn\fR@ Use Subversion for downloading snippet. GitHub supports \fBSVN\fR protocol, this allows to clone subdirectories as snippets, e.g. \fBzinit ice svn; zinit snippet OMZ::plugins/git\fR. Other ice \fBpick\fR can be used to select file to source (default are: \fB*.plugin.zsh\fR, \fBinit.zsh\fR, \fB*.zsh-theme\fR). \fBDoes not work with plugins.\fR .TE .SS "Selection of Files (To Source, …)" @@ -471,10 +473,10 @@ Modifier@Description \fB\fB\fBwait\fB\fR\fR \fI\(lahttps://zdharma-continuum.github.io/zinit/wiki/Example-wait-conditions\(ra\fR@ Postpone loading a plugin or snippet. For \fBwait'1'\fR, loading is done \fB1\fR second after prompt. For \fBwait'\[lB]\[lB] ... \[rB]\[rB]'\fR, \fBwait'(( ... ))'\fR, loading is done when given condition is meet. For \fBwait'!...'\fR, prompt is reset after load. Zsh can start 73% faster thanks to postponed loading. \fBFact:\fR when \fBwait\fR is used without value, it works as \fBwait'0'\fR. \fB\fB\fBload\fB\fR\fR \fI\(lahttps://zdharma-continuum.github.io/zinit/wiki/Multiple-prompts\(ra\fR@ A condition to check which should cause plugin to load. It will load once, the condition can be still true, but will not trigger second load (unless plugin is unloaded earlier, see \fBunload\fR below). E.g.: \fBload'\[lB]\[lB] $PWD = */github* \[rB]\[rB]'\fR. \fB\fB\fBunload\fB\fR\fR \fI\(lahttps://zdharma-continuum.github.io/zinit/wiki/Multiple-prompts\(ra\fR@ A condition to check causing plugin to unload. It will unload once, then only if loaded again. E.g.: \fBunload'\[lB]\[lB] $PWD != */github* \[rB]\[rB]'\fR. -\fBcloneonly\fR@ Don't load the plugin / snippet, only download it +\fBcloneonly\fR@ Don't load the plugin / snippet, only download it \fBif\fR@ Load plugin or snippet only when given condition is fulfilled, for example: \fBzinit ice if'\[lB]\[lB] -n "$commands\[lB]otool\[rB]" \[rB]\[rB]'; zinit load ...\fR. \fBhas\fR@ Load plugin or snippet only when given command is available (in $PATH), e.g. \fBzinit ice has'git' ...\fR -\fBsubscribe\fR / \fBon-update-of\fR@ Postpone loading of a plugin or snippet until the given file(s) get updated, e.g. \fBsubscribe'{~/files-*,/tmp/files-*}'\fR +\fBsubscribe\fR / \fBon-update-of\fR@ Postpone loading of a plugin or snippet until the given file(s) get updated, e.g. \fBsubscribe'{~/files-*,/tmp/files-*}'\fR .TE .SS "Plugin Output" .TS @@ -715,7 +717,8 @@ compinit\fR. This should be done after loading of all plugins and before possibl .P .RS 2 .nf -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" ... @@ -751,7 +754,9 @@ If you want to ignore compdefs provided by some plugins or snippets, place their .P .RS 2 .nf -source ~/.zinit/bin/zinit.zsh +ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" +source "${ZINIT_HOME}/zinit.zsh" + zinit snippet OMZ::plugins/git/git.plugin.zsh zinit cdclear -q # <- forget completions provided by Git plugin @@ -788,7 +793,7 @@ To install just the binary zinit module \fBstandalone\fR (zinit is not needed, t .P .RS 2 .nf -sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma/zinit/master/doc/mod-install.sh)" +sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma/zinit/master/scripts/mod-install.sh)" .fi .RE .P @@ -820,11 +825,11 @@ typeset -g ZPLG_MOD_DEBUG=1 .SH "HINTS AND TIPS" .SS "Customizing Paths" .P -Following variables can be set to custom values, before sourcing zinit. The previous global variables like \fB$ZPLG_HOME\fR have been removed to not pollute the namespace \[en] there's single \fB$ZPLGM\fR ("\fIzinit MAP\fR") hash instead of \fB8\fR string variables. Please update your dotfiles. +Following variables can be set to custom values, before sourcing zinit. The previous global variables like \fB$ZPLG_HOME\fR have been removed to not pollute the namespace \[en] there's single \fB$ZINIT\fR ("\fIzinit MAP\fR") hash instead of \fB8\fR string variables. Please update your dotfiles. .P .RS 2 .nf -declare -A ZPLGM # initial zinit's hash definition, if configuring before loading zinit, and then: +declare -A ZINIT # initial zinit's hash definition, if configuring before loading zinit, and then: .fi .RE .TS @@ -832,20 +837,20 @@ tab(@); cb cb l l . Hash Field@Description -ZPLGM\fBBIN_DIR\fR@ Where zinit code resides, e.g.: "~/.zinit/bin" -ZPLGM\fBHOME_DIR\fR@ Where zinit should create all working directories, e.g.: "~/.zinit" -ZPLGM\fBPLUGINS_DIR\fR@Override single working directory \[en] for plugins, e.g. "/opt/zsh/zinit/plugins" -ZPLGM\fBCOMPLETIONS_DIR\fR@As above, but for completion files, e.g. "/opt/zsh/zinit/root_completions" -ZPLGM\fBSNIPPETS_DIR\fR@ As above, but for snippets -ZPLGM\fBZCOMPDUMP_PATH\fR@Path to \fB.zcompdump\fR file, with the file included (i.e. its name can be different) -ZPLGM\fBCOMPINIT_OPTS\fR@Options for \fBcompinit\fR call (i.e. done by \fBzpcompinit\fR), use to pass -C to speed up loading -ZPLGM\fBMUTE_WARNINGS\fR@If set to \fB1\fR, then mutes some of the zinit warnings, specifically the \fBplugin already registered\fR warning +ZINIT\fBBIN_DIR\fR@ Where zinit code resides, e.g.: "~/.local/share/zinit/zinit.git" +ZINIT\fBHOME_DIR\fR@ Where zinit should create all working directories, e.g.: "~/.local/share/zinit" +ZINIT\fBPLUGINS_DIR\fR@Override single working directory \[en] for plugins, e.g. "/opt/zsh/zinit/plugins" +ZINIT\fBCOMPLETIONS_DIR\fR@As above, but for completion files, e.g. "/opt/zsh/zinit/root_completions" +ZINIT\fBSNIPPETS_DIR\fR@ As above, but for snippets +ZINIT\fBZCOMPDUMP_PATH\fR@Path to \fB.zcompdump\fR file, with the file included (i.e. its name can be different) +ZINIT\fBCOMPINIT_OPTS\fR@Options for \fBcompinit\fR call (i.e. done by \fBzpcompinit\fR), use to pass -C to speed up loading +ZINIT\fBMUTE_WARNINGS\fR@If set to \fB1\fR, then mutes some of the zinit warnings, specifically the \fBplugin already registered\fR warning .TE .P -There is also \fB$ZPFX\fR, set by default to \fB~/.zinit/polaris\fR \[en] a directory where software with \fBMakefile\fR, etc. can be pointed to, by e.g. \fBatclone'./configure --prefix=$ZPFX'\fR. +There is also \fB$ZPFX\fR, set by default to \fB~/.local/share/zinit/polaris\fR \[en] a directory where software with \fBMakefile\fR, etc. can be pointed to, by e.g. \fBatclone'./configure --prefix=$ZPFX'\fR. .SS "Non-GitHub (Local) Plugins" .P -Use \fBcreate\fR subcommand with user name \fB_local\fR (the default) to create plugin's skeleton in \fB$ZPLGM\[lB]PLUGINS_DIR\[rB]\fR. It will be not connected with GitHub repository (because of user name being \fB_local\fR). To enter the plugin's directory use \fBcd\fR command with just plugin's name (without \fB_local\fR, it's optional). +Use \fBcreate\fR subcommand with user name \fB_local\fR (the default) to create plugin's skeleton in \fB$ZINIT\[lB]PLUGINS_DIR\[rB]\fR. It will be not connected with GitHub repository (because of user name being \fB_local\fR). To enter the plugin's directory use \fBcd\fR command with just plugin's name (without \fB_local\fR, it's optional). .P If user name will not be \fB_local\fR, then zinit will create repository also on GitHub and setup correct repository origin. .SS "Extending Git" @@ -880,7 +885,7 @@ zinit light k4rthik/git-cal .fi .RE .P -Target directory for installed files is \fB$ZPFX\fR (\fB~/.zinit/polaris\fR by default). +Target directory for installed files is \fB$ZPFX\fR (\fB~/.local/share/zinit/polaris\fR by default). .SS "Preinstalling Plugins" .P If you create a Docker image that uses zinit, or want to install Turbo-loaded plugins before the shell starts interactively, you can invoke the zinit-scheduler function in such a way, that it: diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 000000000..d3bedc354 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,331 @@ +#!/usr/bin/env sh + +{ # Colors + COLOR_RESET='' + COLOR_BOLD_RED='' + COLOR_BOLD_GREEN='' + COLOR_BOLD_YELLOW='' + COLOR_BOLD_BLUE='' + COLOR_BOLD_MAGENTA='' + COLOR_BOLD_CYAN='' + + # The over-the-top fancy ones + COLOR_PALE_MAGENTA='' + COLOR_BOLD_WHITE_ON_BLACK='' +} + +echo_fancy() { + emoji="$1" + color="$2" + shift 2 + + msg="" + # prepend emoji, unless NO_EMOJI is set + if [ -z "$NO_EMOJI" ]; then + msg="$emoji" + fi + + # wrap every word in color (needed in case there are custom colors in + # the message itself), unless NO_COLOR is set + for str in "$@" + do + # FIXME: NO_COLOR only applies if there are no colors in the msg + if [ -z "$NO_COLOR" ]; then + msg="${msg}${color}" + fi + msg="${msg}${str}" + done + + # Actual output + echo "${msg}${COLOR_RESET}" >&2 + # fake "local" vars + unset emoji color str msg +} + +echo_info() { + echo_fancy "🔵" "${COLOR_BOLD_BLUE}" "INFO: ${*}" +} + +echo_success() { + echo_fancy "✅" "${COLOR_BOLD_GREEN}" "SUCCESS: ${*}" +} + +echo_warn() { + echo_fancy "🚧" "${COLOR_BOLD_YELLOW}" "WARNING: ${*}" +} + +echo_error() { + echo_fancy "❌" "${COLOR_BOLD_RED}" "ERROR: ${*}" +} + +check_dependencies() { + zsh_min_version=5.5 + if ! zsh -sfc \ + 'autoload is-at-least; + is-at-least $1 $ZSH_VERSION' "$zsh_min_version"; then + echo_warning "ZSH version 5.5+ is recommended for zinit." \ + "It'll still work, but be warned." + fi + + if ! command -v git >/dev/null 2>&1; then + echo_error "${COLOR_BOLD_GREEN}git${COLOR_RESET} is not installed" + exit 1 + fi + + unset zsh_min_version +} + +show_environment() { + echo_info "About to setup zinit from $ZINIT_REPO" \ + "(branch: $ZINIT_BRANCH - commit: ${ZINIT_COMMIT:-N/A})" \ + "to ${ZINIT_INSTALL_DIR}" +} + +create_zinit_home() { + if ! test -d "${ZINIT_HOME}"; then + mkdir -p "${ZINIT_HOME}" + chmod g-w "${ZINIT_HOME}" + chmod o-w "${ZINIT_HOME}" + fi +} + +create_zinit_tmpdir() { + # use -d instead of --directory for macos (BSD) compatibility + ZINIT_TMPDIR="$(mktemp -d)" + if [ ! -d "$ZINIT_TMPDIR" ]; then + echo_error "Tempdir creation failed. This ain't good" + exit 1 + fi + + trap 'rm -rvf "$ZINIT_TMPDIR"' EXIT INT +} + +# Get the download-progress bar tool +download_git_output_processor() { + url="https://raw.githubusercontent.com/${ZINIT_REPO}/${ZINIT_COMMIT:-${ZINIT_BRANCH}}/share/git-process-output.zsh" + script_path="${ZINIT_TMPDIR}/git-process-output.zsh" + + echo_info "Fetching git-process-output.zsh from $url" + if command -v curl >/dev/null 2>&1; then + curl -fsSL -o "$script_path" "$url" + elif command -v wget >/dev/null 2>&1; then + wget -q -O "$script_path" "$url" + fi + + # shellcheck disable=2181 + if [ "$?" -eq 0 ] + then + chmod a+x "$script_path" 2>/dev/null + echo_success 'Download finished!' + else + echo_warn "Download failed." + fi + + unset url script_path +} + +zinit_git_exec() { + command git -C "${ZINIT_INSTALL_DIR}" "$@" +} + +zinit_checkout_ref() { + ref="${ZINIT_BRANCH}" + git_obj_type="branch" + + if [ -n "$ZINIT_COMMIT" ] + then + ref="$ZINIT_COMMIT" + git_obj_type="commit" + fi + + if zinit_git_exec checkout "$ref" >/dev/null 2>&1; then + echo_success "Checked out $git_obj_type $ref" + else + echo_error "Failed to check out $git_obj_type $ref" + fi + + unset ref git_obj_type +} + +zinit_current_version() { + zinit_git_exec describe --tags 2>/dev/null +} + +zinit_update() { + cd "${ZINIT_INSTALL_DIR}" || { + echo_error "Failed to cd to ${ZINIT_INSTALL_DIR}" + exit 1 + } + + echo_info "Updating ${COLOR_BOLD_CYAN}zinit${COLOR_RESET} in" \ + "in ${COLOR_BOLD_MAGENTA}${ZINIT_INSTALL_DIR}" + { # Clean up repo + zinit_git_exec clean -d -f -f + zinit_git_exec reset --hard HEAD + } >/dev/null 2>&1 + + # fetch our branch (to ensure the target commit exists locally) + zinit_git_exec fetch origin "$ZINIT_BRANCH" + + zinit_checkout_ref + if zinit_git_exec pull origin "$ZINIT_BRANCH"; then + echo_success "Updated zinit to $(zinit_current_version)" + fi +} + +zinit_install() { + cd "${ZINIT_HOME}" || { + echo_error "Failed to cd to ${ZINIT_HOME}" + exit 1 + } + + echo_info "Installing ${COLOR_BOLD_CYAN}zinit${COLOR_RESET} to " \ + "${COLOR_BOLD_MAGENTA}${ZINIT_INSTALL_DIR}" + { + command git clone --progress --branch "$ZINIT_BRANCH" \ + "https://github.com/${ZINIT_REPO}" \ + "${ZINIT_REPO_DIR_NAME}" 2>&1 | { + "${ZINIT_TMPDIR}/git-process-output.zsh" || cat; + } + } 2>/dev/null + + zinit_checkout_ref + + if [ -d "${ZINIT_REPO_DIR_NAME}" ]; then + echo_success "Zinit succesfully installed to " \ + "${COLOR_BOLD_GREEN}${ZINIT_INSTALL_DIR}" + echo_info "Zinit Version: ${COLOR_BOLD_GREEN}$(zinit_current_version)" + else + echo_error "Failed to install Zinit to ${COLOR_BOLD_YELLOW}${ZINIT_INSTALL_DIR}" + fi +} + +# Modify .zshrc +edit_zshrc() { + rc_update=1 + if grep -E '(zinit|zplugin)\.zsh' "${ZSHRC}" >/dev/null 2>&1; then + echo_warn "${ZSHRC} already contains zinit commands. Not making any changes." + rc_update=0 + fi + + if [ $rc_update -eq 1 ]; then + echo_info "Updating ${ZSHRC} (10 lines of code, at the bottom)" + zinit_home_escaped="$(echo "${ZINIT_HOME}" | sed "s|$HOME|\$HOME|")" + command cat <<-EOF >> "$ZSHRC" + +### Added by Zinit's installer +if [[ ! -f ${zinit_home_escaped}/${ZINIT_REPO_DIR_NAME}/zinit.zsh ]]; then + print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}${ZINIT_REPO}%F{220})…%f" + command mkdir -p "${zinit_home_escaped}" && command chmod g-rwX "${zinit_home_escaped}" + command git clone https://github.com/${ZINIT_REPO} "${zinit_home_escaped}/${ZINIT_REPO_DIR_NAME}" && \\ + print -P "%F{33} %F{34}Installation successful.%f%b" || \\ + print -P "%F{160} The clone has failed.%f%b" +fi + +source "${zinit_home_escaped}/${ZINIT_REPO_DIR_NAME}/zinit.zsh" +autoload -Uz _zinit +(( \${+_comps} )) && _comps[zinit]=_zinit +EOF + fi + + unset rc_update zinit_home_escaped +} + +query_for_annexes() { + zshrc_annex_file="$(mktemp)" + command cat <<-EOF >>"$zshrc_annex_file" + +# Load a few important annexes, without Turbo +# (this is currently required for annexes) +zinit light-mode for \\ + zdharma-continuum/zinit-annex-as-monitor \\ + zdharma-continuum/zinit-annex-bin-gem-node \\ + zdharma-continuum/zinit-annex-patch-dl \\ + zdharma-continuum/zinit-annex-rust + +EOF + # Ask user if we should add the annexes to their zshrc + # If NO_INPUT is set, but NO_ANNEXES is the annexes bit gets appended to the + # config (ie. default to yes if NO_INPUT, unless NO_ANNEXES) + reply=n + if [ -n "$NO_INPUT" ] + then + [ -z "$NO_ANNEXES" ] && reply=y + else + echo "${COLOR_PALE_MAGENTA}${COLOR_RESET} Would you like to add 4 useful plugins" \ + "- the most useful annexes (Zinit extensions that add new" \ + "functions-features to the plugin manager) to the zshrc as well?" \ + "It will be the following snippet:" + command cat "$zshrc_annex_file" + # shellcheck disable=2059 + printf "${COLOR_PALE_MAGENTA}${COLOR_RESET} Enter y/n and press Return: " + read -r reply + fi + + if [ "$reply" = y ] || [ "$reply" = Y ]; then + command cat "$zshrc_annex_file" >> "$ZSHRC" + echo_success 'Done!' + else + echo_warning "Skipped the annexes." + fi + + command cat <<-EOF >> "$ZSHRC" +### End of Zinit's installer chunk +EOF + unset reply zshrc_annex_file +} + + +display_tutorial() { + command cat <<-EOF + +🌻 ${COLOR_BOLD_WHITE_ON_BLACK}Welcome!${COLOR_RESET} + +Now to get started you can check out the following: + +- The ${COLOR_BOLD_WHITE_ON_BLACK}README${COLOR_RESET} section on the ice-modifiers: + 🧊 https://github.com/${ZINIT_REPO}#ice-modifiers +- There's also an ${COLOR_BOLD_WHITE_ON_BLACK}introduction${COLOR_RESET} to Zinit on the wiki: + 📚 https://zdharma-continuum.github.io/zinit/wiki/INTRODUCTION/ +- The ${COLOR_BOLD_WHITE_ON_BLACK}For-Syntax${COLOR_RESET} article on the wiki, which hilights some best practises: + 📖 https://zdharma-continuum.github.io/zinit/wiki/For-Syntax/ + +💁 Need help? +- 💬 Get in touch with us on Gitter: https://gitter.im/zdharma-continuum +- 🔖 Or on GitHub: https://github.com/zdharma-continuum +EOF +} + +# Globals. Can be overridden. +ZINIT_REPO="${ZINIT_REPO:-zdharma-continuum/zinit}" +ZINIT_BRANCH="${ZINIT_BRANCH:-master}" +ZINIT_COMMIT="${ZINIT_COMMIT:-}" # no default value +ZINIT_HOME="${ZINIT_HOME:-${XDG_DATA_HOME:-${HOME}/.local/share}/zinit}" +ZINIT_REPO_DIR_NAME="${ZINIT_REPO_DIR_NAME:-zinit.git}" +ZINIT_INSTALL_DIR=${ZINIT_INSTALL_DIR:-${ZINIT_HOME}/${ZINIT_REPO_DIR_NAME}} +ZSHRC="${ZSHRC:-${ZDOTDIR:-${HOME}/.zshrc}}" + +show_environment +check_dependencies +create_zinit_home +create_zinit_tmpdir +download_git_output_processor + +if [ -d "${ZINIT_INSTALL_DIR}/.git" ]; then + zinit_update +else + zinit_install +fi + +if [ -z "$NO_EDIT" ] +then + edit_zshrc + query_for_annexes +fi + +if [ -z "$NO_TUTORIAL" ] +then + display_tutorial +fi + +# vim: set ft=sh et ts=2 sw=2 : diff --git a/doc/mod-install.sh b/scripts/mod-install.sh similarity index 56% rename from doc/mod-install.sh rename to scripts/mod-install.sh index 0fdb4337d..e15a2032c 100755 --- a/doc/mod-install.sh +++ b/scripts/mod-install.sh @@ -15,17 +15,17 @@ echo "${col_info}Re-run this script to update (from Github) and rebuild the modu ZINIT_HOME="${ZDOTDIR:-$HOME}/.zinit" if ! test -d "$ZINIT_HOME"; then - mkdir "$ZINIT_HOME" - chmod g-rwX "$ZINIT_HOME" + mkdir "$ZINIT_HOME" + chmod g-rwX "$ZINIT_HOME" fi echo ">>> Downloading zdharma-continuum/zinit module to $ZINIT_HOME/mod-bin" if test -d "$ZINIT_HOME/mod-bin/.git"; then - cd "$ZINIT_HOME/mod-bin" - git pull origin master + cd "$ZINIT_HOME/mod-bin" || exit 9 + git pull origin master else - cd "$ZINIT_HOME" - git clone --depth 10 https://github.com/zdharma-continuum/zinit.git mod-bin + cd "$ZINIT_HOME" || exit 9 + git clone --depth 10 https://github.com/zdharma-continuum/zinit.git mod-bin fi echo ">>> Done" @@ -33,34 +33,39 @@ echo ">>> Done" # Build the module # -cd "$ZINIT_HOME/mod-bin/zmodules" +cd "$ZINIT_HOME/mod-bin/zmodules" || exit 9 echo "$col_pname== Building module zdharma-continuum/zinit, running: a make clean, then ./configure and then make ==$col_rst" echo "$col_pname== The module sources are located at: $ZINIT_HOME/mod-bin/zmodules ==$col_rst" -test -f Makefile && { [ "$1" = "--clean" ] && { - echo "$col_info2-- make distclean --$col_rst" - make distclean - true - } || { - echo "$col_info2-- make clean (pass --clean to invoke \`make distclean') --$col_rst" - make clean - } -} +if test -f Makefile; then + if [ "$1" = "--clean" ]; then + echo "$col_info2-- make distclean --$col_rst" + make distclean + true + else + echo "$col_info2-- make clean (pass --clean to invoke \`make distclean') --$col_rst" + make clean + fi +fi + echo "$col_info2-- ./configure --$col_rst" -CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && { +if CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib \ + ./configure --disable-gdbm --without-tcsetpgrp; then echo "$col_info2-- make --$col_rst" - make && { + if make; then echo "${col_info}Module has been built correctly.$col_rst" echo "To load the module, add following 2 lines to .zshrc, at top:" - echo " module_path+=( \"$ZINIT_HOME/mod-bin/zmodules/Src\" )" - echo " zmodload zdharma-continuum/zinit" + echo " module_path+=( \"$ZINIT_HOME/mod-bin/zmodules/Src\" )" + echo " zmodload zdharma-continuum/zinit" echo "" echo "After loading, use command \`zpmod' to communicate with the module." echo "See \`zpmod -h' for more information. There are two main features," echo "invocation of \`zpmod source-study' which shows \`source' profile" echo "data, and guaranteed, automatic compilation of any sourced script" echo "while the module is loaded (check with Zsh command \`zmodload')." - } || { - echo "${col_error}Module didn't build.$col_rst. You can copy the error messages and submit" - echo "error-report at: https://github.com/zdharma-continuum/zinit/issues" - } -} + else + echo "${col_error}Module didn't build.$col_rst. You can copy the error messages and submit" + echo "error-report at: https://github.com/zdharma-continuum/zinit/issues" + fi +fi + +# vim: set ft=sh et ts=2 sw=2 :