diff options
Diffstat (limited to 'plugins/mercurial')
| -rw-r--r-- | plugins/mercurial/README.md | 64 | ||||
| -rw-r--r-- | plugins/mercurial/mercurial.plugin.zsh | 6 | 
2 files changed, 68 insertions, 2 deletions
diff --git a/plugins/mercurial/README.md b/plugins/mercurial/README.md new file mode 100644 index 000000000..89e1c1743 --- /dev/null +++ b/plugins/mercurial/README.md @@ -0,0 +1,64 @@ +# Mercurial plugin +### Usage +Update .zshrc: + +1. Add name to the list of plugins, e.g. `plugins = (..., mercurial, ...)` +   (that is pretty obvious). +2. Change PROMPT variable of current theme to contain current folder mercurial repo info: + +   robbyrussel theme is used by default, so you need to modify PROMPT var +   from [this file](https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/robbyrussell.zsh-theme) +   by adding `$(hg_prompt_info)` after `$(git_prompt_info)`, so currently it +   looks next: + +   ```diff +   - PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +   + PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(hg_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' +   ``` +    +   and put modified var at the end of **.zshrc**. +3. Initialize additional vars used in plugin. So in short put next in **.zshrc**: +    +   ``` +   ZSH_THEME_HG_PROMPT_PREFIX="%{$fg_bold[magenta]%}hg:(%{$fg[red]%}" +   ZSH_THEME_HG_PROMPT_SUFFIX="%{$reset_color%}" +   ZSH_THEME_HG_PROMPT_DIRTY="%{$fg[magenta]%}) %{$fg[yellow]%}✗%{$reset_color%}" +   ZSH_THEME_HG_PROMPT_CLEAN="%{$fg[magenta]%})" +   ``` + +### What's inside? +#### Adds handy aliases: +###### general +* `hgc` - `hg commit` +* `hgb` - `hg branch` +* `hgba` - `hg branches` +* `hgbk` - `hg bookmarks` +* `hgco` - `hg checkout` +* `hgd`  - `hg diff` +* `hged` - `hg diffmerge` + +###### pull and update +* `hgi` - `hg incoming` +* `hgl` - `hg pull -u` +* `hglr` - `hg pull --rebase` +* `hgo` - `hg outgoing` +* `hgp` - `hg push` +* `hgs` - `hg status` +* `hgsl` - `hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n"` + +###### this is the 'git commit --amend' equivalent +* `hgca` - `hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip` + +###### list unresolved files (since hg does not list unmerged files in the status command) +* `hgun` - `hg resolve --list` + +#### Displays repo branch and directory status in prompt +This is the same as git plugin does. + +**Note**: additional changes to **.zshrc** are required in order for this to +work. + +### Mantainers +[ptrv](https://github.com/ptrv) - original creator + +[oshybystyi](https://github.com/oshybystyi) - created this README and know how most of code works diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index 2e99a12fb..86200ccf6 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -16,6 +16,8 @@ alias hgs='hg status'  alias hgsl='hg log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" '  # this is the 'git commit --amend' equivalent  alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip' +# list unresolved files (since hg does not list unmerged files in the status command) +alias hgun='hg resolve --list'  function in_hg() {    if [[ -d .hg ]] || $(hg summary > /dev/null 2>&1); then @@ -33,14 +35,14 @@ function hg_prompt_info {    if [ $(in_hg) ]; then      _DISPLAY=$(hg_get_branch_name)      echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\ -$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_PROMPT_BASE_COLOR" +$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR"      unset _DISPLAY    fi  }  function hg_dirty_choose {    if [ $(in_hg) ]; then -    hg status 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]' +    hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'      if [ $pipestatus[-1] -eq 0 ]; then        # Grep exits with 0 when "One or more lines were selected", return "dirty".        echo $1  | 
