diff --git a/configs/.zshenv b/configs/.zshenv new file mode 100644 index 0000000..33cf15f --- /dev/null +++ b/configs/.zshenv @@ -0,0 +1 @@ +skip_global_compinit=1 diff --git a/configs/.zshrc b/configs/.zshrc index 47c82a4..59dba61 100644 --- a/configs/.zshrc +++ b/configs/.zshrc @@ -18,6 +18,8 @@ fi # Path to your oh-my-zsh installation. export ZSH=~/.oh-my-zsh +source $ZSH/custom/plugins/zsh-autocomplete/zsh-autocomplete.plugin.zsh + # Set the name of the theme to load. If you set this to "random" # It'll load a random theme each time that oh-my-zsh is loaded. # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes @@ -79,11 +81,10 @@ plugins=( git zsh-history-substring-search zsh-autosuggestions - zsh-autocomplete # zsh-eza fzf-zsh-plugin zsh-syntax-highlighting - + ) source $ZSH/oh-my-zsh.sh diff --git a/zsh.sh b/zsh.sh index 0483e0c..f23803e 100755 --- a/zsh.sh +++ b/zsh.sh @@ -80,16 +80,19 @@ fi # Do not print commands set +x -# Backup the user's current config before oh-my-zsh overwrites it. +# Backup the user's current configs before oh-my-zsh / our downloads overwrite them. # Timestamped so re-running the script never overwrites the previous backup. -if [ -f "$HOME/.zshrc" ]; then - ZSHRC_BACKUP="$HOME/.zshrc.bak-$(date +%Y%m%d-%H%M%S)" - if ! cp "$HOME/.zshrc" "$ZSHRC_BACKUP"; then - echo "error: failed to back up $HOME/.zshrc to $ZSHRC_BACKUP" >&2 - exit 1 +BACKUP_STAMP="$(date +%Y%m%d-%H%M%S)" +for cfg in .zshrc .zshenv; do + if [ -f "$HOME/$cfg" ]; then + cfg_backup="$HOME/$cfg.bak-$BACKUP_STAMP" + if ! cp "$HOME/$cfg" "$cfg_backup"; then + echo "error: failed to back up $HOME/$cfg to $cfg_backup" >&2 + exit 1 + fi + echo "Backed up $HOME/$cfg to $cfg_backup" fi - echo "Backed up $HOME/.zshrc to $ZSHRC_BACKUP" -fi +done # Install oh-my-zsh without entering zsh if ! omz_installer=$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh); then @@ -121,10 +124,12 @@ clone_plugin "$ZSH_CUSTOM_DIR/plugins/zsh-autocomplete" --depth=1 https://github # Download and replace config file -curl -fsSL https://raw.githubusercontent.com/alvinlollo/Single-install-script/refs/heads/main/configs/.zshrc -o ~/.zshrc +CONFIG_BASE_URL="https://raw.githubusercontent.com/alvinlollo/Single-install-script/refs/heads/main/configs" +curl -fsSL "$CONFIG_BASE_URL/.zshrc" -o ~/.zshrc +curl -fsSL "$CONFIG_BASE_URL/.zshenv" -o ~/.zshenv # Download generic fzf configuration -curl -fsSL https://raw.githubusercontent.com/alvinlollo/Single-install-script/refs/heads/main/configs/.fzf.zsh -o ~/.fzf.zsh +curl -fsSL "$CONFIG_BASE_URL/.fzf.zsh" -o ~/.fzf.zsh # Setup fzf: the oh-my-zsh fzf-zsh-plugin provides the integration. # (Previously an empty ~/.fzf/shell/key-bindings.zsh placeholder was created