diff --git a/install.sh b/install.sh index 091f832..8bad9c2 100755 --- a/install.sh +++ b/install.sh @@ -50,36 +50,37 @@ set +eux # Install Oh-My-zsh if not installed if [ ! -f ~/.zshrc ]; then - sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" + sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | sh fi # Enable exit on error set -eux -# Remove old config file -rm -rf ~/.zshrc +# Backup old config file if it exists +if [ -f ~/.zshrc ]; then + mv ~/.zshrc ~/.zshrc.backup +fi -# Replace config file -touch ~/.zshrc -echo "$(curl https://raw.githubusercontent.com/alvinlollo/Single-install-script/refs/heads/main/configs/.zshrc)" >> ~/.zshrc +# Download and replace config file +curl -fsSL https://raw.githubusercontent.com/alvinlollo/Single-install-script/refs/heads/main/configs/.zshrc -o ~/.zshrc # [zsh-history-substring-search](https://github.com/zsh-users/zsh-history-substring-search) -if [ ! -d ~/.oh-my-zsh/custom/plugins/zsh-history-substring-search ]; then +if [ ! -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search ]; then git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search fi # [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) -if [ ! -d ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions ];then - git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" +if [ ! -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ];then + git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions fi # [zsh-eza](https://github.com/z-shell/zsh-eza) -if [ ! -d ~/.oh-my-zsh/custom/plugins/zsh-eza ]; then +if [ ! -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-eza ]; then git clone https://github.com/z-shell/zsh-eza.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-eza fi # [fzf-zsh-plugin](https://github.com/unixorn/fzf-zsh-plugin) -if [ ! -d ~/.oh-my-zsh/custom/plugins/fzf-zsh-plugin ]; then +if [ ! -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-zsh-plugin ]; then git clone --depth 1 https://github.com/unixorn/fzf-zsh-plugin.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-zsh-plugin fi