Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🐣 zsh plugin to cache eval loads to improve shell startup time

License

NotificationsYou must be signed in to change notification settings

mroth/evalcache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

zsh plugin to cache the output of a binary initialization command, intendedto help lower shell startup time.

What it does

There are lots of shell wrapper tools that follow the pattern of asking you toeval a specific init command in your shell startup, for example, rbenv asks:

eval "$(hub alias -s)"

While this is very convenient, the reality is there is a small amount ofoverhead associated with shelling out to this, and the output is almost alwaysactually static in all of the tools I know. So why bear this cost every timeyou open a new tab in your shell?

Instead, after you load this plugin, you can replace that same command with:

_evalcache hub alias -s

The first time this runs, it will cache the output of the command to a file,which will be sourced in the future instead when it exists.

If you update a tool and expect for some reason that it's initialization mighthave changed, you can simply clear the cache and it will be regenerated.

It also gracefully degrades to a no-op if the tool is no longer installed.

Benchmarks

Some informal benchmarks from my MacBook on my .zshrc:

commandwithoutfirst runsubsequent runssavings
rbenv init~65ms~65ms~8ms88%
hub alias~30ms~30ms~6ms80%
scmpuff init~24ms~25ms~10ms58%

The difference isn't huge, but can be handy in shaving down shell startup time,especially if you use a bunch of these tools. Every millisecond counts!

Options

  • $ZSH_EVALCACHE_DIR: cache files storage, default$HOME/.zsh-evalcache.
  • $ZSH_EVALCACHE_DISABLE: set totrue if you wish to bypass evalcache.

There is a convenience function to clear the cache called_evalcache_clear.

Installation

Addantigen bundle mroth/evalcache to your.zshrc with your other bundle commands.

Antigen will handle cloning the plugin for you automatically the next time you start zsh. You can also add the plugin to a running zsh withantigen bundle mroth/evalcache for testing before adding it to your.zshrc.

Fig adds apps, shortcuts, and autocomplete to your existing terminal.

Installevalcache in just one click.

  1. Clone this repository into$ZSH_CUSTOM/plugins (by default~/.oh-my-zsh/custom/plugins)

    git clone https://github.com/mroth/evalcache${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/evalcache
  2. Edit~/.zshrc to addevalcache to your plugin list,

    - plugins=(...)+ plugins=(... evalcache)

Addzgen load mroth/evalcache to your.zshrc file in the same function you're doing your otherzgen load calls in. Zgen will handle automatically cloning the plugin for you the next time you do azgen save.

About

🐣 zsh plugin to cache eval loads to improve shell startup time

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp