Mac下Terminal异常缓慢解决

屏幕快照 2016-08-14 下午3.30.14

前一阵我的Mac的终端突然变得异常缓慢,每次回车后的命令响应的特别慢,由于我使用了oh-my-zsh,所以一开始就怀疑是因为它的原因。

执行如下命令,退出zsh

bash -x

结果发现,一点都不慢了,哈哈,找到了问题的根源,但是究竟是oh-my-zsh哪里导致的呢?就一顿Google,不过大多数的解决方案都是执行如下命令,这样就不会每次执行命令时都判断git status了,不过问题依然没有解决。

git config --add oh-my-zsh.hide-status 1

所以,决定重装oh-my-zsh!

新建卸载脚本uninstallonmyzsh.sh

read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation
if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
  echo "Uninstall cancelled"
  exit
fi

echo "Removing ~/.oh-my-zsh"
if [ -d ~/.oh-my-zsh ]; then
  rm -rf ~/.oh-my-zsh
fi

echo "Looking for original zsh config..."
if [ -f ~/.zshrc.pre-oh-my-zsh ] || [ -h ~/.zshrc.pre-oh-my-zsh ]; then
  echo "Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc";

  if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
    ZSHRC_SAVE=".zshrc.omz-uninstalled-$(date +%Y%m%d%H%M%S)";
    echo "Found ~/.zshrc -- Renaming to ~/${ZSHRC_SAVE}";
    mv ~/.zshrc ~/"${ZSHRC_SAVE}";
  fi

  mv ~/.zshrc.pre-oh-my-zsh ~/.zshrc;

  echo "Your original zsh config was restored. Please restart your session."
else
  if hash chsh >/dev/null 2>&1; then
    echo "Switching back to bash"
    chsh -s /bin/bash
  else
    echo "You can edit /etc/passwd to switch your default shell back to bash"
  fi
fi

echo "Thanks for trying out Oh My Zsh. It's been uninstalled."

执行卸载脚本uninstallonmyzsh.sh

sh uninstallonmyzsh.sh

安装oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

报错了?
安装时如果出现:git: error: unable to find utility “git”

xcode-select --print-path
//如果执行结果是/Applications/Xcode.app/Contents/Developer,再次执行下面的命令即可
sudo xcode-select --switch /Library/Developer/CommandLineTools

导致这个问题的原因是Xcode无法找到自己的命令行工具。

Mac下Terminal异常缓慢解决
Tags:         

发表评论

电子邮件地址不会被公开。 必填项已用*标注