linux zsh終端 大目錄下 緩慢的問題?

使用的是 zsh下的 oh my zsh 項目 配置好之後 進入一些文件比較多的目錄就會 很卡頓 就是 cd 進去會卡很長的時間 打一個命令也要很久 是不是索引還是其他的問題 求助 不是老爺機 Intel Core i5-3470 CPU @ 3.6GHz

oh my zsh 默認的配置

.zshrc

# Path to your oh-my-zsh installation.
export ZSH=/home/sxx/.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="agnoster"

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="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="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
# 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"


可以檢查下是否只有在進入使用了git的目錄的時候才會這樣,如果是的話可以關閉git對status的檢查.

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

主要問題應該是使用了oh-my-zsh,其中

.oh-my-zsh/lib/git.zsh

這個腳本會調用git status,很可能會使得cd命令很慢.

可以把~/.oh-my-zsh/lib/git.zsh裡面的git_prompt_info函數替換為

function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2&> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_SUFFIX"
}


我回答錯問題了,

----------

原答案:https://www.zhihu.com/question/48157196/answer/157691961


上面說的已經很全了, 但是還是會卡。

有可能你的theme裡面有操作 git, 導致卡。

因為很多的theme的最後一欄 是當前的 git 分支名。


推薦閱讀:

學Linux內核的作用與方法?
利用iptables目標重寫巧妙變更遺留系統配置
淺談Windows 10中藏著的那個Linux
如果沒有Linux,IT業界會是怎樣的現狀?
遊戲伺服器運維疑惑?

TAG:Linux | 終端命令 | Bash |