subnixr / minimal

A minimal zsh theme
GNU General Public License v3.0
259 stars 23 forks source link

Mercurial Support #23

Closed oscarmcm closed 5 years ago

oscarmcm commented 5 years ago

Is there any support for mercurial or a form to enable it? Thanks

subnixr commented 5 years ago

Unfortunately there is not support for mercurial, as I'm not familiar with it. But minimal is flexible enough, so you can write your own "widget" and plug it in. The git widget might be a good starting point.

If you happen to submit a pull request and there is enough interest, I might include it in the repo

jedahan commented 5 years ago

Feel free to adapt this:

# ansi - simplified coloring of prompt text `ansi red "some text"`
(( $+functions[ansi] )) || ansi() { (($# - 2)) || echo -n "%F{$1}$2%f"; }

# geometry_hg - display current mercurial branch and status
geometry_hg() {
  (( $+commands[hg] )) || return 1
  [[ -d .hg ]] || return 2

  local branch="$(ansi ${GEOMETRY_HG_COLOR_BRANCH:=242} $(hg branch 2> /dev/null))"

  [[ -n "$(hg status 2> /dev/null)" ]] \
    && local symbol=$(ansi ${GEOMETRY_HG_COLOR_DIRTY:=red} ${GEOMETRY_HG_SYMBOL_DIRTY:="⬡"}) \
    || local symbol=$(ansi ${GEOMETRY_HG_COLOR_CLEAN:=green} ${GEOMETRY_HG_SYMBOL_CLEAN:="⬢"})

  echo -n "${branch}${GEOMETRY_HG_SYMBOL_SEPARATOR:='::'}${symbol}"
}