Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement omb theme #620

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions lib/cli.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,42 @@ 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
_omb_util_print_lines "${available_themes[@]}"
;;
use)
local theme=${2-}
if [[ -z "$theme" ]]; then
_omb_util_print 'Usage: omb theme use <theme>' >&2
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_omb_module_require_theme is kind of "include once"; it checks whether the module is already loaded and loads the module only when it hasn't been loaded. So, with this implementation, one cannot switch to the theme that was loaded before.

To handle this, we may need to factorize a part of _omb_module_require (oh-my-bash.sh) into _omb_module_search and use it to obtain the location of the theme file.

return 0
fi
done
_omb_util_print "Theme '$theme' not found"
;;
set)
echo 'Not yet implemented'
;;
*)
_omb_util_print_lines \
'Usage: omb theme <command>' \
'' \
'Available commands:' \
' list List all available themes' \
' set <theme> Set the given theme in your .bashrc file' \
' use <theme> Load the given theme'
return 2
;;
esac
}
function _omb_cmd_update {
echo 'Not yet implemented'
Expand Down Expand Up @@ -161,7 +196,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 ;;
Expand Down
Loading