1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-26 02:08:37 +08:00
ohmyzsh/plugins/svn
2022-01-03 13:50:50 +01:00
..
README.md use https everywhere (#6574) 2018-08-07 20:42:01 +02:00
svn.plugin.zsh fix(svn): return true repo name in svn_get_repo_name 2022-01-03 13:50:50 +01:00

svn plugin

This plugin adds some utility functions to display additional information regarding your current
svn repository. See https://subversion.apache.org/ for the full svn documentation.

To use it, add svn to your plugins array:

plugins=(... svn)

Functions

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)
svn_get_rev_nr Get revision number
svn_dirty Checks if there are changes in the svn repo

Caveats

The plugin expects the first directory to be the current branch / tag / trunk. So it returns
the first path element if you don't use branches.

Usage on themes

To use this in the agnoster theme follow these instructions:

  1. Enable the svn plugin

  2. Add the following lines to your zshrc file:

    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
        fi
    }
    
  3. Override the agnoster build_prompt() function:

    build_prompt() {
        RETVAL=$?
        prompt_status
        prompt_context
        prompt_dir
        prompt_git
        prompt_svn
        prompt_end
    }