删除每次 ZSH 运行时显示的消息(安装了 oh-my-zsh)

删除每次 ZSH 运行时显示的消息(安装了 oh-my-zsh)

我决定精简我的条目.zshrc并整理oh-my-zsh条目。看来zsh现在可以自动安装引用的插件并自动更新它们,这是我想要实现的目标。但是,每次运行终端时,我都会得到以下输出:

[zplug] Start to update 0 plugins in parallel


[zplug] Elapsed time: 0.0074 sec.
 ==> Updating finished successfully!

它当然是不需要的,我希望将其删除。

.zshrc这是我有条目的部分oh-my-zsh

# Check if zplug is installed
[ ! -d ~/.zplug ] && git clone https://github.com/zplug/zplug ~/.zplug
source ~/.zplug/init.zsh && zplug update

zplug 'zplug/zplug',    hook-build:'zplug --self-manage'
zplug "seebi/dircolors-solarized", ignore:"*", as:plugin
zplug "plugins/mvn",    from:oh-my-zsh
zplug "plugins/gradle", from:oh-my-zsh
zplug "plugins/git",    from:oh-my-zsh
zplug "plugins/sudo",   from:oh-my-zsh
zplug "plugins/dnf",    from:oh-my-zsh

# Supports checking out a specific branch/tag/commit
zplug "b4b4r07/enhancd", at:v1

# Support bitbucket
zplug "b4b4r07/hello_bitbucket", \
    from:bitbucket, \
    as:command, \
    use:"*.sh"

zplug "zsh-users/zsh-completions",              defer:0
zplug "zsh-users/zsh-autosuggestions",          defer:2, on:"zsh-users/zsh-completions"
zplug "zsh-users/zsh-syntax-highlighting",      defer:3, on:"zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-history-substring-search", defer:3, on:"zsh-users/zsh-syntax-highlighting"

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

# Then, source plugins and add commands to $PATH
zplug load

答案1

基于对代码的审查https://github.com/zplug/zplug,这些消息由 zplug 通过 printf 发送到 stdout,因此您可以通过更改此行来使它们静音:

source ~/.zplug/init.zsh && zplug update

对于这个:

source ~/.zplug/init.zsh && zplug update > /dev/null

要完全禁止更新,只需删除更新命令:

source ~/.zplug/init.zsh

相关内容