Skip to content

Commit

Permalink
blog commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yaragos committed Aug 1, 2024
1 parent 5a35aa2 commit 2c5be4c
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
Binary file added content/post/6/cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/post/6/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions content/post/6/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: 'zsh插件管理器:从zplug转到zinit'
date: 2024-08-01T18:09:12+08:00
slug: "zsh-plugin-manager-from-zplug-to-zinit"
image: "cover.jpg"
tags:
- zsh
categories:
- Linux
description: "zinit是真快,但配置是真难。"
---

> 好久之前就使用的是zplug管理zsh插件,为了追求速度,打算使用zinit。
## 配置

我在zinit中多配置了一些插件,配置语法我目前也是一知半解,反正能用就行,我也不知道怎么更快,以后慢慢了解。

- zinit 配置

```zsh
# # ------------>>> zinit <<<-------------
### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
print -P "%F{33} %F{34}Installation successful.%f%b" || \
print -P "%F{160} The clone has failed.%f%b"
fi

source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zdharma-continuum/zinit-annex-as-monitor \
zdharma-continuum/zinit-annex-bin-gem-node \
zdharma-continuum/zinit-annex-patch-dl \
zdharma-continuum/zinit-annex-rust
# 语法高亮
zinit ice lucid wait='0'
zinit light zsh-users/zsh-syntax-highlighting
# 自动建议 && 补全
zinit ice lucid wait="0" atload='_zsh_autosuggest_start'
zinit light zsh-users/zsh-autosuggestions
zinit ice lucid
zinit light zsh-users/zsh-history-substring-search
zinit ice lucid blockf
zinit light zsh-users/zsh-completions
zinit light Aloxaf/fzf-tab
# OMZ
zinit snippet OMZ::lib/completion.zsh
zinit snippet OMZ::lib/history.zsh
zinit snippet OMZ::lib/key-bindings.zsh
zinit snippet OMZ::lib/theme-and-appearance.zsh
zinit snippet OMZ::plugins/colored-man-pages/colored-man-pages.plugin.zsh
zinit snippet OMZ::plugins/sudo/sudo.plugin.zsh
zinit ice lucid wait='1'
zinit snippet OMZ::plugins/git/git.plugin.zsh
# theme
zinit snippet OMZ::lib/git.zsh
zinit snippet OMZ::lib/async_prompt.zsh
zinit snippet OMZ::plugins/svn/svn.plugin.zsh
zinit snippet OMZ::themes/ys.zsh-theme
```

- zplug 配置

```zsh
# ------------>>> zplug <<<-------------
if [[ ! -d ~/.zplug ]];then
git clone https://github.com/b4b4r07/zplug.git ~/.zplug
source ~/.zplug/zplug
zplug update --self
fi
source ~/.zplug/init.zsh

zplug "plugins/svn", from:oh-my-zsh
zplug "themes/ys", from:oh-my-zsh

zplug "lib/history", from:oh-my-zsh
zplug "zsh-users/zsh-completions"
zplug "zsh-users/zsh-autosuggestions", as:plugin
zplug "zsh-users/zsh-syntax-highlighting", as:plugin, defer:2
zplug "zsh-users/zsh-history-substring-search", as:plugin, defer:3

# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install zplug plugins? [y/N]: "
if read -q; then
echo; zplug install
fi
fi

zplug load
```

## 对比

<img src="image.png" style="zoom:80%;align:center;">

对比发现,zinit虽然加载了更多插件,但启动速度稳定在0.2秒左右,而zplug则在0.5秒左右。

0 comments on commit 2c5be4c

Please sign in to comment.