ZI(1)
π ZI(1) π
okay bestie, so this is the manual page for ZI β literally the whole thing, section by section, and I'm gonna walk you through every single bit of it because you deserve to know. no skimming, no "you'll figure it out", we're doing this properly. π
β¨ NEWS β¨
Table of Contents generated with DocToc (https://github.com/thlorenz/doctoc)
- News (News)
- ZI (ZI)
- ZI Wiki (ZI Wiki)
- Installation (Installation)
- Option 1 - Automatic Installation (Recommended) (Option 1 - Automatic Installation (Recommended))
- Option 2 - Manual Installation (Option 2 - Manual Installation)
- Usage (Usage)
- Introduction (Introduction)
- Example Usage (Example Usage)
- Ice Modifiers (Ice Modifiers)
- ZI Commands (ZI Commands)
- Updating ZI and Plugins (Updating ZI and Plugins)
- Using Oh My Zsh Themes (Using Oh My Zsh Themes)
- Completions (Completions)
- Calling compinit Without Turbo Mode (Calling compinit Without Turbo Mode)
- Calling compinit With Turbo Mode (Calling compinit With Turbo Mode)
- Ignoring Compdefs (Ignoring Compdefs)
- Disabling System-Wide compinit Call (Ubuntu) (Disabling System-Wide compinit Call (Ubuntu))
- ZI Module (ZI Module)
- Motivation (Motivation)
- Installation (Installation)
- Measuring Time of sources (Measuring Time of sources)
- Debugging (Debugging)
- Hints and Tips (Hints and Tips)
- Customizing Paths (Customizing Paths)
- Non-GitHub (Local) Plugins (Non-GitHub (Local) Plugins)
- Extending Git (Extending Git)
- Preinstalling Plugins (Preinstalling Plugins)
- Getting Help and Community (Getting Help and Community)
π 12-10-2019
- Special value for the
id-as''ice βauto. It sets the plugin/snippet ID automatically to the last component of its spec, e.g.:
zi ice id-as"auto"
zi load robobenklein/zinc
will load the plugin as id-as'zinc'. slay.
π 14-09-2019
- There's a Vim plugin which extends syntax highlighting of zsh scripts with coloring of the ZI commands. Project homepage (
https://github.com/zi/zi-vim-syntax). π
π 13-09-2019
- New ice
aliaseswhich loads plugin with the aliases mechanism enabled. Use for plugins that define and use aliases in their scripts.
π 11-09-2019
- New ice-mods
sh,bash,ksh,cshthat load plugins (and snippets) with the sticky emulation feature of Zsh β all functions defined within the plugin will automatically switch to the desired emulation mode before executing and switch back thereafter. In other words it is now possible to load e.g. bash plugins with ZI, provided that the emulation level done by Zsh is sufficient, e.g.:
zi ice bash pick"bash_it.sh" \
atinit"BASH_IT=${ZPLGM[PLUGINS_DIR]}/Bash-it---bash-it" \
atclone"yes n | ./install.sh"
zi load Bash-it/bash-it
This script loads correctly thanks to the emulation, however it isn't functional because it uses type -t β¦ to check if a function exists. π (so close, bestie)
π 10-09-2019
- A new ice-mod
reset''that ivokesgit reset --hard(or the provided command) beforegit pullandatpull''ice. It can be used it to implement altering (i.e. patching) of the plugin's files inside theatpull''ice β git will report no conflicts when doing pull, and the changes can be then again introduced by theatpull''ice. - Three new ZI annexes (i.e. extensions (
http://z-shell.github.io/zi/wiki/Annexes/)):z-a-man(https://github.com/z-shell/z-a-man)
Generates man pages and code-documentation man pages from plugin's README.md and source files (the code documentation is obtained from Zshelldoc (https://github.com/z-shell/zshelldoc)).
z-a-test(https://github.com/z-shell/z-a-test)
Runs tests (if detected test target in a Makefile or any *.zunit files) on plugin installation and non-empty update.
z-a-patch-dl(https://github.com/z-shell/z-a-patch-dl)
Allows easy download and applying of patches, to e.g. aid building a binary program equipped in the plugin.
- A new variable is being recognized by the installation script:
$ZPLG_BIN_DIR_NAME. It configures the directory within$ZPLG_HOMEto which ZI should be cloned. π«Ά
π 09-08-2019
- A new ice-mod
wrap-track''which gets;-separated list of functions that are to be tracked once when executing. In other words you can extend the tracking beyond the moment of loading of a plugin. - The unloading of Zle widgets is now more smart β it takes into account the chains of plugins that can overload the Zle widgets, and solves the interactions that result out of it. β¨
π 29-07-2019
deletenow supports following options:--allβ deletes all plugins and snippets (a purge, similar torm -rf ${ZPLGM[PLUGINS_DIR]} ${ZPLGM[SNIPPETS_DIR]})--cleanβ deletes only plugins and snippets that are currently not loaded in the current session.
ngl --all is giving "no thoughts, head empty, everything gone" energy. use it on purpose, bestie. π
π 09-07-2019
- ZI can now have its own plugins, called z-plugins! Check out an example but fully functional z-plugin
z-shell/z-a-submods(https://github.com/z-shell/z-a-submods) and a document that explains on how to implement your own z-plugin (here (../../wiki/Z-PLUGINS)).
π 08-07-2019
- You can now do
zi ice wait ...and it will work aszi ice wait'0' ...:) I.e. when there's no value to thewait''ice then a value of0is being substituted. π
π 02-07-2019
- Cooperation of Fast-Syntax-Highlighting and ZI (
https://asciinema.org/a/254630) β a new precise highlighting for ZI in F-Sy-H. iconic.
π 01-07-2019
atclone'',atpull''&make''get run in the same subshell, thus an e.g.exportdone inatclone''will be visible during themake. π
π 26-06-2019
notify''contents gets evaluated, i.e. can contain active code like$(tail -1 /var/log/messages), etc.
π 23-06-2019
- New ice mod
subscribe''/on-update-of''which works like thewait''ice-mod, i.e. defers loading of a plugin, but it looks at modification time of the given file(s), and when it changes, it then triggers loading of the plugin/snippet:
% zi ice on-update-of'{~/files-*,/tmp/files-*}' lucid \
atload"echo I have been loaded" \
notify"Yes that's true :)"
% zi load z-shell/null
% touch ~/files-1
The plugin has been loaded
%
Yes that's true :)
The plugin/snippet will be sourced as many times as the file gets updated. π₯
π 22-06-2019
- New ice mod
reset-promptthat will issuezle .reset-promptafter loading the plugin or snippet, causing the prompt to be recomputed. Useful with themes & Turbo mode. - New ice-mod
notify''which will cause to display an under-prompt notification when the plugin or snippet gets loaded. E.g.:
% zi ice wait"0" lucid notify"z-shell/null has been loaded"
% zi light z-shell/null
%
z-shell/null has been loaded
In case of problems with the loading a warning message will be output:
% zi ice notify atload'return 7'
% zi light z-shell/null
%
notify: Plugin not loaded / loaded with problem, the return code: 7
Refer to Ice Modifiers (Ice Modifiers) section for a complete description.
π 29-05-2019
- Turbo mode, i.e. the
wait''ice-mode now supports a suffix β the lettera,borc. The meaning is illustrated by the following example:
zi ice wait"0b" as"command" pick"wd.sh" atinit"echo Firing 1" lucid
zi light mfaerevaag/wd
zi ice wait"0a" as"command" pick"wd.sh" atinit"echo Firing 2" lucid
zi light mfaerevaag/wd
# The output
Firing 2
Firing 1
As it can be seen, the second plugin has been loaded first. That's because there are now three sub-slots (the a, b and c) in which the plugin/snippet loadings can be put into. Plugins from the same time-slot with suffix a will be loaded before plugins with suffix b, etc.
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 zi commands. π§
To see the full history check the changelog (CHANGELOG.md).
π ZI π
ZI is an elastic and fast Zshell plugin manager that will allow you to install everything from GitHub and other sites.
ZI is currently the only plugin manager out there that has Turbo mode which yields 50-73% faster Zsh startup! π₯
ZI gives reports from plugin load describing what aliases, functions, bindkeys, Zle widgets, zstyles, completions, variables, PATH and FPATH elements a plugin has set up.
Supported is unloading of plugin and ability to list, (un)install and selectively disable, enable plugin's completions.
The system does not use $FPATH, loading multiple plugins doesn't clutter $FPATH with the same number of entries (e.g. 10). Code is immune to KSH_ARRAYS. Completion management functionality is provided to allow user to call compinit only once in .zshrc. β¨
π¦ ZI WIKI π¦
The information in this README is complemented by the ZI wiki (http://z-shell.github.io/zi/wiki/). The README is an introductory overview of ZI while the wiki gives a complete and in-depth information with examples. Make sure to read it to get the most out of ZI. π
π Option 1 - Automatic Installation (Recommended) π
okay so the easiest way to install ZI β like, genuinely the one everyone does β is to run this bad boy:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/z-shell/zi/main/lib/install.sh)"
That slays it into ~/.zi/bin. Your .zshrc gets updated too, bestie β three lines of code get tacked onto the bottom. Those lines source zi.zsh and set up completion for the command zi. That's it, that's the whole vibe.
After installing and reloading the shell, compile ZI with zi self-update β¨
π¦ Option 2 - Manual Installation π¦
okay so you're a do it myself girlie, respect. To manually install ZI, clone the repo to e.g. ~/.zi/bin:
mkdir ~/.zi
git clone https://github.com/z-shell/zi.git ~/.zi/bin
and then source it from .zshrc β above compinit, bestie, this matters:
source ~/.zi/bin/zi.zsh
If you place the source below compinit instead (no judgment, but like⦠pay attention here), then add these two lines right after the source:
autoload -Uz _zi
(( ${+_comps} )) && _comps[zi]=_zi
Lowkey there are so many various paths you can customize β peep the section Customizing Paths (Customizing Paths) for that whole situation π
After installing and reloading the shell, compile ZI with zi self-update.
π USAGE π
β Introduction β
Click here to read the introduction to ZI β it's at http://z-shell.github.io/zi/wiki/INTRODUCTION/ π«Ά
It explains basic usage and some of the more unique features of ZI such as the Turbo mode. If you're new to ZI we highly recommend you read it at least once. Fr fr, read it. It's giving essential.
π Example Usage π
After installing ZI you can start adding some actions (load some plugins) to ~/.zshrc, at the bottom. Some examples:
# Two regular plugins loaded without tracking.
zi light zsh-users/zsh-autosuggestions
zi light z-shell/F-Sy-H
# Plugin history-search-multi-word loaded with tracking.
zi load z-shell/history-search-multi-word
# Load the pure theme, with zsh-async library that's bundled with it.
zi ice pick"async.zsh" src"pure.zsh"
zi light sindresorhus/pure
# Binary release in archive, from GitHub-releases page.
# After automatic unpacking it provides program "fzf".
zi ice from"gh-r" as"program"
zi load junegunn/fzf-bin
# One other binary release, it needs renaming from `docker-compose-Linux-x86_64`.
# This is done by ice-mod `mv'{from} -> {to}'. There are multiple packages per
# single version, for OS X, Linux and Windows β so ice-mod `bpick' is used to
# select Linux package β in this case this is actually not needed, ZI will
# grep operating system name and architecture automatically when there's no `bpick'.
zi ice from"gh-r" as"program" mv"docker* -> docker-compose" bpick"*linux*"
zi load docker/compose
# Vim repository on GitHub β a typical source code that needs compilation β ZI
# can manage it for you if you like, run `./configure` and other `make`, etc. stuff.
# Ice-mod `pick` selects a binary program to add to $PATH. You could also install the
# package under the path $ZPFX, see: http://z-shell.github.io/zi/wiki/Compiling-programs
zi ice as"program" atclone"rm -f src/auto/config.cache; ./configure" \
atpull"%atclone" make pick"src/vim"
zi light vim/vim
# Scripts that are built at install (there's single default make target, "install",
# and it constructs scripts by `cat'ing a few files). The make'' ice could also be:
# `make"install PREFIX=$ZPFX"`, if "install" wouldn't be the only, default target.
zi ice as"program" pick"$ZPFX/bin/git-*" make"PREFIX=$ZPFX"
zi light tj/git-extras
# Handle completions without loading any plugin, see "clist" command.
# This one is to be ran just once, in interactive session.
zi creinstall %HOME/my_completions
# For GNU ls (the binaries can be gls, gdircolors, e.g. on OS X when installing the
# coreutils package from Homebrew; you can also use https://github.com/ogham/exa)
zi ice atclone"dircolors -b LS_COLORS > c.zsh" atpull'%atclone' pick"c.zsh" nocompile'!'
zi light trapd00r/LS_COLORS
You can see an extended explanation of LS_COLORS in the wiki, at http://z-shell.github.io/zi/wiki/LS_COLORS-explanation/ πΈ
# make'!...' -> run make before atclone & atpull
zi ice as"program" make'!' atclone'./direnv hook zsh > zhook.zsh' atpull'%atclone' src"zhook.zsh"
zi light direnv/direnv
You can see an extended explanation of direnv in the wiki, at http://z-shell.github.io/zi/wiki/Direnv-explanation/ π
If you're interested in more examples then check out the zi-configs repository at https://github.com/z-shell/zi-configs, where users have uploaded their ~/.zshrc and ZI configurations. Feel free to submit yours at https://github.com/z-shell/zi-configs/issues/new?template=request-to-add-zshrc-to-the-zi-configs-repo.md β like, if your ~/.zshrc contains ZI commands, drop it there π
You can also check out the Gallery of ZI Invocations at http://z-shell.github.io/zi/wiki/GALLERY/ for some additional examples. It's giving inspiration, ngl.
π§ Ice Modifiers π§
Okay so the following ice modifiers are the ones you pass to zi ice ... to get the described effects. And like β why "ice"? The word ice means something that's added (like ice to a drink) πΉ β and in ZI it means adding a modifier to a next zi command, and also something that's temporary because it melts. So the modification lasts only for a single next zi command. Blink and it's gone, bestie π
Some Ice-modifiers are highlighted and clicking on them will take you to the appropriate wiki page for an extended explanation.
You may safely assume a given ice works with both plugins and snippets unless explicitly stated otherwise π«Ά
π Cloning Options
protoβ Change protocol togit,ftp,ftps,ssh,rsync, etc. Default ishttps. Does not work with snippets.fromβ Clone plugin from given site. Supported arefrom"github"(default),..."github-rel",..."gitlab",..."bitbucket",..."notabug"(short names:gh,gh-r,gl,bb,nb). Can also be a full domain name (e.g. for GitHub enterprise). Does not work with snippets.verβ Used withfrom"gh-r"(i.e. downloading a binary release, e.g. for use withas"program") β selects which version to download. Default islatest, can also be explicitlyver"latest". Works also with regular plugins, checkouts e.g.ver"abranch", i.e. a specific version. Does not work with snippets.bpickβ Used to select which release from GitHub Releases to download, e.g.zi ice from"gh-r" as"program" bpick"*Darwin*"; zi load docker/compose. Does not work with snippets.depthβ Pass--depthtogit, i.e. limit how much of history to download. Does not work with snippets.cloneoptsβ Pass the contents ofcloneoptstogit clone. Defaults to--recursivei.e. Change cloning options. Does not work with snippets.svnβ Use Subversion for downloading snippet. GitHub supports SVN protocol, this allows to clone subdirectories as snippets, e.g.zi ice svn; zi snippet OMZ::plugins/git. Other icepickcan be used to select file to source (default are:*.plugin.zsh,init.zsh,*.zsh-theme). Does not work with plugins.
π― Selection of Files (To Source, β¦)
pickβ Select the file to source, or the file to set as command (when usingsnippet --commandor the iceas"program"); it is a pattern, alphabetically first matched file is being chosen; e.g.zi ice pick"*.plugin.zsh"; zi load β¦. Wiki: http://z-shell.github.io/zi/wiki/Sourcing-multiple-files/srcβ Specify additional file to source after sourcing main file or after setting up command (viaas"program"). It is not a pattern but a plain file name. Wiki: http://z-shell.github.io/zi/wiki/Sourcing-multiple-filesmultisrcβ Allows to specify multiple files for sourcing, enumerated with spaces as the separators (e.g.multisrc'misc.zsh grep.zsh') and also using brace-expansion syntax (e.g.multisrc'{misc,grep}.zsh'). Supports patterns. Wiki: http://z-shell.github.io/zi/wiki/Sourcing-multiple-files
β³ Conditional Loading
waitβ Postpone loading a plugin or snippet. Forwait'1', loading is done 1 second after prompt. Forwait'[[ ... ]]',wait'(( ... ))', loading is done when given condition is meet. Forwait'!...', prompt is reset after load. Zsh can start 73% faster thanks to postponed loading π₯ Fact: whenwaitis used without value, it works aswait'0'. Wiki: http://z-shell.github.io/zi/wiki/Example-wait-conditionsloadβ 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, seeunloadbelow). E.g.:load'[[ $PWD = */github* ]]'. Wiki: http://z-shell.github.io/zi/wiki/Multiple-promptsunloadβ A condition to check causing plugin to unload. It will unload once, then only if loaded again. E.g.:unload'[[ $PWD != */github* ]]'. Wiki: http://z-shell.github.io/zi/wiki/Multiple-promptscloneonlyβ Don't load the plugin / snippet, only download it.ifβ Load plugin or snippet only when given condition is fulfilled, for example:zi ice if'[[ -n "$commands[otool]" ]]'; zi load β¦.hasβ Load plugin or snippet only when given command is available (in$PATH), e.g.zi ice has'git' β¦.subscribe/on-update-ofβ Postpone loading of a plugin or snippet until the given file(s) get updated, e.g.subscribe'{~/files-*,/tmp/files-*}'.
π Plugin Output
silentβ Mute plugin's or snippet's stderr & stdout. Also skipLoaded ...message under prompt forwait, etc. loaded plugins, and completion-installation messages. Total mute icon behavior π€lucidβ SkipLoaded ...message under prompt forwait, etc. loaded plugins (a subset ofsilent).notifyβ Output given message under-prompt after successfully loading a plugin/snippet. In case of problems with the loading, output a warning message and the return code. If starts with!it will then always output the given message. Hint: if the message is empty, then it will just notify about problems.
π§© Completions
blockfβ Disallow plugin to modifyfpath. Useful when a plugin wants to provide completions in traditional way. ZI can manage completions and plugin can be blocked from exposing them.nocompletionsβ Don't detect, install and manage completions for this plugin. Completions can be installed later withzi creinstall {plugin-spec}.
π Command Execution After Cloning, Updating or Loading
okay so these are the ice-mods that fire off around cloning, updating, and loading β every single one, no skips, no cap π
mvβ move file after cloning or after update (then, only if new commits were downloaded). Example:mv "fzf-* -> fzf". It uses->as separator for old and new file names. Works also with snippets. π«Άcpβ copy file after cloning or after update (then, only if new commits were downloaded). Example:cp "docker-c* -> dcompose". Ran aftermv. β¨atcloneβ¨http://z-shell.github.io/zi/wiki/atload-and-other-at-icesβ© β run command after cloning, within plugin's directory, e.g.zi ice atclone"echo Cloned". Ran also after downloading snippet. π¦atpullβ¨http://z-shell.github.io/zi/wiki/atload-and-other-at-icesβ© β run command after updating (only if new commits are waiting for download), within plugin's directory. If starts with!then command will be ran beforemv&cpices and beforegit pullorsvn update. Otherwise it is ran after them. Can beatpull'%atclone', to repeatatcloneIce-mod. πΈatinitβ¨http://z-shell.github.io/zi/wiki/atload-and-other-at-icesβ© β run command after directory setup (cloning, checking it, etc.) of plugin/snippet but before loading. πatloadβ¨http://z-shell.github.io/zi/wiki/atload-and-other-at-icesβ© β run command after loading, within plugin's directory. Can be also used with snippets. Passed code can be preceded with!, it will then be tracked (if usingload, notlight). πrun-atpullβ always run theatpullhook (when updating), not only when there are new commits to be downloaded. π₯nocdβ don't switch the current directory into the plugin's directory when evaluating the above ice-modsatinit'',atload'', etc. πmakeβ¨http://z-shell.github.io/zi/wiki/Installing-with-makeβ© β runmakecommand after cloning/updating and executingmv,cp,atpull,atcloneIce mods. Can obtain argument, e.g.make"install PREFIX=/opt". If the value starts with!thenmakeis ran beforeatclone/atpull, e.g.make'!'. π
π¦ Sticky-Emulation Of Other Shells
sh,!shβ source the plugin's (or snippet's) script withshemulation so that also all functions declared within the file will get a sticky emulation assigned β when invoked they'll execute also with theshemulation set-up. The!shversion switches additional options that are rather not important from the portability perspective. πbash,!bashβ the same assh, but with theSH_GLOBoption disabled, so that Bash regular expressions work. βksh,!kshβ the same assh, but emulatingkshshell. πcsh,!cshβ the same assh, but emulatingcshshell. π
πΈ Others
asβ can beas"program"(also the alias:as"command"), and will cause to add script/program to$PATHinstead of sourcing (seepick). Can also beas"completion"β use with plugins or snippets in whose only underscore-starting_*files you are interested in. β¨id-asβ¨http://z-shell.github.io/zi/wiki/id-as/β© β nickname a plugin or snippet, to e.g. create a short handler for long-url snippet. πcompileβ pattern (+ possible{...}expansion, like{a/*,b*}) to select additional files to compile, e.g.compile"(pure\|async).zsh"for sindresorhus/pure. π₯nocompileβ don't try to compilepick-pointed files. If passed the exclamation mark (i.e.nocompile'!'), then do compile, but aftermake''andatclone''(useful ifMakefileinstalls some scripts, to pointpick''at the location of their installation). πserviceβ make following plugin or snippet a service, which will be ran in background, and only in single Zshell instance. Seezservices-organizationβ¨https://github.com/zservicesβ© page. πreset-promptβ reset the prompt after loading the plugin/snippet (by issuingzle .reset-prompt). Note: normally it's sufficient to precede the value ofwait''ice with!. πbindmapβ to hold;-separated strings likeKey(s)A -> Key(s)B, e.g.^R -> ^T; ^A -> ^B. In general,bindmap''changes bindings (done with thebindkeybuiltin) the plugin does. The example would cause the plugin to map Ctrl-T instead of Ctrl-R, and Ctrl-B instead of Ctrl-A. Does not work with snippets. πΉtrackbindsβ shadow but onlybindkeycalls even withzi light ..., i.e. even with tracking disabled (fast loading), to allowbindmapto remap the key-binds. The same effect haszi light -b ..., i.e. additional-boption to the light-subcommand. Does not work with snippets. πwrap-trackβ¨http://z-shell.github.io/zi/wiki/wrap-trackβ© β takes a;-separated list of function names that are to be tracked (meaning gathering report and unload data) once during execution. It works by wrapping the functions with a tracking-enabling and disabling snippet of code. In summary,wrap-trackallows to extend the tracking beyond the moment of loading of a plugin. Example use is to wrap-track aprecmdfunction of a prompt (like_p9k_precmd()ofpowerlevel10k) or other plugin that postpones its initialization till the first prompt (like e.g.:zsh-autosuggestions). Does not work with snippets. π§aliasesβ load the plugin with the aliases mechanism enabled. Use with plugins that define and use aliases in their scripts. πͺ
β Order of Execution
order of execution of related Ice-mods, bestie β this is the exact chain:
atinit -> atpull! -> make'!!' -> mv -> cp -> make! -> atclone/atpull -> make -> (plugin script loading) -> src -> multisrc -> atload.
π ZI Commands
following commands are passed to zi ... to obtain described effects. π«‘
π Help
-h,--help,helpβ usage information.manβ manual. π
π§Έ Loading and Unloading
load {plg-spec}β load plugin, can also receive absolute local path. πlight [-b] {plg-spec}β light plugin load, without reporting/tracking.-bβ track bindkey-calls only. πͺΆunload [-q] {plg-spec}β unload plugin loaded withzi load ....-qβ quiet. π«§snippet [-f] {url}β source local or remote file (by direct URL).-fβ don't use cache (force redownload). π
π Completions
clist columns, completions columnsβ list completions in use, withcolumnscompletions per line.zi clist 5will for example print 5 completions per line. Default is 3. πcdisable {cname}β disable completioncname. π ββοΈcenable {cname}β enable completioncname. βcreinstall [-q] {plg-spec}β install completions for plugin, can also receive absolute local path.-qβ quiet. π¦cuninstall {plg-spec}β uninstall completions for plugin. ποΈcsearchβ search for available completions from any plugin. πcompinitβ refresh installed completions. πcclearβ clear stray and improper completions. π§Ήcdlistβ showcompdefreplay list. πcdreplay [-q]β replay compdefs (to be done aftercompinit).-qβ quiet. πcdclear [-q]β clear compdef replay list.-qβ quiet. π§Ό
π¦ Tracking of the Active Session
dtrace,dstartβ start tracking what's going on in session. π¬dstopβ stop tracking what's going on in session. βΉοΈdunloadβ revert changes recorded betweendstartanddstop. βͺdreportβ report what was going on in session. πdclearβ clear report of what was going on in session. π§½
πΈ Reports and Statistics
times [-s]β statistics on plugin load times, sorted in order of loading.-sβ use seconds instead of milliseconds. β±οΈzstatusβ overall ZI status. π©Ίreport {plg-spec}\|--allβ show plugin report.--allβ do it for all plugins. πloaded [keyword],list [keyword]β show what plugins are loaded (filter with'keyword'). π¦lsβ list snippets in formatted and colorized manner. Requirestreeprogram. π³status {plg-spec}\|URL\|--allβgitstatus for plugin orsvnstatus for snippet.--allβ do it for all plugins and snippets. π§recently [time-spec]β show plugins that changed recently, argument is e.g.1 month 2 days. π°οΈbindkeysβ lists bindkeys set up by each plugin. β¨οΈ
π Compiling
compile {plg-spec}\|--allβ compile plugin.--allβ compile all plugins. π¨uncompile {plg-spec}\|--allβ remove compiled version of plugin.--allβ do it for all plugins. π§¨compiledβ list plugins that are compiled. π
πΈ Other πΈ
okay so this is the grab-bag of the remaining zi subcommands β the little side quests, iykyk π
self-updateβ updates and compiles ZI. two birds, one slay β¨update [-q] [-r] {plg-spec}|URL|--allβ git-updates a plugin or snippet.--allmeans update all plugins and snippets.-qis quiet mode.-r|--resetrunsgit reset --hard/svn revertbefore pulling changes πice <ice specification>β adds an ice to the next command; the argument is e.g. from"gitlab"delete {plg-spec}|URL|--clean|--allβ removes a plugin or snippet from disk (lowkey great for forgetting wrongly passed ice-mods π).--allβ purge.--cleanβ delete plugins and snippets that are not loaded.cd {plg-spec}β cds you into the plugin's directory. also supports snippets if you feed it a URL π«Άedit {plg-spec}β opens the plugin's file in$EDITORglance {plg-spec}β lets you look at the plugin's source (pygmentize,{,source-}highlight)stress {plg-spec}β tests the plugin for compatibility with a set of options πchanges {plg-spec}β views the plugin's git logcreate {plg-spec}β creates a plugin (also together with a GitHub repository π)srv {service-id} [cmd]β controls a service; the command can be:stop,start,restart,next,quit;nextmoves the service to another Zshellrecall {plg-spec}|URLβ fetches the saved ice modifiers and constructs thezi ice ...command for you β¨env-whitelist [-v] [-h] {env..}β lets you specify names (also patterns) of variables that stay unchanged during an unload.-vβ verbose.moduleβ manages the binary Zsh module shipped with ZI, seezi module help
π Updating ZI and Plugins π
To update ZI, just drop zi self-update in the command line. periodt.
To update all plugins and snippets, issue zi update. If you only wanna update a single plugin/snippet instead, issue zi update NAME_OF_PLUGIN. A list of commits will be shown:
Some plugins require performing an action each time they're updated β and one way you can do that is with the atpull ice modifier π§ for example, writing zi ice atpull'./configure' before loading a plugin will execute ./configure after a successful update. Refer to Ice Modifiers (Ice Modifiers) for more info.
The ice modifiers for any plugin or snippet are stored in their directory in a ._zi subdirectory, hence the plugin doesn't have to be loaded to be correctly updated π there's one other file created there too: .zi_lstupd β it holds the log of the new commits pulled-in in the last update.
π¦ Using Oh My Zsh Themes π¦
To use themes created for Oh My Zsh you might want to first source the git library there:
zi snippet http://github.com/ohmyzsh/ohmyzsh/raw/master/lib/git.zsh
# Or using OMZ:: shorthand:
zi snippet OMZ::lib/git.zsh
If the library will not be loaded, then similar to following errors will be appearing:
Then you can use the themes as snippets (zi snippet {file path or GitHub URL}). Some themes require not only Oh My Zsh's Git library, but also the Git plugin (error about current_branch function can be appearing). Load this Git-plugin as a single-file snippet directly from OMZ:
zi snippet OMZ::plugins/git/git.plugin.zsh
Such lines should be added to .zshrc. Snippets are cached locally, so use the -f option to download a fresh version of a snippet, or zi update {URL}. You can also use zi update --all to update all snippets (and plugins).
Most themes require the promptsubst option (setopt promptsubst in zshrc) β if it isn't set, then the prompt will appear as something like: ... $(build_prompt) ....
You might want to suppress completions provided by the git plugin by issuing zi cdclear -q (-q is for quiet) β see below Ignoring Compdefs π
To summarize:
# Load OMZ Git library
zi snippet OMZ::lib/git.zsh
# Load Git plugin from OMZ
zi snippet OMZ::plugins/git/git.plugin.zsh
zi cdclear -q # <- forget completions provided up to this moment
setopt promptsubst
# Load theme from OMZ
zi snippet OMZ::themes/dstufft.zsh-theme
# Load normal GitHub plugin with theme depending on OMZ Git library
zi light NicoSantangelo/Alpharized
See also the Wiki page: Example Oh My Zsh Setup http://z-shell.github.io/zi/wiki/Example-Oh-My-Zsh-setup/ π
β¨ COMPLETIONS β¨
π Calling compinit Without Turbo Mode π
With no Turbo mode in use, compinit can be called normally, i.e.: as autoload compinit; compinit. This should be done after loading of all plugins and before possibly calling zi cdreplay. Also, plugins aren't allowed to simply run compdefs π«Ά you can decide whether to run compdefs by issuing zi cdreplay (reads: compdef-replay). To summarize:
source ~/.zi/bin/zi.zsh
zi load "some/plugin"
compdef _gnu_generic fd # this will be intercepted by ZI, because as the compinit
# isn't yet loaded, thus there's no such function `compdef'; yet
# ZI provides its own `compdef' function which saves the
# completion-definition for later possible re-run with `zi
# cdreplay` or `zpcdreplay` (the second one can be used in hooks
# like atload'', atinit'', etc.)
zi load "other/plugin"
autoload -Uz compinit
compinit
zi cdreplay -q # -q is for quiet; actually run all the `compdef's saved before
#`compinit` call (`compinit' declares the `compdef' function, so
# it cannot be used until `compinit` is ran; ZI solves this
# via intercepting the `compdef'-calls and storing them for later
# use with `zi cdreplay')
This allows to call compinit once. Performance gains are huge, example shell startup time with double compinit: 0.980 sec, with cdreplay and single compinit: 0.156 sec π₯ likeβ¦ that's not a glow-up, that's a whole transformation.
π Calling compinit With Turbo Mode π
If you load completions using wait'' Turbo mode then you can add atinit'zpcompinit' to the syntax-highlighting plugin (which should be the last one loaded, as their (2 projects, z-sy-h https://github.com/zsh-users/zsh-syntax-highlighting & f-sy-h https://github.com/z-shell/fast-syntax-highlighting) documentation state), or atload'zpcompinit' to the last completion-related plugin. zpcompinit is a function that just runs autoload compinit; compinit, created for convenience β¨ there's also zpcdreplay which will replay any caught compdefs so you can also do: atinit'zpcompinit; zpcdreplay', etc. Basically, the whole topic is the same as a normal compinit call, but it is done in atinit or atload hook of the last related plugin with use of the helper functions (zpcompinit, zpcdreplay & zpcdclear β see below for explanation of the last one).
π Ignoring Compdefs π
If you want to ignore compdefs provided by some plugins or snippets, place their load commands before commands loading other plugins or snippets, and issue zi cdclear (or zpcdclear, designed to be used in hooks like atload''):
source ~/.zi/bin/zi.zsh
zi snippet OMZ::plugins/git/git.plugin.zsh
zi cdclear -q # <- forget completions provided by Git plugin
zi load "some/plugin"
zi load "other/plugin"
autoload -Uz compinit
compinit
zi cdreplay -q # <- execute compdefs provided by rest of plugins
zi cdlist # look at gathered compdefs
π Disabling System-Wide compinit Call (Ubuntu) π
On Ubuntu, users might get surprised that e.g. their completions work while they didn't call compinit in their .zshrc. That's because the function is being called in /etc/zshrc π to disable this call β what is needed to avoid the slowdown and if user loads any completion-equipped plugins, i.e. almost on 100% β add the following lines to ~/.zshenv:
# Skip the not really helping Ubuntu global compinit
skip_global_compinit=1
π ZI MODULE π
β Motivation β
The module is a binary Zsh module (think about zmodload Zsh command, it's that topic) which transparently and automatically compiles sourced scripts. Many plugin managers do not offer compilation of plugins, and the module is a solution to this π«Ά even if a plugin manager does compile the plugin's main script (like ZI does), the script can source smaller helper scripts or dependency libraries (for example, the prompt geometry-zsh/geometry does that) and there are very few solutions to that, which are demanding (e.g. specifying all helper files in the plugin load command and tracking updates to the plugin β in ZI case: by using the compile ice-mod).
image https://raw.githubusercontent.com/z-shell/zi/images/mod-auto-compile.png
πΈ Installation πΈ
π Without ZI π
To install just the binary ZI module standalone (ZI is not needed, the module can be used with any other plugin manager), execute:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/z-shell/zi/main/lib/mod-install.sh)"
This script will display what to add to ~/.zshrc (2 lines) and show usage instructions.
π¦ With ZI π¦
ZI users can build the module by issuing the following command instead of running the above mod-install.sh script (the script is for e.g. zgen users or users of any other plugin manager):
zi module build
This command will compile the module and display instructions on what to add to ~/.zshrc β¨
π Measuring Time of sources π
Besides the compilation-feature, the module also measures the duration of each script sourcing. Issue zpmod source-study after loading the module at the top of ~/.zshrc to see a list of all sourced files with the time the sourcing took in milliseconds on the left β±οΈ this feature allows you to profile the shell startup. Also, no script can pass-through that check and you will obtain a complete list of all loaded scripts, like if Zshell itself was tracking this. The list can be surprising π
π§ Debugging π§
To enable debug messages from the module set:
typeset -g ZPLG_MOD_DEBUG=1
β¨ HINTS AND TIPS β¨
Okay so this is the glow-up guide part: custom paths, local plugins, git extensions, and preinstall magic. Letβs get into it, bestie π
π Customizing Paths π
You can set the following variables to custom values before sourcing ZI. The previous global variables like $ZPLG_HOME have been removed so they donβt pollute the namespace β thereβs single $ZPLGM (aka "ZI MAP") hash instead of 8 string variables. Please update your dotfiles. π«Ά
declare -A ZPLGM # initial ZI's hash definition, if configuring before loading ZI, and then:
Here are the hash fields, no cap:
ZPLGMBIN_DIRβ where ZI code resides, e.g."~/.zi/bin"ZPLGMHOME_DIRβ where ZI should create all working directories, e.g."~/.zi"ZPLGMPLUGINS_DIRβ override single working directory for plugins, e.g."/opt/zsh/zi/plugins"ZPLGMCOMPLETIONS_DIRβ same override energy as above, but for completion files, e.g."/opt/zsh/zi/root_completions"ZPLGMSNIPPETS_DIRβ as above, but for snippetsZPLGMZCOMPDUMP_PATHβ path to the.zcompdumpfile, with the file included (i.e. its name can be different)ZPLGMCOMPINIT_OPTSβ options for thecompinitcall (i.e. done byzpcompinit), use it to pass-Cto speed up loadingZPLGMMUTE_WARNINGSβ if set to1, then it mutes some of the ZI warnings, specifically the plugin already registered warning
Thereβs also $ZPFX, set by default to ~/.zi/polaris β a directory where software with Makefile, etc. can be pointed to, by e.g. atclone'./configure --prefix=$ZPFX'. π οΈ
πΈ Non-GitHub (Local) Plugins πΈ
Use the create subcommand with user name _local (the default) to create the pluginβs skeleton in $ZPLGM[PLUGINS_DIR]. It lowkey wonβt be connected to a GitHub repository (because the user name is _local). To enter the pluginβs directory, use the cd command with just the pluginβs name (without _local, itβs optional). π
If the user name is not _local, then ZI will create the repository also on GitHub and set up the correct repository origin. β¨
π¦ Extending Git π¦
There are several projects that provide git extensions. Installing them with ZI has many benefits:
- all files are under
$HOMEβ no administrator rights needed - declarative setup (like Chef or Puppet) β copying
.zshrcto a different account brings the git-related setup too - easy update by e.g.
zi update --all
Below is a configuration that adds multiple git extensions, loaded in Turbo mode, two seconds after the prompt:
zi ice wait"2" lucid as"program" pick"bin/git-dsf"
zi light z-shell/zsh-diff-so-fancy
zi ice wait"2" lucid as"program" pick"$ZPFX/bin/git-now" make"prefix=$ZPFX install"
zi light iwata/git-now
zi ice wait"2" lucid as"program" pick"$ZPFX/bin/git-alias" make"PREFIX=$ZPFX" nocompile
zi light tj/git-extras
zi ice wait"2" lucid as"program" atclone'perl Makefile.PL PREFIX=$ZPFX' atpull'%atclone' \
make'install' pick"$ZPFX/bin/git-cal"
zi light k4rthik/git-cal
Target directory for installed files is $ZPFX (~/.zi/polaris by default). π
π§ Preinstalling Plugins π§
If you create a Docker image that uses ZI, or want to install Turbo-loaded plugins before the shell starts interactively, you can invoke the zi-scheduler function in such a way that it:
- installs plugins without waiting for the prompt (i.e. itβs script friendly)
- installs all plugins instantly, without respecting the
wait''argument
To accomplish this, use the burst argument and call the -zi-scheduler function. Example Dockerfile entry:
RUN zsh -i -c -- '-zi-scheduler burst || true'
An example Dockerfile can be found here: https://github.com/robobenklein/configs/blob/master/Dockerfile π³
π GETTING HELP AND COMMUNITY π
Whant to learn more? π
- See Z-Shell News Blog:
https://z-shell.github.io
Thatβs the whole page, bestie π β footer check: the date is November 2021, and the source/version slot is literally () (mysterious, but iconic). π
π¦ where this page comes from
- nixpkgs unstable: zi 1.0.0-unstable-2022-04-09
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms