Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/QuarticCat/zsh-smartcache
A Zsh plugin to cache command output to boost shell startup.
https://github.com/QuarticCat/zsh-smartcache
Last synced: about 2 months ago
JSON representation
A Zsh plugin to cache command output to boost shell startup.
- Host: GitHub
- URL: https://github.com/QuarticCat/zsh-smartcache
- Owner: QuarticCat
- License: mit
- Created: 2022-06-10T11:39:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-15T11:04:29.000Z (3 months ago)
- Last Synced: 2024-04-11T15:02:42.056Z (about 2 months ago)
- Language: Shell
- Homepage:
- Size: 11.7 KB
- Stars: 25
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-zsh-plugins - smartcache - Caches command output to speed up shell startup time. (Plugins / ZSH on Windows)
- awesome-stars - QuarticCat/zsh-smartcache - `★26` A Zsh plugin to cache command output to boost shell startup. (Shell)
- fucking-awesome-zsh-plugins - smartcache - Caches command output to speed up shell startup time. (Plugins / ZSH on Windows)
- fucking-awesome-zsh-plugins - smartcache - Caches command output to speed up shell startup time. (Plugins / ZSH on Windows)
- awesome-zsh-plugins - smartcache - Caches command output to speed up shell startup time. (Plugins / ZSH on Windows)
README
# zsh-smartcache
A Zsh plugin to cache command output to boost shell startup.
## What it does
It basically has the same functionality as [evalcache](https://github.com/mroth/evalcache), except that
- It will automatically update the cache and inform you, while evalcache will never update the cache until you clear them. This operation is done in the background, so it has no effect on the satrtup time.
- It also supports caching completions. (experimental)## Benchmark
Here are some benchmark results. (CPU: Ryzen 3700X)
Benchmarked by `hyperfine 'zsh -ic exit'` and comparing the differences.
| command | version | raw eval | zsh-smartcache | evalcache |
| :-----: | :-----: | -------: | -------------: | --------: |
| `rbenv init` | 1.2.0 | ~48ms | ~23.5ms | ~23.5ms |
| `hub alias` | 2.14.2 | ~2.5ms | ~1.5ms | ~1.5ms |
| `scmpuff init` | 0.5.0 | ~2.5ms | ~2ms | ~2ms |Some changes from evalcache's results:
- Only the subsequent runs are recorded. The first run has a fixed extra cost (~1ms) on the MD5 hash computation.
- Speedup of `rbenv init` is much lower, since the command output now includes `rbenv` calls, which are super slow.
- `hub alias` and `scmpuff init` are superfast now.## Usage
### Eval
```zsh
eval "$(rbenv init -)"
# change to
smartcache eval rbenv init -
```### Completion
```zsh
rustup completions zsh > ~/.zfunc/_rustup
fpath+=~/.zfunc
# change to
smartcache comp rustup completions zsh
```## Configuration
- `ZSH_SMARTCACHE_DIR`: cache files storage, default to `${XDG_CACHE_HOME:-$HOME/.cache}/zsh-smartcache`.