1# `svn` plugin
2
3This plugin adds some utility functions to display additional information regarding your current
4svn repository. See https://subversion.apache.org/ for the full svn documentation.
5
6To use it, add `svn` to your plugins array:
7
8```zsh
9plugins=(... svn)
10```
11
12## Functions
13
14| Command               | Description                                 |
15|:----------------------|:--------------------------------------------|
16| `svn_prompt_info`     | Shows svn prompt in themes                  |
17| `in_svn`              | Checks if we're in an svn repository        |
18| `svn_get_repo_name`   | Get repository name                         |
19| `svn_get_branch_name` | Get branch name (see [caveats](#caveats))   |
20| `svn_get_rev_nr`      | Get revision number                         |
21| `svn_dirty`           | Checks if there are changes in the svn repo |
22
23## Caveats
24
25The plugin expects the first directory to be the current branch / tag / trunk. So it returns
26the first path element if you don't use branches.
27
28## Usage on themes
29
30To use this in the `agnoster` theme follow these instructions:
31
321. Enable the svn plugin
33
342. Add the following lines to your `zshrc` file:
35
36    ```shell
37    prompt_svn() {
38        local rev branch
39        if in_svn; then
40            rev=$(svn_get_rev_nr)
41            branch=$(svn_get_branch_name)
42            if [[ $(svn_dirty_choose_pwd 1 0) -eq 1 ]]; then
43                prompt_segment yellow black
44                echo -n "$rev@$branch"
45                echo -n "±"
46            else
47                prompt_segment green black
48                echo -n "$rev@$branch"
49            fi
50        fi
51    }
52    ```
53
543. Override the agnoster `build_prompt()` function:
55
56    ```zsh
57    build_prompt() {
58        RETVAL=$?
59        prompt_status
60        prompt_context
61        prompt_dir
62        prompt_git
63        prompt_svn
64        prompt_end
65    }
66    ```
67
68