From 731f43e22b6a2d1dd24fc4edd97430b9f5d672f1 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 29 Mar 2015 21:42:28 +0200 Subject: [PATCH] Show revision-Changeset, if POWERLEVEL9K_SHOW_CHANGESET is enabled. --- README.md | 6 +++++- powerlevel9k.zsh-theme | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fd89cc81..2aefc839 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,11 @@ To specify which segments you want, just add the following variables to your POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) +If you want to show the current changeset, enable `POWERLEVEL9K_SHOW_CHANGESET` +in your `~/.zshrc`: + + POWERLEVEL9K_SHOW_CHANGESET=true + #### Conditional 'context' The `context` segment (user@host string) is conditional. This lets you enable it, but only display @@ -88,7 +93,6 @@ elements (it is by default), and define a `DEFAULT_USER` in your `~/.zshrc`: export DEFAULT_USER= - ### Bugs / Contact If you have any requests or bug reports, please use the tracker in this Github diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 83d55e8f..cdb04d8a 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -32,16 +32,21 @@ VCS_STAGED_ICON='✚' # vcs_info settings for git ################################################################ -local VCS_WORKDIR_DIRTY=false setopt prompt_subst autoload -Uz vcs_info +local VCS_WORKDIR_DIRTY=false +local VCS_CHANGESET_PREFIX='' +if ( $POWERLEVEL9K_SHOW_CHANGESET ); then + VCS_CHANGESET_PREFIX='%12.12i@' +fi + zstyle ':vcs_info:*' enable git hg # The `get-revision` function must be turned on for dirty-check to work for Hg zstyle ':vcs_info:*' get-revision true zstyle ':vcs_info:*' check-for-changes true -zstyle ':vcs_info:*' formats "%b%c%u%m" +zstyle ':vcs_info:*' formats " $VCS_CHANGESET_PREFIX%b%c%u%m" zstyle ':vcs_info:*' actionformats "%b %F{red}| %a%f" zstyle ':vcs_info:*' stagedstr " %F{black}$VCS_STAGED_ICON%f" @@ -52,6 +57,14 @@ zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-aheadbehind git-re # For Hg, only show the branch name (as opposed to the rev) zstyle ':vcs_info:hg*:*' branchformat "%b" +if ( $POWERLEVEL9K_SHOW_CHANGESET ); then + zstyle ':vcs_info:*' get-revision true # If false, the dirty-check won't work in mercurial +else + # A little performance-boost (at least for mercurial). If we don't show + # the changeset, we can switch to simple mode. + zstyle ':vcs_info:*' use-simple true +fi + ## Debugging #zstyle ':vcs_info:*+*:*' debug true