[英]Small delay when executing MacOS terminal commands
I've noticed that there is a small but noticeable delay when I execute simple commands like ls and cd in the terminal. 我注意到在终端中执行ls和cd之类的简单命令时,会有很小但明显的延迟。 Can anyone tell me how to go about troubleshooting this problem?
谁能告诉我如何解决此问题? I really don't know where to start.
我真的不知道从哪里开始。
Summary of the discussion in the comments: 评论中的讨论摘要:
At each prompt you are executing the command __git_ps1
which creates a small delay. 在每个提示符下,您正在执行
__git_ps1
命令,这会产生一个小的延迟。 The time needed to execute __git_ps1
depends on your git
configuration and your current working directory. 执行
__git_ps1
所需的时间取决于您的git
配置和当前工作目录。
To get a faster prompt you could 为了获得更快的提示,您可以
__git_ps1
to run faster (probably not a real option). __git_ps1
使其运行得更快(可能不是真正的选择)。 __git_ps1
. __git_ps1
给出的所有信息。 __git_ps1
is used only if it's not too slow (see following section). __git_ps1
不太慢时才使用(请参阅下一节)。 __git_ps1
only when something changes (not explained here since you would have to identify all commands that could change the output of __git_ps1). __git_ps1
(此处不做解释,因为您将必须识别所有可能更改__git_ps1输出的命令)。 In bash
the command timeout n cmd
executes cmd
for at most n
seconds. 在
bash
,命令timeout n cmd
最多执行cmd
n
秒。 When used in your prompt 在提示中使用时
PS1="[\\u@\\h \\W\$(__git_ps1 \" (%s)\")]\\\$ "
becomes 变
PS1="[\\u@\\h \\W\$(timeout 0.2 __git_ps1 \" (%s)\")]\\\$ "
You can adjust the timeout to your needs. 您可以根据需要调整超时时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.