themes/random: add OMB_THEME_RANDOM_IGNORED (#498)

This commit is contained in:
Yishuai Li 2023-12-11 06:01:54 +08:00 committed by GitHub
parent 0d9a9fd73a
commit 00f28e4a5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View File

@ -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..) 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: The selected theme name can be checked by the following command:
```shell ```shell

View File

@ -144,6 +144,18 @@ unset -v _omb_init_files _omb_init_file
# Load the theme # Load the theme
if [[ $OSH_THEME == random ]]; then if [[ $OSH_THEME == random ]]; then
_omb_util_glob_expand _omb_init_files '"$OSH"/themes/*/*.theme.sh' _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 if ((${#_omb_init_files[@]})); then
_omb_init_file=${_omb_init_files[RANDOM%${#_omb_init_files[@]}]} _omb_init_file=${_omb_init_files[RANDOM%${#_omb_init_files[@]}]}
source "$_omb_init_file" source "$_omb_init_file"

View File

@ -11,6 +11,9 @@ export OSH=~/.oh-my-bash
# it'll load a random theme each time that oh-my-bash is loaded. # it'll load a random theme each time that oh-my-bash is loaded.
OSH_THEME="font" 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. # Uncomment the following line to use case-sensitive completion.
# OMB_CASE_SENSITIVE="true" # OMB_CASE_SENSITIVE="true"