From 46818bec1795e26acbcc8ce67ab26ac8f26bff4c Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 1 Feb 2022 19:10:37 +0900 Subject: [PATCH] themes/modern-t: Print information on the command "t" when it's not found --- README.md | 3 +-- themes/modern-t/modern-t.theme.sh | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 789e738..de483d2 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/themes/modern-t/modern-t.theme.sh b/themes/modern-t/modern-t.theme.sh index c7b31b8..cace41d 100644 --- a/themes/modern-t/modern-t.theme.sh +++ b/themes/modern-t/modern-t.theme.sh @@ -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