Cygwin 如何在windows上提高babun中zsh的加载时间?
我喜欢ZSH外壳和它的主题,但它非常慢。加载需要7到10秒。我还将其用作VS代码中的集成终端,尽管加载速度很慢。这是我的Cygwin 如何在windows上提高babun中zsh的加载时间?,cygwin,zsh,oh-my-zsh,zshrc,babun,Cygwin,Zsh,Oh My Zsh,Zshrc,Babun,我喜欢ZSH外壳和它的主题,但它非常慢。加载需要7到10秒。我还将其用作VS代码中的集成终端,尽管加载速度很慢。这是我的.zshrc文件的副本 # Path to your oh-my-zsh installation. export ZSH=$HOME/.oh-my-zsh export PS1="[%* - %D] %d %% " # Set name of the theme to load. # Look in ~/.oh-my-zsh/themes/ # Optionally,
.zshrc
文件的副本
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
export PS1="[%* - %D] %d %% "
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
DEFAULT_USER=13000
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for
completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked
files
# under VCS as dirty. This makes repository status check for large
repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution
time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-
zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
# User configuration
export PATH=$HOME/bin:/usr/local/bin:$PATH
# export MANPATH="/usr/local/man:$MANPATH"
source $ZSH/oh-my-zsh.sh
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
prompt_dir() {
prompt_segment blue black "${PWD##*/}"
}
编辑::我在我的cygwin目录中找到了2ohmyzsh.sh
文件,下面是这两个文件
第一个
# Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f
$ZSH/tools/check_for_upgrade.sh
fi
# Initializes Oh My Zsh
# add a function path
fpath=($ZSH/functions $ZSH/completions $fpath)
# Load all stock functions (from $fpath files) called below.
autoload -U compaudit compinit
: ${ZSH_DISABLE_COMPFIX:=true}
# Set ZSH_CUSTOM to the path where your custom config files
# and plugins exists, or else we will use the default custom/
if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom"
fi
# Set ZSH_CACHE_DIR to the path where cache files should be created
# or else we will use the default cache/
if [[ -z "$ZSH_CACHE_DIR" ]]; then
ZSH_CACHE_DIR="$ZSH/cache"
fi
# Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh); do
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
[ -f "${custom_config_file}" ] && config_file=${custom_config_file}
source $config_file
done
is_plugin() {
local base_dir=$1
local name=$2
test -f $base_dir/plugins/$name/$name.plugin.zsh \
|| test -f $base_dir/plugins/$name/_$name
}
# Add all defined plugins to fpath. This must be done
# before running compinit.
for plugin ($plugins); do
if is_plugin $ZSH_CUSTOM $plugin; then
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
elif is_plugin $ZSH $plugin; then
fpath=($ZSH/plugins/$plugin $fpath)
fi
done
# Figure out the SHORT hostname
if [[ "$OSTYPE" = darwin* ]]; then
# macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) ||
SHORT_HOST=${HOST/.*/}
else
SHORT_HOST=${HOST/.*/}
fi
# Save the location of the current completion dump file.
if [ -z "$ZSH_COMPDUMP" ]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
# If completion insecurities exist, warn the user without enabling
completions.
if ! compaudit &>/dev/null; then
# This function resides in the "lib/compfix.zsh" script sourced above.
handle_completion_insecurities
# Else, enable and cache completions to the desired file.
else
compinit -d "${ZSH_COMPDUMP}"
fi
else
compinit -i -d "${ZSH_COMPDUMP}"
fi
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
fi
done
# Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
source $config_file
done
unset config_file
# Load the theme
if [ "$ZSH_THEME" = "random" ]; then
themes=($ZSH/themes/*zsh-theme)
N=${#themes[@]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else
if [ ! "$ZSH_THEME" = "" ]; then
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
fi
fi
第二个是
# Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f
$ZSH/tools/check_for_upgrade.sh
fi
# Initializes Oh My Zsh
# add a function path
fpath=($ZSH/functions $ZSH/completions $fpath)
# Set ZSH_CUSTOM to the path where your custom config files
# and plugins exists, or else we will use the default custom/
if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom"
fi
# Set ZSH_CACHE_DIR to the path where cache files should be created
# or else we will use the default cache/
if [[ -z "$ZSH_CACHE_DIR" ]]; then
ZSH_CACHE_DIR="$ZSH/cache/"
fi
# Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh); do
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
[ -f "${custom_config_file}" ] && config_file=${custom_config_file}
source $config_file
done
# Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
source $config_file
done
unset config_file
is_plugin() {
local base_dir=$1
local name=$2
test -f $base_dir/plugins/$name/$name.plugin.zsh \
|| test -f $base_dir/plugins/$name/_$name
}
# Add all defined plugins to fpath. This must be done
# before running compinit.
for plugin ($plugins); do
if is_plugin $ZSH_CUSTOM $plugin; then
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
elif is_plugin $ZSH $plugin; then
fpath=($ZSH/plugins/$plugin $fpath)
fi
done
# Figure out the SHORT hostname
if [[ "$OSTYPE" = darwin* ]]; then
# OS X's $HOST changes with dhcp, etc. Use ComputerName if possible.
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) ||
SHORT_HOST=${HOST/.*/}
else
SHORT_HOST=${HOST/.*/}
fi
# Save the location of the current completion dump file.
if [ -z "$ZSH_COMPDUMP" ]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi
# Load and run compinit
autoload -U compinit
compinit -i -d "${ZSH_COMPDUMP}"
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
fi
done
# Load the theme
if [ "$ZSH_THEME" = "random" ]; then
themes=($ZSH/themes/*zsh-theme)
N=${#themes[@]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else
if [ ! "$ZSH_THEME" = "" ]; then
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
fi
fi
不要介意长的post:D.通常长的加载时间会导致shell使用框架。
- 您可以尝试另一个更小的框架:
- 您可以尝试找出哪些插件/工具在运行时花费的时间最多
$zsh-xv
它将输出运行时加载的内容。您可以看到哪个插件/进程需要最长的时间来加载和响应
你还尝试过清理asl文件吗?
我已在Windows 10计算机上安装了babun 禁用bash自动完成作业稍微缩短了我的加载时间。我将所有文件重命名为“bash_completion.d”目录中的“.bk”扩展名
{ ~ } » ls -ltr /etc/bash_completion.d ~
total 68
-rwxrwx---+ 1 m.ortiz.montealegre Domain Users 998 Jun 23 2015 vim-completion.bk
-rwxrwx---+ 1 m.ortiz.montealegre Domain Users 44924 Jun 23 2015 svn.bk
-rwxrwx---+ 1 m.ortiz.montealegre Domain Users 1200 Jun 23 2015 gvim-completion.bk
-rwxrwx---+ 1 m.ortiz.montealegre Domain Users 2609 Jun 23 2015 gsettings.bk
-rwxrwx---+ 1 m.ortiz.montealegre Domain Users 1356 Jun 23 2015 gresource.bk
-rwxrwx---+ 1 m.ortiz.montealegre Domain Users 935 Jun 23 2015 gdbus.bk
-rwxrwx---+ 1 m.ortiz.montealegre Domain Users 1389 Jun 23 2015 gapplication.bk
另外,使用strace进行调试是一个很好的选择,可以查看Cygwin加载时发生的情况,请检查此项
编辑:
关于巴朋调整的信息
babun网站上记录了一个可用于检查安装的工具,请使用babun check也许这会为您提供一些线索:
{ ~ } » babun check ~
Executing babun check
Prompt speed [SLOW]
Hint: your prompt is very slow. Check the installed 'BLODA' software.
Connection check [OK]
Update check [OK]
Cygwin check [OK]
我不知道您是否在babun安装中执行了一些调整,请检查您的~/.babunc文件,并验证您是否已禁用自动更新和启动检查(不启用它们):
关于Cygwin
有几个调整,如果您不喜欢使用Strace调试,您可以探索Cygwin
我认为您应该抽象出“babun”的概念,不要忘记嵌入式Cygwin,我认为这才是真正需要加速的,babun核心是一个Cygwin实现,有一些变化:
Babun的核心由预配置的Cygwin组成
运行
zsh-xv
命令,观看详细的输出,就像看电视一样(不要用鼠标和按键干扰)。此时,详细的输出速度会变慢,如果可能,请删除该插件或检查bug。然后运行source.zshrc
。再次启动详细输出。启动一个新的shell窗口。你会明白加载速度越来越快
我说的是慢哦,我的ZSH/ZSH部分。我不是Windows用户,您应该排除任何与Windows相关的独家事宜。有了自制的iTerm,这些小问题就成了常规问题。哦,我的ZSH,有漂亮的东西,在Mac上加载插件、主题,速度慢得可怜。没什么新鲜事。你可以搜索整个互联网,你会发现很多Mac用户&慢啊,我的ZSH。您需要在windows上使用慢速ZSH或Oh My ZSH not slow babun搜索问题。使用Oh My ZSH的Mac用户数量要高得多。另外还有GNU/Linux用户
和。所有的修复都是为了稍微加快速度
所有这些都将为您提供有关通用的说明,比如我们将说使禁用\u AUTO\u UPDATE=“true”
处于活动状态,ZSH历史记录大小变小等等。运行:
cd ~
export HISTSIZE=2000
export HISTFILE="$HOME/.history"
export SAVEHIST=$HISTSIZE
setopt hist_ignore_all_dups
# reload once
source .zshrc
# check
cat .history
你能编辑你的文章,包括$ZSH/oh my ZSH的内容吗。sh@mikep我找到了2个
ohmyzsh.sh
文件。它有许多共同点。这两个都在上面的帖子中给出。谢谢。狒狒在室外比(未集成)跑得快吗?或者是同一时间。@Miguelotiz在VS中速度更慢,比如一秒或两秒。在VS外部正常运行通常需要7秒,在VS中需要8-9秒。bash自动完成是我使用的主要功能之一。这是我爱巴邦的主要原因之一。正在禁用这是一个否:)。还有其他建议吗?请别逗我:D.谢谢!跑着的斯特拉斯给了我这么大的一根木头。我必须滚动23次才能到达顶部。我该怎么办?我还尝试将bash completion.d
中的每个文件重命名为.bak
扩展名。加载时间仍然相同。Pramesh,strace允许您查看所有系统调用。调试该日志您可以找到在您的环境中加载的内容,并禁用或改进耗时过长的内容。Strace日志太长了。调试它可能需要3-4天,但我迟早会尝试的。还有别的办法吗?谢谢你的帮助。使用抗原没有什么好处。装载时间几乎相同。早些时候,它花了大约7秒。抗原之后也是一样的。还使用了zsh-rv
给了我一个巨大的日志,我对此一无所知。asl
清除是针对mac操作系统的,我想这对我不起作用。谢谢你还有什么建议吗?我会尝试一切:你是否使用了抗原并移除了我的zsh?通常,开始时间至少应该很快。其他贝壳怎么样?猛击?他们快吗?试试https://github.com/getantibody/antibody因为抗原速度太慢,所以写了
。我的其他shell,如cmd、git bash
都很快。我的慢shell是windows上的Bash和使用oh My zsh的Babun。那么Bash也慢吗?zsh没有哦,我的zsh
也很慢吗?你试过抗体了吗?你试过“巴邦”主题吗?巴什比自己的很快。当使用oh my zsh进行介绍时,速度很慢。您提供的链接是我已经没有运气通过的链接。在调试模式下运行zsh
ie.zsh-xv
在不到一秒钟的时间内给了我一个巨大的日志。我该怎么办?在您提供的链接中,建议您查看终端冻结的位置,但我的完全不冻结。我也执行了你提供的命令。我会告诉你是否注意到了装载时间的减少。非常感谢。同样,你是对的,所有花哨的主题和插件zsh
肯定会很慢,而且有很多关于它的帖子。但是那些帖子都是关于Linux和MAC的
cd ~
export HISTSIZE=2000
export HISTFILE="$HOME/.history"
export SAVEHIST=$HISTSIZE
setopt hist_ignore_all_dups
# reload once
source .zshrc
# check
cat .history