Giter VIP home page Giter VIP logo

zgenom's Introduction

zgenom

A lightweight yet powerful plugin manager for Zsh.

It is a superset of the brilliant zgen. Providing more features and bugfixes while being fully backwards compatible. Have a look at the migration guide if you're currently using zgen. Also have a look at new features of zgenom.

Zgenom provides you simple commands for managing plugins. It installs your plugins and generates a static init script that will source them for you every time you run the shell. We do this to save some startup time by not having to execute time consuming logic (plugin checking, updates, etc) every time a new shell session is started. This means that you have to manually check for updates (zgenom update) and reset the init script (zgenom reset) whenever you add or remove plugins.

Zgenom does have a zgenom autoupdate which checks for updates periodically without startup penalty or having to wait for the plugins to update. See here for more information.

Installation

...

Clone the zgenom repository:

git clone https://github.com/jandamm/zgenom.git "${HOME}/.zgenom"

Edit your .zshrc file to load zgenom:

# load zgenom
source "${HOME}/.zgenom/zgenom.zsh"

Place the following code after the one above to load ohmyzsh for example, see Example and Usage for more details.

# if the init script doesn't exist
if ! zgenom saved; then

  # specify plugins here
  zgenom ohmyzsh

  # generate the init script from plugins above
  zgenom save
fi

If you're currently using zgen see below.

Example .zshrc

# load zgenom
source "${HOME}/.zgenom/zgenom.zsh"

# Check for plugin and zgenom updates every 7 days
# This does not increase the startup time.
zgenom autoupdate

# if the init script doesn't exist
if ! zgenom saved; then
    echo "Creating a zgenom save"

    # Add this if you experience issues with missing completions or errors mentioning compdef.
    # zgenom compdef

    # Ohmyzsh base library
    zgenom ohmyzsh

    # You can also cherry pick just parts of the base library.
    # Not loading the base set of ohmyzsh libraries might lead to issues.
    # While you can do it, I won't recommend it unless you know how to fix
    # those issues yourself.

    # Remove `zgenom ohmyzsh` and load parts of ohmyzsh like this:
    # `zgenom ohmyzsh path/to/file.zsh`
    # zgenom ohmyzsh lib/git.zsh # load git library of ohmyzsh

    # plugins
    zgenom ohmyzsh plugins/git
    zgenom ohmyzsh plugins/sudo
    # just load the completions
    zgenom ohmyzsh --completion plugins/docker-compose

    # Install ohmyzsh osx plugin if on macOS
    [[ "$(uname -s)" = Darwin ]] && zgenom ohmyzsh plugins/macos

    # prezto options
    zgenom prezto editor key-bindings 'emacs'
    zgenom prezto prompt theme 'sorin'

    # prezto and modules
    # If you use prezto and ohmyzsh - load ohmyzsh first.
    zgenom prezto
    zgenom prezto command-not-found

    # Load prezto tmux when tmux is installed
    if hash tmux &>/dev/null; then
        zgenom prezto tmux
    fi

    zgenom load zsh-users/zsh-syntax-highlighting
    zgenom load /path/to/super-secret-private-plugin

    # use a plugin file
    # The file must only contain valid parameters for `zgenom load`
    zgenom loadall < path/to/plugin/file

    # bulk load
    zgenom loadall <<EOPLUGINS
        zsh-users/zsh-history-substring-search
        /path/to/local/plugin
EOPLUGINS
    # ^ can't indent this EOPLUGINS

    # add binaries
    zgenom bin tj/git-extras

    # completions
    zgenom load zsh-users/zsh-completions

    # theme
    zgenom ohmyzsh themes/arrow

    # save all to init script
    zgenom save

    # Compile your zsh files
    zgenom compile "$HOME/.zshrc"
    # Uncomment if you set ZDOTDIR manually
    # zgenom compile $ZDOTDIR

    # You can perform other "time consuming" maintenance tasks here as well.
    # If you use `zgenom autoupdate` you're making sure it gets
    # executed every 7 days.

    # rbenv rehash
fi

You can also use zgenom in a more dynamic way:

if ! zgenom saved; then
    # ...
fi

# Load plugins on a per shell basis:
# (Only load chucknorris on weekends)
if is_weekend; then
    zgenom ohmyzsh plugins/chucknorris
    # Be aware that this will be loaded dynamically and increases the startup time.
    # When using `zgenom clean` this plugin might be removed as well (unless it is
    # currently loaded).
fi

# Load plugins lazily when used:
# (When brew is first executed, load ohmyzsh brew and then use brew)
alias brew='unalias brew && zgenom ohmyzsh brew && brew'
# Be aware that this might not work for all plugins.

Note: The more dynamic examples are not official features. They are rather byproducts. They are included as ideas you can test out. In most cases it's probably a better idea to always load the plugin instead.

Migration from zgen

The quickest way would be to just use a new remote. This way no plugins have to be cloned again.

cd $ZGEN_SOURCE
git remote add zgenom https://github.com/jandamm/zgenom.git
git fetch zgenom
git switch main
zgen reset

When you start a new shell your plugins will be migrated. You don't have to change your .zshrc.

Note: zgen is only present if you source zgen.zsh.

The preferred way would be to just delete zgen and start fresh.

Note: If you keep ~/.zgen around, zgenom will use it to store the plugins in there. So please rm or mv the folder before starting a new shell. (Otherwise the plugins will be migrated - with a prompt)

If you've specified branches (e.g. main) you can probably remove those since zgenom should take care of picking the right branch for you. Unless you're using a "pre-release" branch.

Note: While this README uses zgenom and ohmyzsh the old versions zgen and oh-my-zsh can be used interchangeably.

New features

  • Compiling your sourced scripts.
  • Add zgenom compile in case you want to recursively compile your dotfiles (manually).
  • Add zgenom bin to add an executable to your $PATH.
  • Lazy loading zgenom - only the bare minimum you need for the current shell is loaded.
  • The default $ZGEN_DIR is path/to/zgenom/sources (except when you have ~/.zgen for backwards compatibility). So most usecases shouldn't need to modify $ZGEN_DIR anymore.
  • Allow cloning without submodules zgenom clone <repo> --no-submodules.
  • Full support for non master branches (e.g. main). This includes following a new default branch.
  • compinit with custom flags wasn't working properly.
  • Update to ohmyzsh/ohmyzsh.
  • Implement the Zsh Plugin Standard.
  • Add zgenom clean to remove all unused plugins.
  • Add zgenom autoupdate to check for updates periodically and dispatch it to the background to remove any waiting times.
  • Allow just adding a plugins directory to fpath using --completion with load or ohmyzsh.
  • Add zgenom compdef to add compdef before loading plugins.

Usage

...

ohmyzsh

This is a handy shortcut for installing ohmyzsh plugins. They can be loaded using zgenom load too with a significantly longer format.

Load ohmyzsh base

It's a good idea to load the base components before specifying any plugins.

zgenom ohmyzsh

Load ohmyzsh plugins

zgenom ohmyzsh <location>

Example

zgenom ohmyzsh
zgenom ohmyzsh plugins/git
zgenom ohmyzsh plugins/sudo
zgenom ohmyzsh plugins/command-not-found
# Just use the completions in this directory
zgenom ohmyzsh --completion plugins/docker-compose

zgenom ohmyzsh themes/arrow

Prezto

Load Prezto

zgenom prezto

This will create a symlink in the $ZSHDOTDIR or $HOME directory. This is needed by prezto.

Note: When zgenom prezto is used with zgenom ohmyzsh together, prezto should be put behind ohmyzsh. Or prompt theme from prezto may not display as expected.

Load prezto plugins

zgenom prezto <modulename>

This uses the Prezto method for loading modules.

Note: Some modules from prezto are enabled by default. Use ZGEN_PREZTO_LOAD_DEFAULT=0 to disable this behavior.

Load a repo as Prezto plugins

zgenom pmodule <reponame> <branch>

This uses the Prezto method for loading the module. It creates a symlink and calls pmodule.

Set prezto options

zgenom prezto <modulename> <option> <value(s)>

This must be used before the module is loaded. Or if the default modules should be loaded (default) these settings must be done before the zgenom prezto command. module is prepended if the name does not start with module, prezto or a *, prezto is prepended if it does not start with prezto.

Using a default branch

If you don't specify a branch the remotes default branch will be used. (The one you see when you open the github page for a project). When the default branch is used zgenom will try to follow this branch. When you add a plugin with the default branch master and the maintainer decides to use main instead zgenom will switch from master to main for you.

If you have to specify a branch but still want this behavior you can use ___ instead of a branch name.

When you are currently using zgenom and have plugins without a branch specified you'll be asked (on zgenom load) if you want to migrate the old plugin or clone it freshly.

Be aware that this feature will delete the local branch when the head changes. So don't use it if you plan to tamper with clone locally. If you just want to use plugins this won't affect you.

See this comment for more information.

General zgenom functions

Load plugins and completions

zgenom load <repo> [location] [branch] [--completion] [--pin=full_commit_hash]

Zgenom tries to source any scripts from location using a "very smart matching logic". It will also append location to $fpath. If you add --completion it will only append location to fpath.

You can use --pin with a full commit hash instead of a branch to prevent the repo from updating.

  • repo
    • github user/repository or path to a repository
    • currently supported formats for a repository path:
      • any local repository
      • git://*
      • https://*
      • http://*
      • ssh://*
      • git@*:*/*
  • location
    • relative path to a script/folder
    • useful for repositories that don't have proper plugin
  • branch
    • specifies the git branch to use
  • --completion
    • Don't source any file. Just add the given location to $fpath

Load executables

zgenom bin <repo> --location --branch --name --glob

If location is omitted ./bin is checked if ./bin doesn't exist . is checked. All executables in the found folder will be added to the path.

If location is a folder all executables of this folder are added to the path.

It's also possible to provide a glob where every matching executable is added to the path.

Note: This may lead to unwanted side-effects so it's recommended that you specify the files you need. You can use zgenom list --bin to check which executables are added.

# Add 'fasd' to the path and rename it to 'fast'.
zgenom bin 'clvv/fasd' --location fasd --name fast

# Add all executables which are in bin, start with git- and end with -branch.
zgenom bin 'tj/git-extras' --glob 'bin/git-*-branch'

Bulk load plugins

zgenom loadall <plugins>

You can use it to load plugins listed in a file or provided by heredoc. Please see example .zshrc for usage.

Generate init script

zgenom save

It is recommended to save the plugin sourcing part to a static init script so we don't have to go through the time consuming installing/updating part every time we start the shell (or source .zshrc)

If you don't want use a init script call zgenom apply after you've loaded all plugins. It'll take care of compinit and adding the loaded bins to your PATH. The default path of the .zcompdump is $ZGEN_DIR/zcompdump_$ZSH_VERSION. You can change it by setting $ZGEN_CUSTOM_COMPDUMP.

Remove init script

zgenom reset

Removes the init script so it will be created next time you start the shell. You must run this every time you add or remove plugins to trigger the changes.

This will not remove the plugins physically from disk.

Check for an init script

zgenom saved

Returns 0 if an init script exists.

It also sources the init script if it exists.

Note: If you don't use zgenom saved you should call zgenom init manually.

Update all plugins and reset

zgenom update

Pulls updates on every plugin repository and removes the init script.

Update zgenom

zgenom selfupdate

Run updates automatically

Using autoupdate disables ohmyzsh automatic updates since zgenom will do the same. You can use --keep-ohmyzsh to keep ohmyzsh automatic updates enabled.

source path/to/zgenom.zsh

# Update every 7 days
zgenom autoupdate

# Update every 3 days
zgenom autoupdate 3

# Update only zgenom every 14 days
zgenom autoupdate --self 14

# Update only plugins every 7 days
zgenom autoupdate --plugin 7

# Update plugins every 7 days and zgenom every 14 days
zgenom autoupdate --plugin 7 --self 14

# Update every 7 days and run updates in the current shell
zgenom autoupdate --no-background

if ! zgenom saved; then
    # load plugins

Call zgenom selfupdate and zgenom update regularly. If you call one of those manually this will also reset the timer. So you can use it to make sure you update every x days.

Make sure to call it before you check for the init file with zgenom saved.

These backups will run fully in the background so you won't any slowdown in your startup time. When the update is complete and you start a new shell everything is prepared so you don't have to wait then either. When starting a new shell after a completed update you will get a log showing you what happened in the background.

There is also an option to run the updates in sync by adding --no-background. This will show you any output as it happens and you have to wait until you can use the shell.
This also increases the startup time around 17% (~16ms) in order to check if an update has to be done. This figure may vary depending on your plugins and machine.

Note: If your .zshrc contains any interactive prompts you might encounter issues with some terminals. In this case you might want to try running the updates in sync using --no-background.

Fix issues with compdef

zgenom compdef

compdef is only available after compinit is called which zgenom executes after all plugins are loaded.
Some plugins might use compdef and either error or fail to add completions (if they check the existence of compdef). Running zgenom compdef will provide a compdef and apply all calls after compinit was done.

Clean zgenom plugins

zgenom clean

Removes every plugin which isn't loaded in the current shell session.

Watch files for modifications

You can automate the process of running zgenom reset by specifying a list of files to ZGEN_RESET_ON_CHANGE. These files will be checked and if a change is detected zgenom reset is called.

ZGEN_RESET_ON_CHANGE=(${HOME}/.zshrc ${HOME}/.zshrc.local)

Compile your .zshrc files

zgenom compile .zshrc
zgenom compile ~/.zsh
zgenom compile $ZDOTDIR # If you set ZDOTDIR manually

The first will just compile your .zshrc. The second one will compile every zsh file it can recursively find in ~/.zsh. You might not want to add any of these lines to your .zsrhc but run them manually or automatically in the background.

You can provide the options -UzkMR to zgenom compile. They are just passed to zcompile. See man zshbuiltins for an explanation of the flags.

Safely access internal api

Calling any function matching __zgenom-* is assumed unsafe and the function is considered private. So it may be renamed anytime without further notice.

To provide a way to safely access some internal api zgenom api is introduced. Please use the zsh completion to check what parts of the internal api is exposed.

Notes

While this README uses zgenom and ohmyzsh the old versions zgen and oh-my-zsh can be used interchangeably.

Environment variables are still prefixed with ZGEN_ to keep backwards compatibility. When zgenom introduces new variables they are prefixed with ZGENOM_.

Be aware that zgenom tries to handle compinit for you to allow for the fastest possible initialization times. However, this functionality will be disabled if you've already called compinit yourself before sourcing zgenom.zsh. Alternatively, you can disable it yourself by disabling $ZGEN_AUTOLOAD_COMPINIT.

Extensions

Extensions may be a bit of a stretch. Every function matching zgenom-* is callable like zgenom *. Every completion function matching _zgenom_* is called by _zgenom.

Also $ZGENOM_EXTENSIONS can be used to add an entry to zgenom help and subcommand completion.

To provide an extension called abc you define zgenom-abc in your plugin. Then you can add a description: ZGENOM_EXTENSIONS+=('abc:Some description'). To provide additional completions you can define _zgenom_abc which will be called when the prompt starts with zgenom abc.

Existing extensions:

  • eval: Use zgenom to quickly generate plugins from a command or heredoc.
  • release: Use zgenom and gh to download github releases.
  • run: Use zgenom to run commands in the plugin folder (e.g. make).

Please create a PR to add your extension here :)

Note: It is not recommended to use the private api (__zgenom-*) since it may change without further notice. Use zgenom api instead.

Other resources

The awesome-zsh-plugins list contains many zgenom compatible zsh plugins & themes that you may find useful.

There's a zsh-quickstart-kit for using zsh and zgenom that does a guided setup of zgenom, including installing a starting sampler of useful plugins.

The Zsh Plugin Standard describes how a plugin for zsh should be written and what the plugin manager should do to support a plugin.

Zgenom does support most paragraphs of this standard. (1-3 & 7-9 as of this writing). The unsupported paragraphs are all related to unloading (which isn't currently supported) and a hook for plugins that the plugin manager should call on updates (you probably shouldn't use zgenom if your plugin requires this).

Note: Paragraph 3 says to add every ./bin folder found in a plugin. I personally wouldn't want this so this is off by default. Please set ZGENOM_AUTO_ADD_BIN=1 before sourcing zgenom.zsh to enable this paragraph.

Releases

Every commit which is merged into main is considered a stable release. Every open PR is considered a beta release that I test locally. You're welcome to test it on your machine as well.

Alternatives

There are a lot of alternatives. The most popular is probably antigen but it's only in maintenance mode. An extensive list can be found here.

You should think what features you need from a plugin manager. At its purest form it's just git clone and source path/to/plugin/file.zsh. So nothing you couldn't do yourself.

But there are some subtleties that you might not think of. For example the default branch could change (e.g. master to main) and keep you from updating the plugin without an error message.

With zgenom I don't even think about zsh plugins. Every seven days zgenom and the plugins get updated automatically. zgenom can also detect new plugins and install them automatically as well.

Feedback

If you like this plugin, star it! It's a great way of getting feedback. The same goes for reporting issues or feature requests.

zgenom's People

Contributors

belak avatar dirx avatar elliottcable avatar forivall avatar hackaugusto avatar hauntsaninja avatar hvindin avatar itiut avatar jandamm avatar javenwang avatar jtt9340 avatar knakayama avatar kylo252 avatar luckywindsck avatar m42e avatar mul14 avatar n4m3z avatar navrudh avatar ngg avatar ogarcia avatar pschmitt avatar revolter avatar sevanteri avatar superbrothers avatar svenstaro avatar tarjoilija avatar tsmoffat avatar ubmit avatar unixorn avatar vifon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zgenom's Issues

Using zgenom load with just location doesn't source functions

I'm trying to use zgenom to load plugins using just the [location] parameter pointing to a plugin directory.
This will however not properly add the functions subdirectory to fpath.

I think the reason is that zgenom-load() for the directory case doesn't declare local dir.
My current workaround is to add:

# ...
    elif [[ "$#" == 1 && ("${1[1]}" == '/' || "${1[1]}" == '.' ) ]]; then
        location="${1}"
        if [[ -d $location ]]; then
            local dir="$location"
        fi
    else
# ...

'zgen-compile' fails with 'dotbare' plugin

Hey,

First of all, thanks for the hardwork! I've just been trying zgenom after switching from Antibody and I'm really happy so far.

When adding:

	zgenom load kazhala/dotbare

and then when I try to load it:

❯ zgenom reset
-- zgenom: Deleting `/home/$USER/.local/share/zgenom/init.zsh` ...
❯ zgenom save
-- zgenom: Creating `/home/$USER/.local/share/zgenom/init.zsh` ...
-- zgenom: Initializing completions ...
-- zgenom: Compiling files ...
-zgen-compile:119: parse error near `\n'
-zgen-compile:zcompile:3: can't read file: /home/$USER/.local/share/zgenom/kazhala/dotbare/___/helper/preview.sh

The weird thing is that it seems that dotbare works fine regardless of that initial error.

P.s: It works out of the box with Antibody.

slow, but possibly due to errors in compiling??

Hi,
I just tried to switch to zgenom from zgen because I was trying to hunt down slow shell startups.

Slow here means >1.1s. Reading many other people's comments, I was under the impression to be able to get it down to about 0.5s which would be fine for me.

So I tried the migration and so on also did a zgenom reset and there I was presented with the following errors:

zgenom reset
-- zgenom: Deleting `/Users/myuserid/.zgenom/sources/init.zsh` ...

zsh                
-- zgenom: Creating `/Users/myuserid/.zgenom/sources/init.zsh` ...
-- zgenom: Initializing completions ...
-- zgenom: Compiling files ...
zgen-save:89: parse error: condition expected: /Users/myuserid/.zcompdump
zgen-save:89: parse error: condition expected: /Users/myuserid/.zcompdump-mylaptop-5.8
zgen-save:89: parse error: condition expected: /Users/myuserid/.zcompdump-mylaptop-5.8.zwc
-zgen-compile:1: parse error near `)'
-zgen-compile:zcompile:3: can't read file: /Users/myuserid/.zcompdump-mylaptop-5.8.zwc
zgen-save:89: parse error: condition expected: /Users/myuserid/.zcompdump.zwc
-zgen-compile:1: parse error near `)'
-zgen-compile:zcompile:3: can't read file: /Users/myuserid/.zcompdump.zwc
-- zgenom: Creating `/Users/myuserid/.zgenom/sources/init.zsh` ...
-- zgenom: Initializing completions ...
-- zgenom: Compiling files ...
zgen-save:89: parse error: condition expected: /Users/myuserid/.zcompdump
zgen-save:89: parse error: condition expected: /Users/myuserid/.zcompdump-mylaptop-5.8
zgen-save:89: parse error: condition expected: /Users/myuserid/.zcompdump-mylaptop.zwc
-zgen-compile:1: parse error near `)'
-zgen-compile:zcompile:3: can't read file: /Users/myuserid/.zcompdump-mylaptop-5.8.zwc
zgen-save:89: parse error: condition expected: /Users/myuserid/.zcompdump.zwc
-zgen-compile:1: parse error near `)'
-zgen-compile:zcompile:3: can't read file: /Users/myuserid/.zcompdump.zwc

I don't know enough about this compiling step, but could that mean that compiling actually fails and therefore my startup times remain high?

And if so - do you have an idea on how to hunt down the actual problem?

Here's my zprof for reference:

num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)    1         371,89   371,89   96,98%    172,83   172,83   45,07%  zgen-init
 2)    3         118,89    39,63   31,00%    118,89    39,63   31,00%  (anon)
 3)    1          56,48    56,48   14,73%     56,48    56,48   14,73%  handle_completion_insecurities
 4)    2          12,82     6,41    3,34%     12,82     6,41    3,34%  compinit
 5)    1          10,82    10,82    2,82%     10,82    10,82    2,82%  load-our-ssh-keys
 6)    1           6,28     6,28    1,64%      6,28     6,28    1,64%  _zsh_highlight_bind_widgets
 7)   20           1,72     0,09    0,45%      1,72     0,09    0,45%  compdef
 8)    1           1,08     1,08    0,28%      1,08     1,08    0,28%  colors
 9)    5           0,79     0,16    0,21%      0,79     0,16    0,21%  add-zsh-hook
10)    3           0,66     0,22    0,17%      0,66     0,22    0,17%  is-at-least
11)    3           0,57     0,19    0,15%      0,57     0,19    0,15%  bashcompinit
12)    4           0,61     0,15    0,16%      0,29     0,07    0,08%  complete
13)    1           0,07     0,07    0,02%      0,07     0,07    0,02%  group_lazy_load
14)    1           0,14     0,14    0,04%      0,05     0,05    0,01%  prompt_agnoster_setup
15)    1           0,05     0,05    0,01%      0,05     0,05    0,01%  detect-clipboard
16)    2           0,03     0,02    0,01%      0,03     0,02    0,01%  env_default
17)    1           0,03     0,03    0,01%      0,03     0,03    0,01%  zgen-saved
18)    1           0,05     0,05    0,01%      0,02     0,02    0,01%  zgenom

explanation of files

Just a minor request for documentation.
I get that there is a compiled version of my zshrc - but why does it create 3 files?

.zcompdump
.zcompdump-Torsten’s MacBook Pro-5.8
.zcompdump.zwc

Or did I just skip this part while reading?
Would be great to have that documented somewhere.

_rmlint.sh:32: command not found: _arguments

After updating my completion library, I see the following bug when booting zsh:

~/.zgenom/sources/zsh-users/zsh-completions/___/src/_rmlint.sh:32: command not found: _arguments

See: zsh-users/zsh-completions#809 which seems basically the same issue, and they note it's a zgen bug (so maybe inherited into zgenom), not an issue with the completion repo.

Proposed solution from the thread:

Files starts with _ like _rmfile.sh is autoloaded file in zsh file name convention. It should not be loaded manually. zgen should avoid loading such files

Occasional zsh processes pinning CPU

I'm not sure what the root cause is, but after switching from zgen to zgenom, occasionally I get zsh processes not associated with any session that are pinned to 100% CPU.

I suspect it's a busy loop somewhere in an async process during an update, but that's just a guess.
I'm moreorless creating this issue to see if anyone else has experienced this before I start narrowing down the root cause.

PS: Thanks a ton for carrying the torch and maintaining the zgen legacy! 💞

Unable to dynamically load a plugin

So I have a notify plugin I want to be loaded only in case of a Tmux session or a Vim session. (Because I use iTerm's inbuilt notifier in other cases)

I tried loading it through an IF statement (outside of the if ! zgenom saved; then ... fi block):

if [[ $TMUX ]] || [[ $VIMRUNTIME ]]; then
    zgenom load MichaelAquilina/zsh-auto-notify
fi

I know the conditions are working because I checked with echo. It printed only when appropriate.

I'm sure I'm not using zgenom load correctly. Any help?

Errors when creating init.zsh

Hello! I was using antigen in my zsh setup previously, however there were various issues I had with that setup and then realized it seems like its not maintained anymore. I found zgenom among some other options, however this seemed like the easiest and fastest option so set it up last night.

Loving how easy it was to setup, however, I am running into some errors I see when starting a new session. Unsure if they can be ignored or they point to other issues as things seem to be working thus far, though admittedly it is still very early.

When I first install or reset, I get this output:

❯ reloadzsh
Creating a zgenom save
/Users/bduffey2/.zgenom/sources/ohmyzsh/ohmyzsh/___/oh-my-zsh.sh:149: no matches found: ~/.oh-my-zsh/lib/*.zsh
-- zgenom: Creating `/Users/bduffey2/.zgenom/sources/init.zsh` ...
-- zgenom: Initializing completions ...
-- zgenom: Compiling files ...
__zgenom_compile:zcompile:3: can't write zwc file: /Users/bduffey2/.zcompdump-Brian Duffey’s iMac-5.3.zwc
__zgenom_compile:zcompile:3: can't write zwc file: /Users/bduffey2/.zcompdump-Brian Duffey’s iMac-5.6.2.zwc
__zgenom_compile:zcompile:3: can't write zwc file: /Users/bduffey2/.zcompdump-Brian Duffey’s iMac-5.7.1.zwc
__zgenom_compile:zcompile:3: can't write zwc file: /Users/bduffey2/.zcompdump-Brian Duffey’s iMac-5.8.zwc

Are these cause for concern? Thanks in advance.

Feature request: Support adding and auto-updating of Oh My Zsh plugins without Oh My Zsh

I would like to be able to add plugins from the Oh My Zsh repo without bringing in the base functions of Oh My Zsh which do things like compinit which we might not handle manually or at a later time.

I note other frameworks do support this already. This could be implemented in such a way that:

zgenom load ohmyzsh/oymyzsh lib/git
zgenom load ohmyzsh/oymyzsh plugins/osx

which points directly to a path within a repo and pulls the plugins/functions wanted, rather than needing the rest of the OMZ repo

zgenom save throws errors on minimal install

Tried setting up a minimal install with:

# Download zgenom
[[ -f "${HOME}/.zgenom/zgenom.zsh" ]] ||
    git clone --depth 1 -- \
        https://github.com/jandamm/zgenom.git "${HOME}/.zgenom"

source "${HOME}/.zgenom/zgenom.zsh"

# zgenom autoupdate

# if the init script doesn't exist
if ! zgenom saved; then
  echo "Creating a zgenom save"
  # source ~/.dotfiles/zsh_prompt.sh

  # save all to init script
  zgenom save

  # Compile your zsh files
  zgenom compile "$HOME/.zshrc"
  zgenom compile $ZDOTDIR
fi

Opening a new shell throws errors, and takes several seconds:

Last login: Tue Nov 16 12:03:01 on ttys003
Creating a zgenom save
-- zgenom: Creating `/Users/trevorhartman/.zgenom/sources/init.zsh` ...
zgenom-save:3: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
__zgenom_write:1: no such file or directory: /Users/trevorhartman/.zgenom/sources/init.zsh
-- zgenom: Initializing completions ...
-- zgenom: Compiling files ...

Do I need to manually create a ~/.zgenom/sources dir? Should that be mentioned in the installation instructions?

Theme not loading after install or reset

Hi,

After migrating from zgen I had an issue with the latest version where the theme is not loaded when creating a zgenom save.

After some digging I found that the issue starts with #63

With 8ed1e26 it is working correctly:
zgenom_theme_working

But not with dd43388:
zgenom_theme_issue

.zshrc used for testing
# zgen installation
# git clone https://github.com/jandamm/zgenom.git "${HOME}/.zgenom"

ZGEN_DIR="$HOME/.zgen"

# load zgenom
source "${HOME}/.zgenom/zgen.zsh"

# Check for plugin and zgenom updates every 7 days
# This does not increase the startup time.
# zgenom autoupdate

# enable error redirect from react-native app
export REACT_EDITOR="code"

# check if there's no init script
if ! zgen saved; then
    echo "Creating a zgen save"

    zgen oh-my-zsh

    # plugins
    zgen oh-my-zsh plugins/ssh-agent
    zgen oh-my-zsh plugins/docker
    zgen oh-my-zsh plugins/docker-compose
    zgen oh-my-zsh plugins/sudo
    zgen oh-my-zsh plugins/common-aliases
    zgen oh-my-zsh plugins/command-not-found
    zgen oh-my-zsh plugins/git
    zgen oh-my-zsh plugins/gitfast
    zgen oh-my-zsh plugins/node
    zgen oh-my-zsh plugins/npm
    zgen oh-my-zsh plugins/yarn
    zgen oh-my-zsh plugins/emacs
    zgen oh-my-zsh plugins/kubectl
    zgen oh-my-zsh plugins/vscode
    zgen oh-my-zsh plugins/gcloud
    zgen load zsh-users/zsh-syntax-highlighting
    zgen load zsh-users/zsh-autosuggestions

    # completions
    zgen load zsh-users/zsh-completions src
    zgen load lukechilds/zsh-better-npm-completion

    # theme
    zgen oh-my-zsh themes/clean

    # save all to init script
    zgen save

    # Compile your zsh files
    #zgen compile "$HOME/.zshrc"
fi

export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin"  # Added by n-install (see http://git.io/n-install-repo).
current .zshrc
# zgenom installation
# git clone https://github.com/jandamm/zgenom.git "${HOME}/.zgenom"

# load zgenom
source "${HOME}/.zgenom/zgenom.zsh"

# Check for plugin and zgenom updates every 7 days
# This does not increase the startup time.
zgenom autoupdate

# enable error redirect from react-native app
export REACT_EDITOR="code"

# check if there's no init script
if ! zgenom saved; then
    echo "Creating a zgenom save"

    zgenom ohmyzsh

    # plugins
    zgenom ohmyzsh plugins/ssh-agent
    zgenom ohmyzsh plugins/docker
    zgenom ohmyzsh plugins/docker-compose
    zgenom ohmyzsh plugins/sudo
    zgenom ohmyzsh plugins/common-aliases
    zgenom ohmyzsh plugins/command-not-found
    zgenom ohmyzsh plugins/git
    zgenom ohmyzsh plugins/gitfast
    zgenom ohmyzsh plugins/node
    zgenom ohmyzsh plugins/npm
    zgenom ohmyzsh plugins/yarn
    zgenom ohmyzsh plugins/emacs
    zgenom ohmyzsh plugins/kubectl
    zgenom ohmyzsh plugins/vscode
    zgenom ohmyzsh plugins/gcloud
    zgenom load zsh-users/zsh-syntax-highlighting
    zgenom load zsh-users/zsh-autosuggestions

    # completions
    zgenom load zsh-users/zsh-completions src
    zgenom load lukechilds/zsh-better-npm-completion

    # theme
    zgenom ohmyzsh themes/clean

    # save all to init script
    zgenom save

    # Compile your zsh files
    zgenom compile "$HOME/.zshrc"
fi

export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin"  # Added by n-install (see http://git.io/n-install-repo).

Config plugin specific settings right away after loading it

Many plugins need specific configurations, bug zgenom can't determine them.
For example:

if ! zgenom saved; then
    echo "Creating a zgenom save"
    zgenom load zsh-users/zsh-history-substring-search
    bindkey '^[[A' history-substring-search-up
    bindkey '^[[B' history-substring-search-down
    zgenom save
fi

the bindkey lines didn't appear in the generated init.zsh file, thus need to be written elsewhere,separate coupled code into different places makes them harder to maintain.

Being able to config plugin settings just after loading it is more intuitive, and easier to add/remove/debug them.
Maybe this can be done by a command to construct and load an "inline plugin", like

zgenom eval "bindkey '^[[A' history-substring-search-up"'

or with heredoc

zgenom eval <<EOP
    bindkey '^[[A' history-substring-search-up
    bindkey '^[[B' history-substring-search-down
EOP

Even better, just write normal zsh statements without any special syntax,and let zgenom automatically add these statements to the generated init.zsh file as is.

Compile All The Things!

Compiling files like .zshrc and .zcompdump gives quite a speed improvement

I have a function that compiles all the things

# The following code helps us by optimizing the existing framework.
# This includes zcompile, zcompdump, etc.
compileAllTheThings () {
  setopt EXTENDED_GLOB
  local zsh_glob='^(.git*|LICENSE|README.md|*.zwc)(.)'

  # zcompile the completion cache; siginificant speedup.
  for file in ${ZDOTDIR:-${HOME}}/.zcomp${~zsh_glob}; do
    zcompare ${file}
  done

  # zcompile .zshrc
  zcompare ${ZDOTDIR:-${HOME}}/.zshrc

  # Zgenom
  zgenom_mods=${ZDOTDIR:-${HOME}}/.zgenom/
  zcompare ${zgenom_mods}init.zsh
  zcompare ${zgenom_mods}zgenom.zsh
  for dir ('/zsh-users/' '/zdharma/' '/robbyrussell/oh-my-zsh-master/plugins/shrink-path/'); do
    if [ -d "${zgenom_mods}${dir}" ]; then
      for file in ${zgenom_mods}${dir}**/*.zsh; do
        zcompare ${file}
      done
    fi
  done
}

Possible typo in README

Be aware that this will be loaded dynamically and reduces the startup time.

Maybe reduces -> increase?

Pin to a commit

It'd be useful if we can pin plugins to a specific commit. I had some plugins break because of an update and I now have no way to pin or rollback to a working commit.

zwc files everywhere

IIUC zgenom compiles some of the shell scripts to speed up the execution.
I always thought this would be limited to just the zgenom files.
But somehow I end up with .zwc files all over my filesystem.

This is my setup:

export ZGEN_CUSTOM_COMPDUMP="${HOME}/.zcompdump-shodan2"
source "${HOME}/.zgenom/zgenom.zsh"
zgenom autoupdate
if ! zgenom saved; then

  echo "not saved"
  zgenom ohmyzsh
  zgenom ohmyzsh plugins/sudo
  zgenom ohmyzsh themes/daveverwer

  zgenom save

  zgenom compile "$HOME/.zshrc"
  zgenom compile $ZDOTDIR
fi

Now looking at this I was wondering if maybe ZDOTDIR could cause this.
And fair enough - it is empty.

Could this be cause by my zgenom setup?
According to the zsh folks this is by no means caused by zsh itself.

Custom aliases not being loaded

Hello! I am not sure if this is the right place for this but wanted to start here as I really appreciated your help getting things working initially. I am using p10k, zgenom, and ohmyzsh in a similar setup to the quickstart. omz lets you add files to the custom directory that end in .zsh, and then auto loads those files (handy for things like aliases and functions). I have 2 such files that were loading before switching to zgenom but are no longer loading. I am not 100% sure if this is from zgenom or p10k, but wanted to start here because maybe you had some ideas or even ways I can troubleshoot/debug. Thanks in advance!

Add an unload command to unload the loaded plugin

In some other frameworks it is possible to unload some plugins, e.g. for testing or overlapping configurations, if they are written in different files. Is it possible to implement something similar here?

Slow startup times via `zgenom ohmyzsh`

I use zgenom to load all my zsh plugins(ohmyzsh and others).
I do this to keep my shell loading time to a minimum.

For e.g

zgenom ohmyzsh
    
zgenom ohmyzsh plugins/sudo
zgenom ohmyzsh plugins/git
zgenom ohmyzsh plugins/cp
zgenom ohmyzsh plugins/aws
zgenom ohmyzsh plugins/golang
zgenom ohmyzsh plugins/copypath

The issue is, the first zgenom ohmyzsh is doubling my start-up time. From 0.6s to 1.2s.

I can tell my experience differs on commenting that first line as tabbing on multiple options doesn't work like it did before.
Is there a list of features that you get on running zgenom ohmyzsh?

no such file or directory: ~/.zshrc

Hi,
i have my zgenom data in ~/.zsh/zgenom. This file is sourced in the .zshrc like this:

# Load zgenom stuff. Needs to stay at top so it can output stuff before the
# Powerlevel10k instant prompt can come into place
source $HOME/.zsh/zgenom

I get an error each time i do a zgenom reset and reinitializing zgenom:

-- zgenom: Updating 'zsh-users/zsh-completions/___' ...
From https://github.com/zsh-users/zsh-completions
   bebaa61..a1a11ca  master     -> origin/master
Updating bebaa61..a1a11ca
Fast-forward
 src/_ccache    | 2 +-
 src/_drush     | 4 ++--
 src/_golang    | 2 +-
 src/_jonas     | 2 +-
 src/_openssl   | 4 ++--
 src/_perf      | 2 +-
 src/_pm2       | 4 ++--
 src/_scala     | 2 +-
 src/_tmuxp     | 2 +-
 src/_udisksctl | 2 +-
 src/_yarn      | 2 +-
 11 files changed, 14 insertions(+), 14 deletions(-)

-- zgenom: Deleting `/Users/simonszu/.zgenom/sources/init.zsh` ...

Recreating init.zsh

zsh:source:1: no such file or directory: ~/.zshrc
--------

Why that? The file is there and can immediately sourced manually after the init process finishes and i get my prompt back.

Allowing for default branch seems to have broken oh-my-zsh

Just ran zgen update and pulled in the most recent commits, including the "use default branch instead of master" change. Now I'm seeing these errors anytime I create a new shell:

/Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-___/oh-my-zsh.sh:source:12: no such file or directory: /Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-master/tools/check_for_upgrade.sh
/Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-___/oh-my-zsh.sh:cd:63: no such file or directory: /Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-master
/Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-___/oh-my-zsh.sh:source:74: no such file or directory: /Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-master/lib/compfix.zsh
/Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-___/oh-my-zsh.sh:76: command not found: handle_completion_insecurities
/Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-___/oh-my-zsh.sh:100: no matches found: /Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-master/lib/*.zsh
/Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-___/plugins/kubectl/kubectl.plugin.zsh:5: no such file or directory: /Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-master/cache/kubectl_completion

I think this is coming from oh-my-zsh's default settings:

❯ echo $ZSH
/Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-master
❯ echo $ZSH_CACHE_DIR
/Users/sprice/.zgenom/sources/ohmyzsh/ohmyzsh-master/cache

Relevant lines from my zgen setup script:

zgen oh-my-zsh
zgen oh-my-zsh plugins/kubectl

any advice on how to avoid? Should I specify the master branch for oh-my-zsh explicitly? How do I do that?

Provide documentation on recommended way to configure installation and plugin directories

I would like to keep my zgenom installation and sources in $XDG_DATA_HOME/zgenom instead of the default $HOME/.zgenom. What would be the simplest way to do so?

Initially, I set ZGEN_DIR to $XDG_DATA_HOME/zgenom and cloned the source repo there. However, I think I may be misusing that environment variable because now all the plugin downloads are dropped into the source directory. I didn't notice at first, but then I ran zgenom clean, which resulted in a broken zgenom because some essential source directories were removed.

Can the documentation be updated to include a list of supported environment variables and their purpose? Or at minimum, how to change the installation directory.

Also, I would recommend rewording this line in the readme:

The default $ZGEN_DIR is a sources subdirectory where you cloned zgenom to

I interpreted it to mean that $ZGEN_DIR is "where you cloned zgenom to".

Any way to load zoxide binary without having it installed system-wide?

I'm using ajeetdsouza/zoxide.

With zinit, the binary can be loaded and updated without having zoxide installed system-wide using (source):

zinit ice wait"2" as"command" from"gh-r" lucid \
  mv"zoxide*/zoxide -> zoxide" \
  atclone"./zoxide init zsh > init.zsh" \
  atpull"%atclone" src"init.zsh" nocompile'!'
zinit light ajeetdsouza/zoxide
zgenom load ajeetdsouza/zoxide

works but only if zoxide is installed system-wide.

Can we achieve something similar with zgenom?

Keep up the good work!

alias not found

This is what my .zshrc looks like:

source "${HOME}/.zgenom/zgenom.zsh"
zgenom autoupdate
if ! zgenom saved; then
  zgenom ohmyzsh
  zgenom ohmyzsh plugins/git
  zgenom ohmyzsh plugins/sudo
  zgenom ohmyzsh themes/daveverwer
  zgenom save
  zgenom compile "$HOME/.zshrc"
  zgenom compile $ZDOTDIR
fi

alias node14='export PATH="/opt/homebrew/opt/node@14/bin:$PATH"'
alias node16='export PATH="/opt/homebrew/opt/node@16/bin:$PATH"'
alias node17='export PATH="/opt/homebrew/opt/node@17/bin:$PATH"'
node14

With zgenom active I am getting

/Users/tcurdt/.zshrc:35: command not found: node14

while it works fine without.

Any idea what's going on?

Add autoupdate functionality

Moving this to a new issue.

I like the idea of having the autoupdate being part of core, defaulting to off. I also like the idea of moving things into a bindir and having the things in there not even get sourced unless ZGENOM_LOAD_XYZ is set to minimize startup impact.

I don't really know how autoload functions work all that well, that might be enough of a performance saver to go with that over not sourcing unused functionality.

[qustion] is this a normal behaviour?

Hi,
I followed your installation instructions, when checking the ~/.zgenom folders I'm getting this:
Screenshot from 2021-01-20 16-48-58
some sub folders has no names only underscores, is that normal? am i missing something here?
Thank you

Option MARK_DIRS makes `zgenom update` fail

Hi

zgenom update uses filename generation to find the worktrees of loaded plugins in

repo="${repo%/.git/}"

When MARK_DIRS is set this fails:

# for repo in ~/.zgenom/**/*/.git/; do echo ${repo%/.git/}; done
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-greymd/tmux-xpanes/___/.git//
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-joel-porquet/zsh-dircolors-solarized/___/.git//
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-laurenkt/zsh-vimto/___/.git//
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-MichaelAquilina/zsh-you-should-use/___/.git//
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-nojhan/liquidprompt/___/.git//
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users/zsh-completions/___/.git//

After unsetting:

# unsetopt markdirs
# for repo in ~/.zgenom/**/*/.git/; do echo ${repo%/.git/}; done
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-greymd/tmux-xpanes/___
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-joel-porquet/zsh-dircolors-solarized/___
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-laurenkt/zsh-vimto/___
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-MichaelAquilina/zsh-you-should-use/___
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-nojhan/liquidprompt/___
/home/henk/.zgenom/sources/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users/zsh-completions/___

This breaks updating:

# zgenom update
-- zgenom: Updating 'https-COLON--SLASH--SLASH-github.com-SLASH-greymd/tmux-xpanes/___/.git//' ...
fatal: this operation must be run in a work tree

-- zgenom: Updating 'https-COLON--SLASH--SLASH-github.com-SLASH-joel-porquet/zsh-dircolors-solarized/___/.git//' ...
fatal: this operation must be run in a work tree

-- zgenom: Updating 'https-COLON--SLASH--SLASH-github.com-SLASH-laurenkt/zsh-vimto/___/.git//' ...
fatal: this operation must be run in a work tree

-- zgenom: Updating 'https-COLON--SLASH--SLASH-github.com-SLASH-MichaelAquilina/zsh-you-should-use/___/.git//' ...
fatal: this operation must be run in a work tree

-- zgenom: Updating 'https-COLON--SLASH--SLASH-github.com-SLASH-nojhan/liquidprompt/___/.git//' ...
fatal: this operation must be run in a work tree

-- zgenom: Updating 'https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users/zsh-completions/___/.git//' ...
fatal: this operation must be run in a work tree

-- zgenom: Deleting `/home/henk/.zgenom/sources/init.zsh` ...

Other functions might also be affected, e.g. clean removed all installed plugins.

I have no suggestion how to fix this.

I’ll be happy to provide more info if you let me know what you need.

autoupdate complains about lock file

❯ zgenom autoupdate
Alias tip: zgen autoupdate
__zgenom_autoupdate:33: file exists: /Users/alextes/.zgenom-autoupdate-lock
❯ stat /Users/alextes/.zgenom-autoupdate-lock
gstat: cannot stat '/Users/alextes/.zgenom-autoupdate-lock': No such file or directory

any idea what could cause this? Only odd thing I can think of is that my .zshrc is a symlink.

Slow init

Hello!

I don't think this is specifically a zgenom issue (as I have this same issue with zgen), but hoping to get some help. My init times are quite noticeably slow.

Here is my zprof output:

num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)    2         198.84    99.42   26.08%    198.84    99.42   26.08%  compdump
 2)    4         491.91   122.98   64.53%    140.03    35.01   18.37%  compinit
 3) 1653         126.71     0.08   16.62%    126.71     0.08   16.62%  compdef
 4)    1         401.64   401.64   52.69%     97.28    97.28   12.76%  zgen-init
 5)    2          85.85    42.93   11.26%     85.85    42.93   11.26%  _zgen-check-for-updates
 6)    4          27.71     6.93    3.63%     27.71     6.93    3.63%  compaudit
 7)    2          27.17    13.59    3.56%     27.17    13.59    3.56%  zrecompile
 8)   40          22.35     0.56    2.93%     16.89     0.42    2.22%  _omz_source
 9)    1           9.67     9.67    1.27%      9.67     9.67    1.27%  nvm_supports_source_options
10)    2           7.52     3.76    0.99%      7.52     3.76    0.99%  _add_identities
11)    2           7.01     3.51    0.92%      6.93     3.47    0.91%  _zsh_highlight_load_highlighters
12)    2           5.88     2.94    0.77%      5.88     2.94    0.77%  (anon) [/Users/tom/.zgen/robbyrussell/oh-my-zsh-master/tools/check_for_upgrade.sh:155]
13)    2           3.57     1.79    0.47%      3.57     1.79    0.47%  test-ls-args
14)    2           9.02     4.51    1.18%      3.14     1.57    0.41%  handle_update
15)   20           0.86     0.04    0.11%      0.86     0.04    0.11%  is-at-least
16)    2           0.82     0.41    0.11%      0.82     0.41    0.11%  colors
17)    2           0.83     0.42    0.11%      0.77     0.39    0.10%  _zsh_highlight__function_callable_p
18)   16           0.64     0.04    0.08%      0.64     0.04    0.08%  add-zsh-hook
19)    5           0.63     0.13    0.08%      0.60     0.12    0.08%  add-zle-hook-widget
20)    1           0.43     0.43    0.06%      0.43     0.43    0.06%  regexp-replace
21)    2           0.41     0.21    0.05%      0.41     0.21    0.05%  _start_agent
22)    2           0.21     0.10    0.03%      0.21     0.10    0.03%  (anon) [/Users/tom/.zgen/zsh-users/zsh-autosuggestions-master/zsh-autosuggestions.zsh:458]
23)    1           0.14     0.14    0.02%      0.09     0.09    0.01%  complete
24)    1           0.06     0.06    0.01%      0.06     0.06    0.01%  nvm_has
25)    1           9.74     9.74    1.28%      0.05     0.05    0.01%  nvm_process_parameters
26)    1           0.03     0.03    0.00%      0.03     0.03    0.00%  _zsh_highlight__function_is_autoload_stub_p
27)    2           0.03     0.01    0.00%      0.03     0.01    0.00%  _zsh_highlight__is_function_p
28)    1           0.02     0.02    0.00%      0.02     0.02    0.00%  (anon) [/usr/share/zsh/5.9/functions/add-zle-hook-widget:28]
29)    4           0.02     0.01    0.00%      0.02     0.01    0.00%  env_default
30)    1           0.02     0.02    0.00%      0.02     0.02    0.00%  nvm_auto
31)    2           0.02     0.01    0.00%      0.02     0.01    0.00%  bashcompinit
32)    2           0.00     0.00    0.00%      0.00     0.00    0.00%  _zsh_highlight_bind_widgets

As you can see, compinit, compdef, and zgen-init are quite slow.

Coming from zgen, I followed the "quickest way" instructions (using my existing .zgen directory and just updating the remote to point to zgenom and checking out main).

Here are the relevant parts of my .zshrc:

# zgen global vars
ZGEN_RESET_ON_CHANGE=(${HOME}/.zshrc)
ZGEN_PLUGIN_UPDATE_DAYS=30
ZGEN_SYSTEM_UPDATE_DAYS=60

# clone zgen 
if [ ! -d "${HOME}/.zgen" ]; then
  printf "~/.zgen doesnt exist. Installing zgen..."
  git clone ssh://[email protected]/jandamm/zgenom.git "${HOME}/.zgen"
fi

# load zgen
source "${HOME}/.zgen/zgen.zsh"

# Generate zgen init script if needed
if [[ ! -s ${ZDOTDIR:-${HOME}}/.zgen/init.zsh ]]; then
  echo "Creating a zgen save..."
  # load oh-my-zsh
  zgen oh-my-zsh

  # load oh-my-zsh plugins
  zgen oh-my-zsh plugins/git
  zgen oh-my-zsh plugins/ssh-agent
  zgen oh-my-zsh plugins/node
  zgen oh-my-zsh plugins/npm
  zgen oh-my-zsh plugins/brew
  zgen oh-my-zsh plugins/gem
  zgen oh-my-zsh plugins/macos
  zgen oh-my-zsh plugins/pip
  zgen oh-my-zsh plugins/z
  zgen oh-my-zsh plugins/git-extras
  zgen oh-my-zsh plugins/git-flow
  zgen oh-my-zsh plugins/sudo

  # load non-zsh plugins
  zgen load zsh-users/zsh-syntax-highlighting
  zgen load zsh-users/zsh-autosuggestions
  zgen load unixorn/autoupdate-zgen

  # load theme
  zgen oh-my-zsh themes/refined

  # generate the init script from plugins above
  zgen save
  zcompile ${ZDOTDIR:-${HOME}}/.zgen/init.zsh
else
  # load zgen save
  source ${ZDOTDIR:-${HOME}}/.zgen/init.zsh
fi

Any ideas why zgen-init and compinit are so slow?

Any workaround for when zgenom source dir is immutable?

I try to keep a deterministic OS userspace with Nix/NixOS but found zgenom wants to write the compiled versions of itself to the source directory.

-zgen-compile:zcompile:3: can't write zwc file: /nix/store/41nvcwaknvb2n051g20aq48pkf0mw1cj-source/zgenom.zsh.zwc
-zgen-compile:zcompile:3: can't write zwc file: /nix/store/41nvcwaknvb2n051g20aq48pkf0mw1cj-source/zgen.zsh.zwc

Perhaps it needs to be like this but just thought I'd check if there was any workaround for compilation when the zgenom source directory is immutable?

errror - did not send all necessary objects

While "Breaking-Move" gives an idea, I am a little lost on what happened here.

Last zgenom autoupdate log:
--------
fatal: bad object refs/remotes/origin/Breaking-Move-zgen-compatibility-into-zgen.zsh.zwc
error: https://github.com/jandamm/zgenom.git did not send all necessary objects


-- zgenom: Deleting `/Users/tcurdt/.zgenom/sources/init.zsh` ...
-- zgenom: Deleting `/Users/tcurdt/.zcompdump-shodan2` ...

Recreating init.zsh

not saved
-- zgenom: Creating `/Users/tcurdt/.zgenom/sources/init.zsh` ...
-- zgenom: Initializing completions ...
-- zgenom: Compiling files ...
--------

Any pointers on how to fix this?

Option to silence output

Hello! Love the plugin, been using it for about 7 months. One thing I don't see in the documentation (or my quick glance through the source) is a way to silence output. The reason I ask is that I am using Powerlevel10k with instant prompt, which shows a warning every time that the .zshrc file has console output after p10k starts. I get why outside of this use case having the console output is great or even needed, however, it would be nice if it could be turned off via an output to avoid seeing these warnings when I start a new console. Specifically, this is what I am referencing as console output (the first line is from p10k):

-- console output produced during zsh initialization follows --

-- zgenom: Files in $ZGEN_RESET_ON_CHANGE changed; resetting `init.zsh`...
-- zgenom: Deleting `/Users/brianduffey/.zgenom/sources/init.zsh` ...
-- zgenom: Deleting `/Users/brianduffey/.config/zsh/.zcompdump_5.8*` ...
-- zgenom: Creating `/Users/brianduffey/.zgenom/sources/init.zsh` ...
-- zgenom: Initializing completions ...
-- zgenom: Compiling files ...

I can potentially also help with a PR if there is interest in this kind of option. Let me know, thanks!

Fails to load if plugin name is different from repository

Not sure if that is actually something that should be handled, but for a couple of my plugins, zgenom complains about not being able to load them.

Cloning into '/home/.../.zgenom/sources/zdharma/history-search-multi-word/___'...
... done.
-- zgenom: Failed to load /home/.../.zgenom/sources/zdharma/history-search-multi-word/___ -- main

The reason is that these plugins do not have the same name as the repository.
For the given example the repository is named history-search-multi-word but the plugin itself is H-S-MW.plugin.zsh, which I suspect is the reason that zgenom cannot find and load it then.

I worked around this by forking the affected plugins and renaming the file to e.g. history-search-multi-word.plugin.zsh so they match the repo's name.

zgenom autoupdate/selfupdate fails with "fatal: bad object"

For some reason, autoupdate and selfupdate are failing to fetch this object and I get this error on both Linux and macOS.

~ ❯ zgenom selfupdate
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 14 (delta 10), reused 5 (delta 4), pack-reused 0
Unpacking objects: 100% (14/14), 1.66 KiB | 850.00 KiB/s, done.
fatal: bad object refs/remotes/origin/Breaking-Move-zgen-compatibility-into-zgen.zsh.zwc
error: https://github.com/jandamm/zgenom.git did not send all necessary objects

I was able to resolve this with:

~ ❯ mv refs/remotes/origin/Breaking-Move-zgen-compatibility-into-zgen.zsh.zwc ~/broken_ref.bak

Compiling does not work with aliases

Compiling fails when a function in a script is also an alias in the current interactive shell.
Therefore a new shell should be created where no aliases exist.

Relates to #28

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.