diff options
| author | JaKooLit <ejhay.games@gmail.com> | 2024-09-19 10:12:58 +0900 |
|---|---|---|
| committer | JaKooLit <ejhay.games@gmail.com> | 2024-09-19 10:12:58 +0900 |
| commit | 90794ab39de7b8acdcd8191231c3852f72498f9b (patch) | |
| tree | c8f35393363f7f2de7ae6b5572c5f8bfe3fa4ec1 | |
| parent | 57448259139628bf8c168f7d4dad77b6874978cb (diff) | |
updated oh my zsh theme switcher. added random function
| -rwxr-xr-x | config/hypr/UserScripts/ZshChangeTheme.sh | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/config/hypr/UserScripts/ZshChangeTheme.sh b/config/hypr/UserScripts/ZshChangeTheme.sh index 46d2249e..f06f2b60 100755 --- a/config/hypr/UserScripts/ZshChangeTheme.sh +++ b/config/hypr/UserScripts/ZshChangeTheme.sh @@ -1,10 +1,19 @@ #!/bin/bash +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# Script for Oh my ZSH theme ( CTRL SHIFT O) + +# preview of theme can be view here: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes + +# after choosing theme, TTY need to be closed and re-open themes_dir="$HOME/.oh-my-zsh/themes" file_extension=".zsh-theme" themes_array=($(find "$themes_dir" -type f -name "*$file_extension" -exec basename {} \; | sed -e "s/$file_extension//")) +# Add "Random" option to the beginning of the array +themes_array=("Random" "${themes_array[@]}") + rofi_command="rofi -i -dmenu -config ~/.config/rofi/config-zsh-theme.rasi" menu() { @@ -16,23 +25,28 @@ menu() { main() { choice=$(menu | ${rofi_command}) - # if nothing selected, script wont change anything + # if nothing selected, script won't change anything if [ -z "$choice" ]; then exit 0 fi zsh_path="$HOME/.zshrc" var_name="ZSH_THEME" - for i in "${themes_array[@]}"; do - if [[ "$i" == "$choice"* ]]; then - if [ -f "$zsh_path" ]; then - sed -i "s/^$var_name=.*/$var_name=\"$i\"/" "$zsh_path" - else - echo "File not found" - fi - break - fi - done + + if [[ "$choice" == "Random" ]]; then + # Pick a random theme from the original themes_array (excluding "Random") + random_theme=${themes_array[$((RANDOM % (${#themes_array[@]} - 1) + 1))]} + theme_to_set="$random_theme" + else + # Set theme to the selected choice + theme_to_set="$choice" + fi + + if [ -f "$zsh_path" ]; then + sed -i "s/^$var_name=.*/$var_name=\"$theme_to_set\"/" "$zsh_path" + else + echo "File not found" + fi } main |
