2022-01-15 19:00:35 +09:00
|
|
|
#! bash oh-my-bash.module
|
2017-10-10 18:07:01 +07:00
|
|
|
# port of zork theme
|
|
|
|
|
|
|
|
# set colors for use throughout the prompt
|
|
|
|
# i like things consistent
|
2022-01-30 21:31:51 -06:00
|
|
|
OMB_THEME_BRACKET_COLOR="${OMB_THEME_BRACKET_COLOR:-${blue}}"
|
|
|
|
OMB_THEME_STRING_COLOR="${OMB_THEME_STRING_COLOR:-${green}}"
|
2017-10-10 18:07:01 +07:00
|
|
|
|
|
|
|
SCM_THEME_PROMPT_PREFIX=""
|
|
|
|
SCM_THEME_PROMPT_SUFFIX=""
|
|
|
|
|
|
|
|
SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
|
|
|
|
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}"
|
2022-01-30 21:31:51 -06:00
|
|
|
SCM_GIT_CHAR="${OMB_THEME_STRING_COLOR}±${normal}"
|
2017-10-10 18:07:01 +07:00
|
|
|
SCM_SVN_CHAR="${bold_cyan}⑆${normal}"
|
|
|
|
SCM_HG_CHAR="${bold_red}☿${normal}"
|
|
|
|
|
2022-01-30 21:31:51 -06:00
|
|
|
PROMPT_CHAR="${OMB_THEME_BRACKET_COLOR}➞ ${normal}"
|
2022-01-29 21:41:37 -06:00
|
|
|
if [[ $OSTYPE =~ "darwin" ]]; then
|
2022-01-30 21:31:51 -06:00
|
|
|
PROMPT_CHAR="${OMB_THEME_BRACKET_COLOR}➞ ${normal}"
|
2022-01-29 21:41:37 -06:00
|
|
|
fi
|
|
|
|
|
2017-10-10 18:07:01 +07:00
|
|
|
#Mysql Prompt
|
|
|
|
export MYSQL_PS1="(\u@\h) [\d]> "
|
|
|
|
|
2022-01-29 21:41:37 -06:00
|
|
|
TITLEBAR=""
|
2017-10-10 18:07:01 +07:00
|
|
|
case $TERM in
|
2022-01-29 21:41:37 -06:00
|
|
|
xterm*) TITLEBAR="\[\033]0;\w\007\]" ;;
|
2017-10-10 18:07:01 +07:00
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
__my_rvm_ruby_version() {
|
2022-01-29 21:41:37 -06:00
|
|
|
local gemset ; gemset=$(echo "${GEM_HOME}" | awk -F'@' '{print $2}')
|
|
|
|
local version ; version=$(echo "${MY_RUBY_HOME}" | awk -F'-' '{print $2}')
|
|
|
|
[ "${gemset}" != "" ] && gemset="@${gemset}"
|
|
|
|
local full="${version}${gemset}"
|
2022-01-30 21:31:51 -06:00
|
|
|
[ "${full}" != "" ] \
|
|
|
|
&& echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}${full}${OMB_THEME_BRACKET_COLOR}]${normal}"
|
2017-10-10 18:07:01 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
is_vim_shell() {
|
2022-01-30 21:31:51 -06:00
|
|
|
if [ -n "${VIMRUNTIME}" ] ; then
|
|
|
|
echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}vim shell${OMB_THEME_BRACKET_COLOR}]${normal}"
|
2022-01-29 21:41:37 -06:00
|
|
|
fi
|
2017-10-10 18:07:01 +07:00
|
|
|
}
|
|
|
|
|
2022-01-30 21:33:54 -06:00
|
|
|
is_integer() { # helper function to make sure input is an integer
|
2017-10-10 18:07:01 +07:00
|
|
|
[ "$1" -eq "$1" ] > /dev/null 2>&1
|
2022-01-29 21:41:37 -06:00
|
|
|
return $?
|
2017-10-10 18:07:01 +07:00
|
|
|
}
|
|
|
|
|
2022-01-29 21:41:37 -06:00
|
|
|
# XXX do we need/want to integrate with todo.sh? We don't provide it and I
|
|
|
|
# can't find a version online that accepts ls as an input
|
2017-10-10 18:07:01 +07:00
|
|
|
todo_txt_count() {
|
2021-12-28 20:29:22 +09:00
|
|
|
if _omb_util_command_exists todo.sh; then # is todo.sh installed
|
2022-01-30 15:05:36 -06:00
|
|
|
local count=$(todo.sh ls \
|
2022-01-29 21:41:37 -06:00
|
|
|
| awk '/TODO: [0-9]+ of ([0-9]+) tasks shown/ { print $4 }')
|
|
|
|
if is_integer "${count}" ; then # did we get a sane answer back
|
2022-01-30 21:31:51 -06:00
|
|
|
echo "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}T:$count${OMB_THEME_BRACKET_COLOR}]$normal"
|
2017-10-10 18:07:01 +07:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
modern_scm_prompt() {
|
2022-01-30 15:05:36 -06:00
|
|
|
local CHAR=$(scm_char)
|
2022-01-30 21:31:51 -06:00
|
|
|
if [ ! "${CHAR}" = "${SCM_NONE_CHAR}" ] ; then
|
|
|
|
printf "%s" \
|
|
|
|
"${OMB_THEME_BRACKET_COLOR}[${CHAR}${OMB_THEME_BRACKET_COLOR}]" \
|
|
|
|
"[${OMB_THEME_STRING_COLOR}$(scm_prompt_info)${OMB_THEME_BRACKET_COLOR}]$normal"
|
|
|
|
printf "\n"
|
|
|
|
fi
|
2017-10-10 18:07:01 +07:00
|
|
|
}
|
|
|
|
|
2022-01-11 12:40:43 +09:00
|
|
|
_omb_theme_PROMPT_COMMAND() {
|
2022-01-30 21:31:51 -06:00
|
|
|
local my_host="${OMB_THEME_STRING_COLOR}\h${normal}";
|
|
|
|
local my_user="${OMB_THEME_STRING_COLOR}\u${normal}";
|
|
|
|
local my_path="${OMB_THEME_STRING_COLOR}\w${normal}";
|
|
|
|
local bracket_c="${OMB_THEME_BRACKET_COLOR}"
|
2017-10-10 18:07:01 +07:00
|
|
|
|
2022-01-30 21:31:51 -06:00
|
|
|
local line2 ; line2="${bracket_c}└─$(todo_txt_count)${PROMPT_CHAR}"
|
2017-10-10 18:07:01 +07:00
|
|
|
# nice prompt
|
2022-01-29 21:41:37 -06:00
|
|
|
case "$(id -u)" in
|
|
|
|
0)
|
|
|
|
my_user="${bold_red}\u${normal}";
|
2022-01-30 21:31:51 -06:00
|
|
|
line2="${bracket_c}└─${PROMPT_CHAR}"
|
2017-10-10 18:07:01 +07:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-01-29 21:41:37 -06:00
|
|
|
PS1="${TITLEBAR}"
|
2022-01-30 21:31:51 -06:00
|
|
|
PS1="${PS1}${bracket_c}┌─[${my_user}${bracket_c}][$my_host${bracket_c}]"
|
2022-01-29 21:41:37 -06:00
|
|
|
PS1="${PS1}$(modern_scm_prompt)"
|
|
|
|
PS1="${PS1}$(__my_rvm_ruby_version)"
|
2022-01-30 21:31:51 -06:00
|
|
|
PS1="${PS1}${bracket_c}[${my_path}${bracket_c}]$(is_vim_shell)"
|
2022-01-29 21:41:37 -06:00
|
|
|
PS1="${PS1}\n${line2}"
|
|
|
|
}
|
2017-10-10 18:07:01 +07:00
|
|
|
|
2022-01-29 21:41:37 -06:00
|
|
|
PS2="└─${PROMPT_CHAR}"
|
|
|
|
PS3=">> "
|
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
|