zsh.sh nits: backup rotation, guarded rm, --needed, drop dead placeholder

- timestamped .zshrc backups (was: .zshrc.bak overwritten every run, so
  only the latest pre-run state survived)
- only remove ~/.oh-my-zsh when it actually contains oh-my-zsh.sh; warn
  and leave anything else alone (was: unguarded rm -rf)
- add --needed to the pacman prerequisite install
- drop the empty ~/.fzf/shell/key-bindings.zsh placeholder (nothing
  sourced it; fzf integration comes from the oh-my-zsh plugin)
- LICENSE spelling in banners (zsh.sh, installbeta.sh)
This commit is contained in:
alvinlollo
2026-10-08 14:16:37 +11:00
parent a012aeab9c
commit bca2dd45ba
2 changed files with 23 additions and 19 deletions
+2 -2
View File
@@ -38,9 +38,9 @@ if [ "$skip_watermark" = false ]; then
|___/ |___/
--------------- Single Download script --------------- --------------- Single Download script ---------------
BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE UNDER THE GPL-2.0 LICENCE, BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE UNDER THE GPL-2.0 LICENSE,
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
See the LICENCE for more detail See the LICENSE for more detail
' '
fi fi
+21 -17
View File
@@ -25,8 +25,8 @@ echo '
|___/ |___/
--------------- ZSH Install Script --------------- --------------- ZSH Install Script ---------------
BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE UNDER THE GPL-2.0 LICENCE, THERE IS NO WARRANTY BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE UNDER THE GPL-2.0 LICENSE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. See the LICENCE for more detail FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. See the LICENSE for more detail
' '
fi fi
@@ -40,7 +40,7 @@ set -eu
if ! command -v zsh >/dev/null || ! command -v git >/dev/null || ! command -v curl >/dev/null || ! command -v fzf >/dev/null; then if ! command -v zsh >/dev/null || ! command -v git >/dev/null || ! command -v curl >/dev/null || ! command -v fzf >/dev/null; then
if command -v pacman >/dev/null; then if command -v pacman >/dev/null; then
echo "pacman detected. Installing prerequisites" echo "pacman detected. Installing prerequisites"
sudo pacman -S zsh git curl fzf --noconfirm sudo pacman -S --needed --noconfirm zsh git curl fzf
fi fi
if command -v apt >/dev/null; then if command -v apt >/dev/null; then
@@ -67,24 +67,28 @@ echo '
# Print commands # Print commands
set -x set -x
# Disable exit on error # Remove an existing oh-my-zsh install, but only when it really is one
set +eu if [ -d "$HOME/.oh-my-zsh" ]; then
if [ -f "$HOME/.oh-my-zsh/oh-my-zsh.sh" ]; then
rm -rf ~/.oh-my-zsh echo "Removing existing ~/.oh-my-zsh for a clean install"
rm -rf "$HOME/.oh-my-zsh"
# Enable exit on error else
set -eu echo "warning: ~/.oh-my-zsh exists but does not look like an oh-my-zsh install - leaving it in place" >&2
fi
fi
# Do not print commands # Do not print commands
set +x set +x
# Backup the user's current config before oh-my-zsh overwrites it # Backup the user's current config before oh-my-zsh overwrites it.
# Timestamped so re-running the script never overwrites the previous backup.
if [ -f "$HOME/.zshrc" ]; then if [ -f "$HOME/.zshrc" ]; then
if ! cp "$HOME/.zshrc" "$HOME/.zshrc.bak"; then ZSHRC_BACKUP="$HOME/.zshrc.bak-$(date +%Y%m%d-%H%M%S)"
echo "error: failed to back up $HOME/.zshrc to $HOME/.zshrc.bak" >&2 if ! cp "$HOME/.zshrc" "$ZSHRC_BACKUP"; then
echo "error: failed to back up $HOME/.zshrc to $ZSHRC_BACKUP" >&2
exit 1 exit 1
fi fi
echo "Backed up $HOME/.zshrc to $HOME/.zshrc.bak" echo "Backed up $HOME/.zshrc to $ZSHRC_BACKUP"
fi fi
# Install oh-my-zsh without entering zsh # Install oh-my-zsh without entering zsh
@@ -122,9 +126,9 @@ curl -fsSL https://raw.githubusercontent.com/alvinlollo/Single-install-script/re
# Download generic fzf configuration # 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 https://raw.githubusercontent.com/alvinlollo/Single-install-script/refs/heads/main/configs/.fzf.zsh -o ~/.fzf.zsh
# Setup fzf # Setup fzf: the oh-my-zsh fzf-zsh-plugin provides the integration.
mkdir -p ~/.fzf/shell # (Previously an empty ~/.fzf/shell/key-bindings.zsh placeholder was created
touch ~/.fzf/shell/key-bindings.zsh # here - nothing ever sourced it, and it would shadow real bindings.)
# Do not print commands # Do not print commands
set +x set +x