From 2eccd6377d48449b8e04fa4f0e8c2ad1d3c1fb74 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 2 Oct 2024 01:15:43 -0400 Subject: [PATCH] Move to Usage: omb theme Available commands: list List all available themes set Set the given theme in your .bashrc file use Load the given theme --- lib/cli.bash | 40 +++++++++++++++++++++++++++++++-- plugins/themes/README.md | 19 ---------------- plugins/themes/themes.plugin.sh | 33 --------------------------- 3 files changed, 38 insertions(+), 54 deletions(-) delete mode 100644 plugins/themes/README.md delete mode 100644 plugins/themes/themes.plugin.sh diff --git a/lib/cli.bash b/lib/cli.bash index 111da2a6d..8af6ece19 100644 --- a/lib/cli.bash +++ b/lib/cli.bash @@ -18,7 +18,43 @@ function _omb_cmd_reload { echo 'Not yet implemented' } function _omb_cmd_theme { - echo 'Not yet implemented' + case "$1" in + list) + local -a available_themes + _comp_cmd_omb__get_available_themes + for theme in "${available_themes[@]}"; do + echo "$theme" + done + ;; + use) + local theme=$2 + if [[ -z "$theme" ]]; then + echo 'Usage: omb theme use ' + return 2 + fi + local -a available_themes + _comp_cmd_omb__get_available_themes + for i in "${available_themes[@]}"; do + if [ "$i" == "$theme" ]; then + _omb_module_require_theme "$theme" + return 0 + fi + done + echo "Theme '$theme' not found" + ;; + set) + echo 'Not yet implemented' + ;; + *) + echo 'Usage: omb theme ' + echo '' + echo 'Available commands:' + echo ' list List all available themes' + echo ' set Set the given theme in your .bashrc file' + echo ' use Load the given theme' + return 2 + ;; + esac } function _omb_cmd_update { echo 'Not yet implemented' @@ -161,7 +197,7 @@ function _comp_cmd_omb { theme) local -a subcmds=( 'list:List themes' - 'set:Set a theme in your .zshrc file' + 'set:Set a theme in your .bashrc file' 'use:Load a theme' ) _comp_cmd_omb__describe 'command' subcmds ;; diff --git a/plugins/themes/README.md b/plugins/themes/README.md deleted file mode 100644 index e9e6ca888..000000000 --- a/plugins/themes/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Themes Plugin - -This plugin allows you to change Oh-My-Bash themes on the go. - -To use it, add `themes` to the plugins array in your `.bashrc` file: - -``` -plugins=(... themes) -``` - -This is based off the [themes oh-my-zsh plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/themes). - -## Usage - -`theme ` - Changes the theme to specified theme. - -`theme ` - Changes the theme to some random theme. - -`lstheme ` - Lists installed themes. diff --git a/plugins/themes/themes.plugin.sh b/plugins/themes/themes.plugin.sh deleted file mode 100644 index 364f9d84d..000000000 --- a/plugins/themes/themes.plugin.sh +++ /dev/null @@ -1,33 +0,0 @@ -#! bash oh-my-bash.module - -# Load the given theme, or a random one if none is provided. -function theme() { - local desired_theme="$1" - - # Random - if [[ -z "$desired_theme" ]]; then - local theme_files - _omb_util_glob_expand theme_files '"$OSH"/themes/*/*.theme.sh' - theme_files=("${theme_files[@]}") - - if ((${#theme_files[@]})); then - local random_theme=${theme_files[RANDOM%${#theme_files[@]}]} - desired_theme=$(basename $(dirname "$random_theme")) - echo "${_omb_term_reset}theme ${_omb_term_bold}${desired_theme}$_omb_term_reset" - else - echo "No themes found." - return 1 - fi - fi - - _omb_module_require_theme "$desired_theme" -} - -# List all available themes -function lstheme() { - local theme_files - _omb_util_glob_expand theme_files '"$OSH"/themes/*/*.theme.sh' - for i in "${theme_files[@]}"; do - echo $(basename $(dirname "$i")) - done -}