From 00f28e4a5ff3f4a5217a3b43ba5072d653bcf443 Mon Sep 17 00:00:00 2001 From: Yishuai Li Date: Mon, 11 Dec 2023 06:01:54 +0800 Subject: [PATCH] themes/random: add OMB_THEME_RANDOM_IGNORED (#498) --- README.md | 6 ++++++ oh-my-bash.sh | 12 ++++++++++++ templates/bashrc.osh-template | 3 +++ 3 files changed, 21 insertions(+) diff --git a/README.md b/README.md index b7ebce3..4b1d0c7 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,12 @@ If you're feeling feisty, you can let the computer select one randomly for you e OSH_THEME="random" # (...please let it be pie... please be some pie..) ``` +If there are themes you don't like, you can add them to an ignored list: + +```shell +OMB_THEME_RANDOM_IGNORED=("powerbash10k" "wanelo") +``` + The selected theme name can be checked by the following command: ```shell diff --git a/oh-my-bash.sh b/oh-my-bash.sh index 9a61fa8..689a499 100644 --- a/oh-my-bash.sh +++ b/oh-my-bash.sh @@ -144,6 +144,18 @@ unset -v _omb_init_files _omb_init_file # Load the theme if [[ $OSH_THEME == random ]]; then _omb_util_glob_expand _omb_init_files '"$OSH"/themes/*/*.theme.sh' + + # Remove ignored themes from the list + for _omb_init_theme in random "${OMB_THEME_RANDOM_IGNORED[@]}"; do + for _omb_init_index in "${!_omb_init_files[@]}"; do + [[ ${_omb_init_files[_omb_init_index]} == */"$_omb_init_theme"/* ]] && + unset -v '_omb_init_files[_omb_init_index]' + done + unset -v _omb_init_index + done + unset -v _omb_init_theme + _omb_init_files=("${_omb_init_files[@]}") + if ((${#_omb_init_files[@]})); then _omb_init_file=${_omb_init_files[RANDOM%${#_omb_init_files[@]}]} source "$_omb_init_file" diff --git a/templates/bashrc.osh-template b/templates/bashrc.osh-template index c73f514..4f1851d 100644 --- a/templates/bashrc.osh-template +++ b/templates/bashrc.osh-template @@ -11,6 +11,9 @@ export OSH=~/.oh-my-bash # it'll load a random theme each time that oh-my-bash is loaded. OSH_THEME="font" +# If you set OSH_THEME to "random", you can ignore themes you don't like. +# OMB_THEME_RANDOM_IGNORED=("powerbash10k" "wanelo") + # Uncomment the following line to use case-sensitive completion. # OMB_CASE_SENSITIVE="true"