![如何检查是什么导致我的终端启动速度变慢?](https://linux22.com/image/1320755/%E5%A6%82%E4%BD%95%E6%A3%80%E6%9F%A5%E6%98%AF%E4%BB%80%E4%B9%88%E5%AF%BC%E8%87%B4%E6%88%91%E7%9A%84%E7%BB%88%E7%AB%AF%E5%90%AF%E5%8A%A8%E9%80%9F%E5%BA%A6%E5%8F%98%E6%85%A2%EF%BC%9F.png)
有没有办法检查是什么导致我的终端启动速度变慢?我在 iTerm2 上使用 zsh 和 ohmyzsh。
打开新窗口大约需要 10 秒钟 :(
这是我的 zshrc 文件:
export PATH=/usr/local/mysql/bin:$PATH
export PATH=$HOME/bin:$PATH
export PATH=$PATH:/usr/local/git/bin/
export HISTFILESIZE=5000
export PYTHONPATH="/usr/local/lib/python2.7/site-packages/:$PYTHONPATH"
#alias ls="ls -G"
export NODE_PATH="/usr/local/lib/node"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/share/npm/bin:$PATH"
#svndiff() {
# svn diff $1 | colordiff.pl
#}
#hgdiff() {
# hg diff $1 | colordiff.pl
#}
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
#PS1="$prompt_style"'${debian_chroot:+($debian_chroot)}\u@\h:\W\$'"$command_style "
#trap 'echo -ne "\033[00m"' DEBUG
export LANG="it_IT.UTF-8"
export LC_COLLATE="it_IT.UTF-8"
export LC_CTYPE="it_IT.UTF-8"
export LC_MESSAGES="it_IT.UTF-8"
export LC_MONETARY="it_IT.UTF-8"
export LC_NUMERIC="it_IT.UTF-8"
export LC_TIME="it_IT.UTF-8"
export LC_ALL=
#export CURL_CA_BUNDLE="$HOME/.curl/cacert.pem"
#Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# 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="cypher"
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"
# 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)
plugins=(fab osx pip django)
source $ZSH/oh-my-zsh.sh
# Customize to your needs...
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/share/npm/bin:/Users/patrick/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin/:$PATH
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
alias serve="python -m SimpleHTTPServer"
alias adb="~/Documents/android-sdk-macosx/platform-tools/adb"
alias fastboot="~/Documents/android-sdk-macosx/platform-tools/fastboot"
是的,有很多东西,你能帮我检查一下哪个是问题的原因吗?
谢谢 :)
答案1
您是否尝试过删除 Apple 系统日志?
http://ariejan.net/2011/11/08/fixing-a-slow-starting-terminal-or-iterm2-on-mac-os-x/
如果这不能解决问题,请将你的 zshrc 移到一边mv .zshrc zshrc.testing
,如果这样可以加快速度,请注释掉每一行,然后慢慢地逐行取消注释,直到你看到是什么减慢了速度。
答案2
使用 iTerm2,您可以通过设置来跟踪初始化
Preferences -> Profiles -> [Your Profile, or Default] -> General -> Command
来自“Login Shell”。至:
/bin/zsh -i -x
-x 将在显示提示之前显示 .zshrc (和 /etc/profile)正在运行的命令。
使用 iTerm2 日志记录,您可以记录每个命令及其运行的时间,并大致了解哪些命令占用了大部分时间。