oh-my-zsh/plugins/svn/README.md

68 lines
1.8 KiB
Markdown
Raw Normal View History

2016-09-27 10:27:37 +00:00
# `svn` plugin
This plugin adds some utility functions to display additional information regarding your current
2016-09-29 11:56:16 +00:00
svn repository. See http://subversion.apache.org/ for the full svn documentation.
To use it, add `svn` to your plugins array:
```zsh
plugins=(... svn)
```
2016-09-27 10:27:37 +00:00
## Functions
2016-09-29 11:56:16 +00:00
| 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 |
2016-09-27 10:27:37 +00:00
## Caveats
2016-09-29 11:56:16 +00:00
The plugin expects the first directory to be the current branch / tag / trunk. So it returns
2016-09-27 10:27:37 +00:00
the first path element if you don't use branches.
2016-09-29 11:56:16 +00:00
## Usage on themes
2016-09-27 10:27:37 +00:00
2016-09-29 11:56:16 +00:00
To use this in the `agnoster` theme follow these instructions:
2016-09-27 10:27:37 +00:00
2016-09-29 11:56:16 +00:00
1. Enable the svn plugin
2016-09-27 10:27:37 +00:00
2016-09-29 11:56:16 +00:00
2. Add the following lines to your `zshrc` file:
2016-09-27 10:27:37 +00:00
2016-09-29 11:56:16 +00:00
```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
2016-09-27 10:27:37 +00:00
fi
2016-09-29 11:56:16 +00:00
}
```
2016-09-27 10:27:37 +00:00
2016-09-29 11:56:16 +00:00
3. Override the agnoster `build_prompt()` function:
2016-09-27 10:27:37 +00:00
2016-09-29 11:56:16 +00:00
```zsh
build_prompt() {
RETVAL=$?
prompt_status
prompt_context
prompt_dir
prompt_git
prompt_svn
prompt_end
}
```
2016-09-27 10:27:37 +00:00