Reputation: 2722
I've noticed that there is a small but noticeable delay when I execute simple commands like ls and cd in the terminal. Can anyone tell me how to go about troubleshooting this problem? I really don't know where to start.
Upvotes: 0
Views: 2114
Reputation: 27340
Summary of the discussion in the comments:
At each prompt you are executing the command __git_ps1
which creates a small delay. The time needed to execute __git_ps1
depends on your git
configuration and your current working directory.
To get a faster prompt you could
__git_ps1
to run faster (probably not a real option).__git_ps1
.__git_ps1
is used only if it's not too slow (see following section).__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).In bash
the command timeout n cmd
executes cmd
for at most n
seconds. 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.
Upvotes: 1