#! bash oh-my-bash.module # Oxygen segment for the oh-my-bash powerline themes. # # Install: copy this file to "$OSH_CUSTOM/oxy.sh" (default ~/.oh-my-bash/custom/) # and open a new shell. Custom files load before the theme, so the # POWERLINE_PROMPT default below adds the "oxy" segment next to the Git one; # set POWERLINE_PROMPT yourself to arrange segments differently. # # The segment shows: icon, bookmark, working-copy change id, a state glyph # (✔ clean, ✎ uncommitted changes, ‼ conflicts), and ↑n/↓n against origin. # Its colour follows the state. It costs one `oxy prompt` call, a few # milliseconds, and prints nothing outside an Oxygen repository. : "${POWERLINE_PROMPT:=user_info scm oxy python_venv ruby cwd}" OXY_CHAR=${POWERLINE_OXY_CHAR:="⚛ "} OXY_THEME_PROMPT_CLEAN_COLOR=${OXY_THEME_PROMPT_CLEAN_COLOR:=25} OXY_THEME_PROMPT_DIRTY_COLOR=${OXY_THEME_PROMPT_DIRTY_COLOR:=88} OXY_THEME_PROMPT_CONFLICT_COLOR=${OXY_THEME_PROMPT_CONFLICT_COLOR:=160} OXY_THEME_PROMPT_CLEAN_GLYPH=${OXY_THEME_PROMPT_CLEAN_GLYPH:="✔"} OXY_THEME_PROMPT_DIRTY_GLYPH=${OXY_THEME_PROMPT_DIRTY_GLYPH:="✎"} OXY_THEME_PROMPT_CONFLICT_GLYPH=${OXY_THEME_PROMPT_CONFLICT_GLYPH:="‼"} function __powerline_oxy_prompt { command -v oxy >/dev/null 2>&1 || return local info info=$(oxy prompt --format '%b|%c|%d|%x|%U|%O' 2>/dev/null) || return [[ -n "$info" ]] || return local bookmark change dirty conflict up down IFS='|' read -r bookmark change dirty conflict up down <<< "$info" local color glyph if [[ -n "$conflict" ]]; then color=$OXY_THEME_PROMPT_CONFLICT_COLOR glyph=$OXY_THEME_PROMPT_CONFLICT_GLYPH elif [[ -n "$dirty" ]]; then color=$OXY_THEME_PROMPT_DIRTY_COLOR glyph=$OXY_THEME_PROMPT_DIRTY_GLYPH else color=$OXY_THEME_PROMPT_CLEAN_COLOR glyph=$OXY_THEME_PROMPT_CLEAN_GLYPH fi _omb_util_print "${OXY_CHAR}${bookmark} ${change} ${glyph}${up}${down}|${color}" }