diff --git a/util/install_fpd_shell.sh b/util/install_fpd_shell.sh index 05f0cd7..5822d88 100755 --- a/util/install_fpd_shell.sh +++ b/util/install_fpd_shell.sh @@ -59,18 +59,11 @@ install_fpd_shell() { # Run the Oh My Zsh installation in a zsh subshell zsh -c " - cat ~/.fpd-shell/VERSION - source ~/.fpd-shell/util/install_oh_my_zsh.sh install_oh_my_zsh - cat ~/.fpd-shell/util/set_theme_and_plugins.sh - source ~/.fpd-shell/util/set_theme_and_plugins.sh set_oh_my_zsh_theme_and_plugins - - source ~/.fpd-shell/util/print_success_message.sh - print_success_message " fi } diff --git a/util/set_theme_and_plugins.sh b/util/set_theme_and_plugins.sh index be12644..ffd4acd 100755 --- a/util/set_theme_and_plugins.sh +++ b/util/set_theme_and_plugins.sh @@ -1,38 +1,58 @@ #!/bin/bash set_oh_my_zsh_theme_and_plugins() { - # Create .zshrc if it doesn't exist - if [ ! -f ~/.zshrc ]; then - touch ~/.zshrc - fi - - # echo "Select a theme for Oh My Zsh:" - # echo "1) robbyrussell" - # echo "2) agnoster" - # echo "3) gallois" - # echo "4) avit" - # echo "5) random" - # read -p "Enter the number corresponding to your choice: " theme_choice - - # case $theme_choice in - # 1) ZSH_THEME="robbyrussell" ;; - # 2) ZSH_THEME="agnoster" ;; - # 3) ZSH_THEME="gallois" ;; - # 4) ZSH_THEME="avit" ;; - # 5) ZSH_THEME="random" ;; - # *) - # echo "Invalid choice, defaulting to robbyrussell" - # ZSH_THEME="robbyrussell" - # ;; - # esac - - ZSH_THEME="gallois" - - echo "ZSH_THEME=\"$ZSH_THEME\"" >>~/.zshrc - - echo "plugins=(git zsh-autosuggestions zsh-syntax-highlighting)" >>~/.zshrc - - echo "Theme set to $theme and plugins configured." - - cat ~/.zshrc + # Create .zshrc if it doesn't exist + if [ ! -f ~/.zshrc ]; then + touch ~/.zshrc + fi + + # echo "Select a theme for Oh My Zsh:" + # echo "1) robbyrussell" + # echo "2) agnoster" + # echo "3) gallois" + # echo "4) avit" + # echo "5) random" + # read -p "Enter the number corresponding to your choice: " theme_choice + + # case $theme_choice in + # 1) ZSH_THEME="robbyrussell" ;; + # 2) ZSH_THEME="agnoster" ;; + # 3) ZSH_THEME="gallois" ;; + # 4) ZSH_THEME="avit" ;; + # 5) ZSH_THEME="random" ;; + # *) + # echo "Invalid choice, defaulting to robbyrussell" + # ZSH_THEME="robbyrussell" + # ;; + # esac + + ZSH_THEME="gallois" + + # Set the theme in .zshrc + # if grep -q "^ZSH_THEME=" ~/.zshrc; then + # sed -i.bak "s/^ZSH_THEME=.*/ZSH_THEME=\"$ZSH_THEME\"/" ~/.zshrc + # else + echo "ZSH_THEME=\"$ZSH_THEME\"" >> ~/.zshrc + # fi + + # Add plugins to .zshrc before sourcing oh-my-zsh + if ! grep -q "plugins=(git zsh-autosuggestions zsh-syntax-highlighting)" ~/.zshrc; then + sed -i.bak '/^source $ZSH\/oh-my-zsh.sh/i \ +plugins=(git zsh-autosuggestions zsh-syntax-highlighting)' ~/.zshrc + fi + + # Ensure the main shell scripts are sourced only once + if ! grep -q "source ~/.fpd-shell/fpd-shell.sh" ~/.zshrc; then + echo 'source ~/.fpd-shell/fpd-shell.sh' >> ~/.zshrc + fi + if ! grep -q "source ~/.fpd-shell/.fpd-shellrc" ~/.zshrc; then + echo 'source ~/.fpd-shell/.fpd-shellrc' >> ~/.zshrc + fi + + # Ensure oh-my-zsh is sourced only once + if ! grep -q "source \$ZSH/oh-my-zsh.sh" ~/.zshrc; then + echo 'source $ZSH/oh-my-zsh.sh' >> ~/.zshrc + fi + + echo "Theme set to $ZSH_THEME and plugins configured." }