Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork10
zcomet - Fast, Simple Zsh Plugin Manager
License
agkozak/zcomet
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
zcomet is a Zsh plugin manager that gets you to the prompt quickly. Its goal is to be simple and convenient without slowing you down. It succeeds in keeping latencies down to the level you would expect if you were not even using a plugin manager:
Many thanks to Roman Perepelitsa for sharing hiszsh-bench benchmarking utility (see"Notes on Benchmarks").
The speed difference can be undetectable, but the improved convenience is noteworthy. Azcomet configuration can be as simple as:
source /path/to/zcomet.zshzcomet load author1/plugin1zcomet load author2/plugin2zcomet load author3/plugin3zcomet compinitThose lines will clone repositories, source scripts, update yourFPATH andPATH, and load the Zsh completion system.
- News
- Sample
.zshrc - Commands and Arguments
- Options
- Directory Customization
- Dynamic Named Directories
- FAQ
- Standards Compliance
- Notes on Benchmarks
- TODO
- December 7, 2024
zcomet loadnow first chooses a branch and then initializes and updates submodules.
- August 24, 2023
zcomet compileno longer expands aliases when compiling scripts.
Older news
- November 17, 2021
zcomet updateno longer re-sources loaded plugins and snippets, as doing so can have undesired consequences. Instead, it reminds the user toexec zshto refresh the system.
- November 16, 2021
- You can now refer to a GitHub repository by the full URL, if you prefer, e.g.
https://github.com/zsh-users/zsh-syntax-highlighting.gitinstead ofzsh-users/zsh-syntax-highlighting. Support for Git servers other than GitHub is coming soon. zcomet listnow displays triggers in a more abbreviated fashion.
- You can now refer to a GitHub repository by the full URL, if you prefer, e.g.
- October 21, 2021
zcometnow supports local plugins and snippets.
- October 13, 2021
- October 4, 2021
zcometnow fetches Git submodules by default. If you do not need them, be sure to save yourself time by using the--no-submodulesoption withload,fpath, ortrigger.
- September 30, 2021
zcometnow defers runningcompdefcalls until afterzcomet compinithas been run.
- September 28, 2021
zcometnow autoloads functions in afunctions/directory before sourcing a Prezto-style module.
- September 27, 2021
zcometnow looks for thebin/subdirectory in the root directory of the repository, not in the directory where the sources plugin files reside.
- September 21, 2021
- I have opted to have named directories assigned only at the repository level. Also, if there is more than one repository with the same name (e.g.,
author1/zsh-toolandauthor2/zsh-tool), neither directory is given a name (to prevent mistakes from happening).
- I have opted to have named directories assigned only at the repository level. Also, if there is more than one repository with the same name (e.g.,
- September 20, 2021
zcometplugins are now assigneddynamic named directories. This feature was inspired by Marlon Richert'sZnap.
- September 18, 2021
zcometdirectories are now specified usingzstyle;see below.- The
loadcommand will now add a plugin'sbin/subdirectory, if it has one, to thePATH.
- September 17, 2021
zcommet triggernow always makes sure that the repository it needs has already been cloned, meaning that you will never have to wait for files to be downloaded when you use a defined trigger.
- September 16, 2021
zcomet listnow reflectsFPATHelements added using thefpathcommand.- New command:
zcomet compinitrunscompinitand compiles its cache for you.
- September 15, 2021
zcometwill store your plugins and snippets in${ZDOTDIR}, if you have set that variable and if${HOME}/.zcometdoes not already exist. Props to @mattjamesdev.
- September 13, 2021
- The
snippetcommand now supports any URL that points to raw Zsh code (not HTML) via HTTP or HTTPS. It will translategithub.comaddresses into theirraw.githubusercontent.comequivalents. You may still use theOMZ::shorthand for Oh-My-Zsh code.
- The
# Clone zcomet if necessaryif [[!-f${ZDOTDIR:-${HOME}}/.zcomet/bin/zcomet.zsh ]];thencommand git clone https://github.com/agkozak/zcomet.git${ZDOTDIR:-${HOME}}/.zcomet/binfisource${ZDOTDIR:-${HOME}}/.zcomet/bin/zcomet.zsh# Load a promptzcomet load agkozak/agkozak-zsh-prompt# Load some pluginszcomet load agkozak/zsh-zzcomet load ohmyzsh plugins/gitfast# Load a code snippet - no need to download an entire repositoryzcomet snippet https://github.com/jreese/zsh-titles/blob/master/titles.plugin.zsh# Lazy-load some pluginszcomet trigger zhooks agkozak/zhookszcomet trigger zsh-prompt-benchmark romkatv/zsh-prompt-benchmark# Lazy-load Prezto's archive module without downloading all of Prezto's# submoduleszcomet trigger --no-submodules archive unarchive lsarchive \ sorin-ionescu/prezto modules/archive# It is good to load these popular plugins last, and in this order:zcomet load zsh-users/zsh-syntax-highlightingzcomet load zsh-users/zsh-autosuggestions# Run compinit and compile its cachezcomet compinit
load is the most commonly used command; it clones a GitHub repository (if it has not already been downloaded), adds its root directory (orfunctions/ subdirectory, if it exists) toFPATH, adds anybin/ subdirectory toPATH, and sources a file or files. The simplest example is:
zcomet load agkozak/zsh-zThe common repositoriesohmyzsh/ohmyzsh andsorin-ionescu/prezto can be abbreviated asohmyzsh andprezto, respectively.zcomet uses simple principles to choose which init file to source (in this case,/path/to/agkozak/zsh-z/zsh-z.plugin.zsh is the obvious choice).
A subdirectory of a repository can be specified:
zcomet load ohmyzsh plugins/gitfastloads Oh-My-Zsh's usefulgitfast plugin. If a specific file or files in a subdirectory should be sourced, they can be specified:
zcomet load ohmyzsh lib git.zshzcomet load sindresorhus/pure async.zsh pure.zshIf there are autoloadable functions in a Prezto-stylefunctions/ directory, they will be automatically autoloaded.
A specific branch, tag, or commit of a repository can be checked out using the following syntax:
zcomet load author/repo@branch(@tag and@commit are equally valid.)
load is the command used for loading prompts.
load also supports local plugins that do not need to be cloned. Just make sure that the plugin name starts with a slash or something that will expand to a slash, e.g.
zcomet load /path/to/plugin1zcomet load ~/path/to/plugin2zcomet load ${HOME}/path/to/plugin3Relative directories cannot be used.
NOTE: If the repository thatload is cloning has submodules, consider whether or not you really need them. Using the--no-submodules option afterload can save a lot of time during installation and updating.
fpath will clone a repository and add one of its directories toFPATH. Unlikeload, it does not source any files. Also, you must be very specific about which subdirectory is to be added toFPATH;zcomet fpath does not try to guess. If you wanted to use the agkozak-zsh-prompt withpromptinit, you could run
zcomet fpath agkozak/agkozak-zsh-promptautoload promptinit; promptinitprompt agkozak-zsh-prompt(But if you are not intending to switch prompts, it is much easier just to usezcomet load agkozak/agkozak-zsh-prompt.)
NOTE: If the repository thatfpath is cloning has submodules, consider whether or not you really need them. Using the--no-submodules option afterfpath can save a lot of time during installation and updating.
trigger lazy-loads plugins, saving time when you start the shell. If you specify a command name, a Git repository, and other optional arguments (the same arguments that get used forload), the plugin will be loaded and the command run only when the command is first used:
zcomet trigger zhooks agkozak/zhooksfor example, creates a function calledzhooks that loads thezhooks plugin and runs the commandzhooks. It takes next to no time to create the initial function, so this is perfect for commands that you do not instantly and constantly use. If there is more than one command that should trigger the loading of the plugin, you can specify each separately:
zcomet trigger extract ohmyzsh plugins/extractzcomet trigger x ohmyzsh plugins/extractor save time by listing a number of triggers before the repository name:
zcomet trigger extract x ohmyzsh plugins/extracttrigger always checks to make sure that the repository it needs has been already cloned; if not, it clones it. The goal is for triggers to take almost no time to load when they are actually run.
NOTE: If the repository thattrigger is cloning has submodules, consider whether or not you really need them. Using the--no-submodules option aftertrigger can save a lot of time during installation and updating.
This feature was inspired byZinit'strigger-load command.
snippet downloads a script (when necessary) and sources it:
zcomet snippet OMZ::plugins/git/git.plugins.zshThis example will download Oh-My-Zsh'sgit aliases without cloning the whole Oh-My-Zsh repository -- a great time-saver.
zcomet will translategithub.com URLs into their raw coderaw.githubusercontent.com equivalents. For example,
zcomet snippet https://github.com/jreese/zsh-titles/blob/master/titles.plugin.zshreally executes
zcomet snippet https://raw.githubusercontent.com/jreese/zsh-titles/master/titles.plugin.zshFor snippets that are not hosted by GitHub, you will want to make sure that the URL you use points towards raw code, not a pretty HTML display of it.
zcomet will also allow you to load local snippets that do not need to be downloaded, e.g.
zcomet snippet /path/to/my/code.zsh
zcomet update downloads updates for any plugins or snippets that have been downloaded in the past.
zcomet list displays any active plugins, addedFPATH elements, snippets, and triggers. As you use the triggers, you will see them disappear as triggers and reappear as loaded plugins.
Runs Zsh'scompinit command, which is necessary if you want to use command line completions.compinit's cache is then stored in a file in the$HOME directory (or in$ZDOTDIR, if you have defined it) starting with.zcompdump_, followed by the effective user ID (EUID), the operating system type (OSTYPE), and ending with the version number of thezsh you are using, e.g.,.zcompdump_1000_linux-gnu_5.8.zcomet compiles the cache for you.
Like other plugin managers and frameworks,zcomet defers runningcompdef calls untilzcomet compinit runs, which means that you can load a plugin full ofcompdefs (e.g.,zcomet load ohmyzsh plugins/git) even beforezcomet compinit and its completions will still work.
A simplezcomet compinit should always get the job done, but if you need to rename the cache file ("dump file"), you can do so thus:
zstyle ':zcomet:compinit' dump-file /path/to/dump_fileIf you need to specify other options tocompinit, you can do it this way:
zstyle ':zcomet:compinit' arguments -i # I.e., run `compinit -i'But it is safest to stick to the default behavior. An incorrectly configuredcompinit can lead to your completions being broken or unsafe code being loaded.
Compiles a script or scripts if there is no corresponding wordcode (.zwc) file or if a script is newer than its.zwc. Note thatzcomet always compiles scripts after cloning repositories or runningupdate, so you should generally never need to invokezcomet compile yourself.
Displays a help screen.
Updateszcomet itself. Note thatzcomet must have been installed as a cloned Git repository for this to work.
Unloads a plugin that has anunload function. The implementation is still very basic.
By default, if a repository has submodules,zcomet will fetch them whenever theload,fpath,trigger, orupdate commands are issued. For example, I usePrezto'sarchive module, but I do not need all of the external prompts in theprompt module, so I usezcomet's--no-submodules option:
zcomet load --no-submodules sorin-ionescu/prezto modules/archiveNot fetching the submodules saves a good deal of time when cloning the repository.
zcomet will store plugins, snippets, and the like in~/.zcomet by default. If you have set$ZDOTDIR, thenzcomet will use${ZDOTDIR}/.zcomet instead. You can also specify a custom home directory forzcomet thus:
zstyle ':zcomet:*' home-dir ~/path/to/home_dirMake sure to do that before you start loading code.
In the home directory there will usually be a/repos subdirectory for plugins and a/snippets subdirectory for snippets, but you may name your own locations:
zstyle ':zcomet:*' repos-dir ~/path/to/repos_dirzstyle ':zcomet:*' snippets-dir ~/path/to/snippets_dirI recommend cloning theagkozak/zcomet repository to a/bin subdirectory in yourzcomet home directory (e.g.,~/.zcomet/bin), as in theexample.zshrc above.
If youload,fpath, ortrigger a number of plugins,zcomet will give them dynamic directory names. For theexample.zshrc above, the following named directories would be created:
~[agkozak-zsh-prompt]~[ohmyzsh]~[zhooks]~[zsh-prompt-benchmark]~[zsh-z]You will also have~[zcomet-bin], the directory in which thezcomet.zsh script resides.
Try typingcd ~[ and press<TAB> to see a list of dynamic directories. This new feature should be particularly useful to people who write plugins and prompts -- it makes it very easy to get to the code.
This feature is based on Marlon Richert'sZnap.
fzf is not structured like a normal Zsh plugin, but you can install it like this:
zcomet load junegunn/fzf shell completion.zsh key-bindings.zsh(( ${+commands[fzf]} )) || ~[fzf]/install --binThe first line makes sure thefzf repository gets cloned, itsbin/ subdirectory is added toPATH, and the relevant scripts get sourced. The second line checks to make sure that thefzf binary is actually available and installs it if it is not (note thatfzf does not work on all systems and that its install script relies onbash's being installed).
I am a great admirer ofSebastian Gniazdowski's principles for plugin development, and I have incorporated most of his suggestions intozcomet:
- Standardized
$0handling - Support for
functions/directories - Support for
bin/directories - Support for
unloadfunctions zsh_loaded_plugins: a plugin manager activity indicatorZPFX: global parameter with PREFIX formake,configure, etc.PMSPEC: global parameter holding the plugin manager’s capabilities
When I started this project, I was happy to discover thatzcomet scored rather well on benchmarks that measurezsh -lic "exit". Roman Perepelitsahas argued eloquently, however, that such benchmarks are misleading, and that we should instead pay attention to comparative latencies that affect user experience. The graph above compares the performance ofa well constructed.zshrc with no plugin manager to that of a comparable configuration usingzcomet.
- Supply prettier output
- Provide more helpful error messages
- Allow users to update just one repository or snippet
- Improve the
unloadcommand - Allow the loading of repositories not on GitHub
- Support for
ssh://andgit://
Copyright (C) 2021-2024 Alexandros Kozak
About
zcomet - Fast, Simple Zsh Plugin Manager
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.

