summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Degenhardt <bdegenhardt@twitter.com>2015-07-27 14:19:23 -0700
committerBrian Degenhardt <bdegenhardt@twitter.com>2015-07-27 14:19:23 -0700
commitb875df8970a67d02eef74f1aad0b60f42fedb356 (patch)
tree66463a5b8a1d268805aa06616b4a86216871d387
parenta207a38d634cc10441636bc4359cd8a18c502dea (diff)
downloadzsh-b875df8970a67d02eef74f1aad0b60f42fedb356.tar.gz
zsh-b875df8970a67d02eef74f1aad0b60f42fedb356.tar.bz2
zsh-b875df8970a67d02eef74f1aad0b60f42fedb356.zip
agnoster: speed up git prompt
Problem On detached-refs, the git prompt is very slow because it uses a command to output all refs, which takes 32s on the twitter internal git repo. Solution Use git-rev-parse instead of git-show-ref to only output the head ref. Runtime drops to 0.03 seconds. Note Interestingly, git-rev-parse isn't slow without the --head arguement so I'll probably be cooking up a patch for the git team to speed this up eventually, but it's still pointless to sigpipe git as it walks the filesystem.
-rw-r--r--themes/agnoster.zsh-theme2
1 files changed, 1 insertions, 1 deletions
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index 3a0c58b89..ee0c2afb8 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -78,7 +78,7 @@ prompt_git() {
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
dirty=$(parse_git_dirty)
- ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
+ ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment yellow black
else