2022-01-15 19:00:35 +09:00
|
|
|
#! bash oh-my-bash.module
|
2017-10-10 18:07:01 +07:00
|
|
|
#
|
|
|
|
# One line prompt showing the following configurable information
|
|
|
|
# for git:
|
|
|
|
# time (virtual_env) username@hostname pwd git_char|git_branch git_dirty_status|→
|
|
|
|
#
|
|
|
|
# The → arrow shows the exit status of the last command:
|
|
|
|
# - bold green: 0 exit status
|
|
|
|
# - bold red: non-zero exit status
|
|
|
|
#
|
|
|
|
# Example outside git repo:
|
|
|
|
# 07:45:05 user@host ~ →
|
|
|
|
#
|
|
|
|
# Example inside clean git repo:
|
|
|
|
# 07:45:05 user@host .oh-my-bash ±|master|→
|
|
|
|
#
|
|
|
|
# Example inside dirty git repo:
|
|
|
|
# 07:45:05 user@host .oh-my-bash ±|master ✗|→
|
|
|
|
#
|
|
|
|
# Example with virtual environment:
|
|
|
|
# 07:45:05 (venv) user@host ~ →
|
|
|
|
#
|
|
|
|
|
|
|
|
SCM_NONE_CHAR=''
|
|
|
|
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
|
|
|
SCM_THEME_PROMPT_CLEAN=""
|
|
|
|
SCM_THEME_PROMPT_PREFIX="${green}|"
|
|
|
|
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
|
|
|
SCM_GIT_SHOW_MINIMAL_INFO=true
|
|
|
|
|
|
|
|
CLOCK_THEME_PROMPT_PREFIX=''
|
|
|
|
CLOCK_THEME_PROMPT_SUFFIX=' '
|
2019-08-02 10:33:12 +02:00
|
|
|
THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"}
|
2017-10-10 18:07:01 +07:00
|
|
|
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$bold_blue"}
|
|
|
|
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"}
|
|
|
|
|
|
|
|
VIRTUALENV_THEME_PROMPT_PREFIX='('
|
|
|
|
VIRTUALENV_THEME_PROMPT_SUFFIX=') '
|
|
|
|
|
2022-01-11 12:40:43 +09:00
|
|
|
function _omb_theme_PROMPT_COMMAND() {
|
2017-10-10 18:07:01 +07:00
|
|
|
# This needs to be first to save last command return code
|
|
|
|
local RC="$?"
|
|
|
|
|
2021-12-27 23:52:37 +09:00
|
|
|
local hostname="${bold_black}\u@\h"
|
|
|
|
local python_venv; _omb_prompt_get_python_venv
|
|
|
|
python_venv=$white$python_venv
|
2017-10-10 18:07:01 +07:00
|
|
|
|
|
|
|
# Set return status color
|
|
|
|
if [[ ${RC} == 0 ]]; then
|
|
|
|
ret_status="${bold_green}"
|
|
|
|
else
|
|
|
|
ret_status="${bold_red}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Append new history lines to history file
|
|
|
|
history -a
|
|
|
|
|
2021-12-27 23:52:37 +09:00
|
|
|
PS1="$(clock_prompt)$python_venv${hostname} ${bold_cyan}\W $(scm_prompt_char_info)${ret_status}→ ${normal}"
|
2017-10-10 18:07:01 +07:00
|
|
|
}
|
|
|
|
|
2022-01-11 12:40:43 +09:00
|
|
|
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND
|