]> git.madduck.net Git - etc/zsh.git/blobdiff - .zsh/zshrc/75_vcsinfo

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

first attempt to use vcs_info
[etc/zsh.git] / .zsh / zshrc / 75_vcsinfo
index 5592fc1d910d1396337ea230ec36bcc6c73f2273..fb7bb74dcc9893eb1ffab12769749e5b6bdd04b8 100644 (file)
 
 autoload -Uz vcs_info
 
-zstyle ':vcs_info:*' actionformats \
-    '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
-zstyle ':vcs_info:*' formats       \
-    '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
-zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
-
-#PS1=’%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_}’"%f%# ’
+#       %s     The vcs in use (git, hg, svn etc.)
+#       %b     Information about the current branch.
+#       %a     An identifier, that describes the action. Only makes sense in actionformats.
+#       %i     The current revision number or identifier.
+#       %c     The string from the stagedstr style if there are staged changes in the repository.
+#       %u     The string from the unstagedstr style if there are unstaged changes in the repository.
+#       %R     base directory of the repository.
+#       %r     repository name. If %R is /foo/bar/repoXY, %r is repoXY.
+#       %S     subdirectory  within  a  repository.  If  $PWD  is  /foo/bar/reposXY/beer/tasty,  %S  is
+#              beer/tasty.
+#       %m     A  "misc"  replacement.  It  is  at  the  discretion  of the backend to decide what this
+#              replacement expands to. It is currently used only by the  hg  backend.  The  hg  backend
+#              replaces %m with the global hash value of the current revision.
 
 zstyle ':vcs_info:*' disable cdv darcs mtn svk p4 tla
+zstyle ':vcs_info:*' check-for-changes true
+zstyle ':vcs_info:*' max-exports 6
+zstyle ':vcs_info:*' formats       '%R' '%s' '%b' ''   '%c%u' '%S'
+zstyle ':vcs_info:*' actionformats '%R' '%s' '%b' '%a' '%c%u' '%S'
+
+__vcs_info_precmd() {
+  vcs_info
+
+  local prefix="${vcs_info_msg_0_/$HOME/~}"
+  local suffix="$vcs_info_msg_5_"
+  [[ $suffix = . ]] && suffix=''
+
+  local type="$vcs_info_msg_1_"
+  [[ $type = git ]] && type=''
+  local branch="$vcs_info_msg_2_"
+  local action="$vcs_info_msg_3_"
+  local changes="$vcs_info_msg_4_"
+  local vcsinfo="${type:+${type}:}%B${branch}%b${action:+|%B${action}%b}"
 
-#this enables vcs_info
-#precmd_functions+=vcs_info
+  _make_ps1 "$prefix|$vcsinfo|$suffix${changes:+|%S${changes}%s}"
+}
+precmd_functions+=__vcs_info_precmd