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 b716f8e commit 95af2c3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
22 changes: 22 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ for script in "${UTIL_SCRIPTS[@]}"; do
fi
done

# Backup .zshrc if it doesn't already exist
backup_zshrc() {
if [[ -f ~/.zshrc && ! -f ~/.zshrc.fpd.backup ]]; then
cp ~/.zshrc ~/.zshrc.fpd.backup
echo "Backup of .zshrc created as .zshrc.fpd.backup"
fi
}

# Restore .zshrc from backup
restore_zshrc() {
if [[ -f ~/.zshrc.fpd.backup ]]; then
cp ~/.zshrc.fpd.backup ~/.zshrc
echo "Restored .zshrc from .zshrc.fpd.backup"
fi
}

# Prompt user for installation or uninstallation
read -p "Do you want to install or uninstall FPD Shell? (i/u): " action

Expand Down Expand Up @@ -79,6 +95,9 @@ i | install)
exit 1
fi

# Backup .zshrc
backup_zshrc

# Source the utility scripts
echo "Sourcing utility scripts"
source "$TEMP_DIR/install_oh_my_zsh.sh"
Expand Down Expand Up @@ -152,6 +171,9 @@ u | uninstall)
uninstall_oh_my_zsh
EOF
fi

# Restore .zshrc from backup
restore_zshrc
;;
*)
echo "Invalid option. Please choose 'i' for install or 'u' for uninstall."
Expand Down
21 changes: 3 additions & 18 deletions util/uninstall_fpd_shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,19 @@ if [[ -f ~/.fpd-shell/.fpd-shellrc ]]; then
fi

uninstall_fpd_shell() {
echo "Uninstalling FPD Shell..."
log_heading "Uninstalling FPD Shell..."

# Remove FPD Shell directory
if [[ -d ~/.fpd-shell ]]; then
rm -rf ~/.fpd-shell
echo "FPD Shell directory removed."
fi

# Remove FPD Shell sourcing from .zshrc or .bashrc
if [[ -f ~/.zshrc ]]; then
sed -i '' '/source ~\/.fpd-shell\/fpd-shell.sh/d' ~/.zshrc
sed -i '' '/source ~\/.fpd-shell\/.fpd-shellrc/d' ~/.zshrc
sed -i '' '/ZSH_THEME="gallois"/d' ~/.zshrc
sed -i '' '/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/d' ~/.zshrc
sed -i '' '/ZSH=$HOME\/.oh-my-zsh/d' ~/.zshrc
sed -i '' '/source $ZSH\/oh-my-zsh.sh/d' ~/.zshrc
echo "Removed FPD Shell sourcing from .zshrc."
elif [[ -f ~/.bashrc ]]; then
sed -i '' '/source ~\/.fpd-shell\/fpd-shell.sh/d' ~/.bashrc
sed -i '' '/source ~\/.fpd-shell\/.fpd-shellrc/d' ~/.bashrc
echo "Removed FPD Shell sourcing from .bashrc."
log_success "FPD Shell directory removed."
fi
}

# Function to uninstall Oh My Zsh
uninstall_oh_my_zsh() {
if [[ -d ~/.oh-my-zsh ]]; then
sh ~/.oh-my-zsh/tools/uninstall.sh --unattended
echo "Oh My Zsh uninstalled."
log_success "Oh My Zsh uninstalled."
fi
}

0 comments on commit 95af2c3

Please sign in to comment.