themes/modern-t: Print information on the command "t" when it's not found

This commit is contained in:
Koichi Murase 2022-02-01 19:10:37 +09:00
parent 5a601cc8d7
commit 46818bec17
2 changed files with 16 additions and 14 deletions

View File

@ -165,10 +165,9 @@ If you have many functions that go well together, you can put them as a `XYZ.plu
If you would like to modify an existing module (theme/plugin/aliases/completion) bundled with Oh My Bash, first copy the original module to `custom/` directory and modify it. It will be loaded instead of the original one.
```bash
$ cd "$OSH_CUSTOM"
$ mkdir -p "$OSH_CUSTOM/themes"
$ cp -r {"$OSH","$OSH_CUSTOM"}/themes/agnoster
$ EDIT themes/agnoster/agnoster.theme.sh
$ EDIT "$OSH_CUSTOM/themes/agnoster/agnoster.theme.sh"
```
If you would like to track the upstream changes for your customized version of modules, you can optionally directly edit the original files and commit them. In this case, you need to handle possible conflicts with the upstream in upgrading.

View File

@ -37,21 +37,24 @@ modern_scm_prompt() {
}
_omb_theme_PROMPT_COMMAND() {
if [ $? -ne 0 ]
then
# Yes, the indenting on these is weird, but it has to be like
# this otherwise it won't display properly.
if (($? != 0)); then
local border_color=$_omb_prompt_bold_brown
else
local border_color=$_omb_prompt_normal
fi
PS1="${TITLEBAR}${_omb_prompt_bold_brown}┌─[${_omb_prompt_teal}$(t | wc -l | sed -e's/ *//')${_omb_prompt_reset_color}]${_omb_prompt_reset_color}$(modern_scm_prompt)[${_omb_prompt_teal}\W${_omb_prompt_normal}]$(is_vim_shell)
${_omb_prompt_bold_brown}└─▪${_omb_prompt_normal} "
else
PS1="${TITLEBAR}┌─[${_omb_prompt_teal}$(t | wc -l | sed -e's/ *//')${_omb_prompt_reset_color}]$(modern_scm_prompt)[${_omb_prompt_teal}\W${_omb_prompt_normal}]$(is_vim_shell)
└─▪ "
fi
local todo_count=
_omb_util_binary_exists t &&
todo_count=[${_omb_prompt_teal}$(command t | wc -l | sed -e's/ *//')${_omb_prompt_reset_color}]
PS1="${TITLEBAR}${border_color}┌─$todo_count${_omb_prompt_normal}$(modern_scm_prompt)[${_omb_prompt_teal}\W${_omb_prompt_normal}]$(is_vim_shell)"
PS1+="\n${border_color}└─▪${_omb_prompt_normal} "
}
PS2="└─▪ "
_omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND
if [[ -t 2 ]] && ! _omb_util_binary_exists t; then
printf '%s\n' "${_omb_term_bold_navy}oh-my-bash (theme:modern-t)${_omb_term_normal}: command \"t\" not found. The theme \"Modern T\" depends on a todo-list manager \"t\" (${_omb_term_underline}https://github.com/sjl/t${_omb_term_normal})." >&2
fi