Skip to content

Commit

Permalink
Installation work... wip
Browse files Browse the repository at this point in the history
  • Loading branch information
raptor235 committed Jun 19, 2024
1 parent c85d740 commit ec63fa9
Showing 1 changed file with 41 additions and 44 deletions.
85 changes: 41 additions & 44 deletions util/set_theme_and_plugins.sh
Original file line number Diff line number Diff line change
@@ -1,53 +1,50 @@
#!/bin/bash

set_oh_my_zsh_theme_and_plugins() {
# Create .zshrc if it doesn't exist
if [ ! -f ~/.zshrc ]; then
touch ~/.zshrc
fi
# Create .zshrc if it doesn't exist
if [ ! -f ~/.zshrc ]; then
touch ~/.zshrc
fi

echo "Select a theme for Oh My Zsh or type your custom theme:"
echo "1) robbyrussell"
echo "2) agnoster"
echo "3) gallois"
echo "4) avit"
echo "5) random"
echo "6) Custom theme"
echo -n "Enter the number corresponding to your choice or type your theme name: "
read theme_choice
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)
theme="robbyrussell"
;;
2)
theme="agnoster"
;;
3)
theme="gallois"
;;
4)
theme="avit"
;;
5)
theme="random"
;;
6)
echo -n "Enter your custom theme name: "
read custom_theme
theme="$custom_theme"
;;
*)
echo "Invalid choice, defaulting to robbyrussell"
theme="robbyrussell"
;;
esac
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

# Set the theme in .zshrc
sed -i.bak "s/^ZSH_THEME=.*/ZSH_THEME=\"$theme\"/" ~/.zshrc
# 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
sed -i.bak '/^source $ZSH\/oh-my-zsh.sh/i plugins=(git zsh-autosuggestions zsh-syntax-highlighting)' ~/.zshrc
# 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

echo "Theme set to $theme and plugins configured."
# 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

echo "Theme set to $ZSH_THEME and plugins configured."
}

0 comments on commit ec63fa9

Please sign in to comment.