That prompt can be really slow, as it runs `__git_ps1` multiple times (through several branches of the conditional, and then for the final output). On my git.git repository, running `time __git_ps1` takes about .085s. If I hit the "cyan" condition in the prompt, we run it three times, and doing `time eval "echo \"$PS1"\""` takes about 0.263s, which feels noticeably laggy.
Changing it to cache the result, like this:
export PS1=$LIGHT_GRAY"\u@\h"'$(
g=$(__git_ps1 " (%s)")
if [[ "$g" =~ \*\)$ ]]
then echo "'$YELLOW'$g"
elif [[ "$g" =~ \+\)$ ]]
then echo "'$MAGENTA'$g"
else echo "'$CYAN'$g"
fi)'$BLUE" \w"$GREEN": "
Speaking of git completion and branch info on the prompt, there are plugins in zsh for this and they're very easy to customize thanks to well-established conventions in oh-my-zsh.
It took me couple of hours to migrate from bash but it was time well spent.
fish shell has some of this built in, such as the git prompt.
Here's a sample of my fish_prompt.fish
function fish_prompt
set last_status $status
set_color $fish_color_cwd
printf '%s' (prompt_pwd)
set_color normal
printf '%s ' (__fish_git_prompt)
set_color normal
end
Comments
Couple typos:
"In the git-completion.bash file" should be "In the .git-completion.bash file"
"In the git-prompt.sh file" should be "In the .git-prompt.sh file"
Updating the permissions is not necessary.
Step 4 should also include adding
Step 5 you can add "Run . ~/.bash_profile" or "close and re-launch your terminal"Thanks for the tips!
That prompt can be really slow, as it runs `__git_ps1` multiple times (through several branches of the conditional, and then for the final output). On my git.git repository, running `time __git_ps1` takes about .085s. If I hit the "cyan" condition in the prompt, we run it three times, and doing `time eval "echo \"$PS1"\""` takes about 0.263s, which feels noticeably laggy.
Changing it to cache the result, like this:
drops it back down to the .085s range.I have a couple other suggestions:
1. Put your dotfiles in GitHub
2. Consider using zsh -- the completion is great, and it's easy to build a great prompt. I know prompts are personal taste, but I'm enjoying mine: https://github.com/hoov/dotfiles/blob/master/zsh/prompts/pro...
I'd also look at Mathias Bynens dotfiles repo.
https://github.com/mathiasbynens/dotfiles
Just use zsh with oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh). Done.
Just wanted to say that. I hesitated for months before switching to zsh but here's a short presentation that sold me: http://www.slideshare.net/jaguardesignstudio/why-zsh-is-cool...
Speaking of git completion and branch info on the prompt, there are plugins in zsh for this and they're very easy to customize thanks to well-established conventions in oh-my-zsh.
It took me couple of hours to migrate from bash but it was time well spent.
Additionally to GIT_PS1_SHOWDIRTYSTATE the following are useful
fish shell has some of this built in, such as the git prompt.
Here's a sample of my fish_prompt.fish