README.md 1.84 KB
Newer Older
Christian Ferbar's avatar
Christian Ferbar committed
1
2
3
# `svn` plugin

This plugin adds some utility functions to display additional information regarding your current
Marc Cornellà's avatar
Marc Cornellà committed
4
5
6
7
8
9
10
svn repository. See http://subversion.apache.org/ for the full svn documentation.

To use it, add `svn` to your plugins array:

```zsh
plugins=(... svn)
```
Christian Ferbar's avatar
Christian Ferbar committed
11
12
13

## Functions

Marc Cornellà's avatar
Marc Cornellà committed
14
15
16
17
18
19
20
21
| Command               | Description                                 |
|:----------------------|:--------------------------------------------|
| `svn_prompt_info`     | Shows svn prompt in themes                  |
| `in_svn`              | Checks if we're in an svn repository        |
| `svn_get_repo_name`   | Get repository name                         |
| `svn_get_branch_name` | Get branch name (see [caveats](#caveats))   |
| `svn_get_rev_nr`      | Get revision number                         |
| `svn_dirty`           | Checks if there are changes in the svn repo |
Christian Ferbar's avatar
Christian Ferbar committed
22
23
24

## Caveats

Marc Cornellà's avatar
Marc Cornellà committed
25
The plugin expects the first directory to be the current branch / tag / trunk. So it returns
Christian Ferbar's avatar
Christian Ferbar committed
26
27
the first path element if you don't use branches.

Marc Cornellà's avatar
Marc Cornellà committed
28
## Usage on themes
Christian Ferbar's avatar
Christian Ferbar committed
29

Marc Cornellà's avatar
Marc Cornellà committed
30
To use this in the `agnoster` theme follow these instructions:
Christian Ferbar's avatar
Christian Ferbar committed
31

Marc Cornellà's avatar
Marc Cornellà committed
32
1. Enable the svn plugin
Christian Ferbar's avatar
Christian Ferbar committed
33

Marc Cornellà's avatar
Marc Cornellà committed
34
2. Add the following lines to your `zshrc` file:
Christian Ferbar's avatar
Christian Ferbar committed
35

Marc Cornellà's avatar
Marc Cornellà committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
    ```shell
    prompt_svn() {
        local rev branch
        if in_svn; then
            rev=$(svn_get_rev_nr)
            branch=$(svn_get_branch_name)
            if [[ $(svn_dirty_choose_pwd 1 0) -eq 1 ]]; then
                prompt_segment yellow black
                echo -n "$rev@$branch"
                echo -n "±"
            else
                prompt_segment green black
                echo -n "$rev@$branch"
            fi
Christian Ferbar's avatar
Christian Ferbar committed
50
        fi
Marc Cornellà's avatar
Marc Cornellà committed
51
52
    }
    ```
Christian Ferbar's avatar
Christian Ferbar committed
53

Marc Cornellà's avatar
Marc Cornellà committed
54
3. Override the agnoster `build_prompt()` function:
Christian Ferbar's avatar
Christian Ferbar committed
55

Marc Cornellà's avatar
Marc Cornellà committed
56
57
58
59
60
61
62
63
64
65
66
    ```zsh
    build_prompt() {
        RETVAL=$?
        prompt_status
        prompt_context
        prompt_dir
        prompt_git
        prompt_svn
        prompt_end
    }
    ```
Christian Ferbar's avatar
Christian Ferbar committed
67