Created
July 25, 2026 20:57
-
-
Save fadlee/bbc3807eeb461a2cc2b80ca37aa219cb to your computer and use it in GitHub Desktop.
Port of Oh My Zsh's ys theme for Oh My Bash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! bash oh-my-bash.module | |
| # Port of Oh My Zsh's ys theme for Oh My Bash. | |
| # Format: | |
| # # user @ host in ~/path on git:branch state [HH:MM:SS] C:last_status | |
| # $ | |
| SCM_GIT_SHOW_MINIMAL_INFO=true | |
| OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} | |
| function _omb_theme_ys_pwd() { | |
| local pwd="${PWD/#$HOME/\~}" | |
| printf '%s' "$pwd" | |
| } | |
| function _omb_theme_ys_git_prompt() { | |
| _omb_prompt_git rev-parse --is-inside-work-tree &>/dev/null || return 0 | |
| local ref status state | |
| ref=$(_omb_prompt_git symbolic-ref --quiet --short HEAD 2>/dev/null) || \ | |
| ref=$(_omb_prompt_git rev-parse --short HEAD 2>/dev/null) || return 0 | |
| # Keep branch names safe for prompt expansion. | |
| ref=${ref//\$/-} | |
| ref=${ref//\`/-} | |
| ref=${ref//\\/-} | |
| ref=${ref//[^[:print:]]/-} | |
| if [[ ${SCM_GIT_IGNORE_UNTRACKED} == true ]]; then | |
| status=$(_omb_prompt_git status --porcelain --untracked-files=no 2>/dev/null) | |
| else | |
| status=$(_omb_prompt_git status --porcelain 2>/dev/null) | |
| fi | |
| if [[ -n $status ]]; then | |
| state=" ${_omb_prompt_brown}x${_omb_prompt_reset_color}" | |
| else | |
| state=" ${_omb_prompt_green}o${_omb_prompt_reset_color}" | |
| fi | |
| printf ' %son%s git%s:%s%s%s%s' \ | |
| "${_omb_prompt_reset_color}" \ | |
| "${_omb_prompt_blue}" \ | |
| "${_omb_prompt_reset_color}" \ | |
| "${_omb_prompt_cyan}" \ | |
| "$ref" \ | |
| "$state" \ | |
| "${_omb_prompt_reset_color}" | |
| } | |
| function _omb_theme_ys_exit_code() { | |
| local last_status="$1" | |
| if [[ $last_status -ne 0 ]]; then | |
| printf ' C:%s%s%s' "${_omb_prompt_brown}" "$last_status" "${_omb_prompt_reset_color}" | |
| fi | |
| } | |
| function _omb_theme_PROMPT_COMMAND() { | |
| local last_status="$?" | |
| local pwd git_info exit_info python_venv | |
| pwd=$(_omb_theme_ys_pwd) | |
| git_info=$(_omb_theme_ys_git_prompt) | |
| exit_info=$(_omb_theme_ys_exit_code "$last_status") | |
| _omb_prompt_get_python_venv | |
| python_venv=${python_venv:+ ${_omb_prompt_green}${python_venv}${_omb_prompt_reset_color}} | |
| PS1=" | |
| ${_omb_prompt_bold_blue}#${_omb_prompt_reset_color} " | |
| if [[ $EUID -eq 0 ]]; then | |
| PS1+="${_omb_prompt_black}${_omb_prompt_background_yellow}\u${_omb_prompt_reset_color}" | |
| else | |
| PS1+="${_omb_prompt_cyan}\u${_omb_prompt_reset_color}" | |
| fi | |
| PS1+=" ${_omb_prompt_reset_color}@ ${_omb_prompt_green}\h ${_omb_prompt_reset_color}in ${_omb_prompt_bold_yellow}${pwd}${_omb_prompt_reset_color}${git_info}${python_venv} [\t]${exit_info} | |
| ${_omb_prompt_bold_brown}\$ ${_omb_prompt_reset_color}" | |
| return "$last_status" | |
| } | |
| _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment