]> git.madduck.net Git - etc/zsh.git/blob - .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
1 # zshrc/75_vcsinfo
2 #
3 # Set up vcs_info subsystem
4 #
5 # Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
6 # Released under the terms of the Artistic Licence 2.0
7 #
8 # Source repository: git://git.madduck.net/etc/zsh.git
9 #
10
11 # see zsh-betacontrib(1)
12
13 autoload -Uz vcs_info
14
15 #       %s     The vcs in use (git, hg, svn etc.)
16 #       %b     Information about the current branch.
17 #       %a     An identifier, that describes the action. Only makes sense in actionformats.
18 #       %i     The current revision number or identifier.
19 #       %c     The string from the stagedstr style if there are staged changes in the repository.
20 #       %u     The string from the unstagedstr style if there are unstaged changes in the repository.
21 #       %R     base directory of the repository.
22 #       %r     repository name. If %R is /foo/bar/repoXY, %r is repoXY.
23 #       %S     subdirectory  within  a  repository.  If  $PWD  is  /foo/bar/reposXY/beer/tasty,  %S  is
24 #              beer/tasty.
25 #       %m     A  "misc"  replacement.  It  is  at  the  discretion  of the backend to decide what this
26 #              replacement expands to. It is currently used only by the  hg  backend.  The  hg  backend
27 #              replaces %m with the global hash value of the current revision.
28
29 zstyle ':vcs_info:*' disable cdv darcs mtn svk p4 tla
30 zstyle ':vcs_info:*' check-for-changes true
31 zstyle ':vcs_info:*' max-exports 6
32 zstyle ':vcs_info:*' formats       '%R' '%s' '%b' ''   '%c%u' '%S'
33 zstyle ':vcs_info:*' actionformats '%R' '%s' '%b' '%a' '%c%u' '%S'
34
35 __vcs_info_precmd() {
36   vcs_info
37
38   local prefix="${vcs_info_msg_0_/$HOME/~}"
39   local suffix="$vcs_info_msg_5_"
40   [[ $suffix = . ]] && suffix=''
41
42   local type="$vcs_info_msg_1_"
43   [[ $type = git ]] && type=''
44   local branch="$vcs_info_msg_2_"
45   local action="$vcs_info_msg_3_"
46   local changes="$vcs_info_msg_4_"
47   local vcsinfo="${type:+${type}:}%B${branch}%b${action:+|%B${action}%b}"
48
49   _make_ps1 "$prefix|$vcsinfo|$suffix${changes:+|%S${changes}%s}"
50 }
51 precmd_functions+=__vcs_info_precmd