2024-08-08 21:54:37 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2024-08-15 07:13:56 +01:00
|
|
|
. ../common-script.sh
|
2024-08-08 21:54:37 +01:00
|
|
|
|
|
|
|
# Function to install zsh
|
2024-09-17 03:10:02 +01:00
|
|
|
installZsh() {
|
2024-09-18 19:32:12 +01:00
|
|
|
if ! command_exists zsh; then
|
2024-09-20 15:27:31 +01:00
|
|
|
printf "%b\n" "${YELLOW}Installing Zsh...${RC}"
|
2024-09-18 19:32:12 +01:00
|
|
|
case "$PACKAGER" in
|
|
|
|
pacman)
|
2024-09-19 01:03:32 +01:00
|
|
|
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm zsh
|
2024-09-18 19:32:12 +01:00
|
|
|
;;
|
2024-11-07 19:03:21 +00:00
|
|
|
apk)
|
|
|
|
"$ESCALATION_TOOL" "$PACKAGER" add zsh
|
|
|
|
;;
|
2024-09-18 19:32:12 +01:00
|
|
|
*)
|
2024-09-19 01:03:32 +01:00
|
|
|
"$ESCALATION_TOOL" "$PACKAGER" install -y zsh
|
2024-09-18 19:32:12 +01:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
printf "%b\n" "${GREEN}ZSH is already installed.${RC}"
|
|
|
|
fi
|
2024-08-08 21:54:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Function to setup zsh configuration
|
2024-09-17 03:10:02 +01:00
|
|
|
setupZshConfig() {
|
2024-09-19 01:35:00 +01:00
|
|
|
printf "%b\n" "${YELLOW}Setting up Zsh configuration...${RC}"
|
2024-08-08 21:54:37 +01:00
|
|
|
CONFIG_DIR="$HOME/.config/zsh"
|
|
|
|
ZSHRC_FILE="$CONFIG_DIR/.zshrc"
|
|
|
|
|
|
|
|
if [ ! -d "$CONFIG_DIR" ]; then
|
|
|
|
mkdir -p "$CONFIG_DIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Write the configuration to .zshrc
|
|
|
|
cat <<EOL >"$ZSHRC_FILE"
|
|
|
|
HISTFILE=~/.config/zsh/.histfile
|
|
|
|
HISTSIZE=5000
|
|
|
|
SAVEHIST=100000
|
|
|
|
setopt autocd extendedglob
|
|
|
|
unsetopt beep
|
|
|
|
bindkey -v
|
|
|
|
|
|
|
|
# Configure the prompt with embedded Solarized color codes
|
|
|
|
PROMPT='%F{32}%n%f%F{166}@%f%F{64}%m:%F{166}%~%f%F{15}$%f '
|
|
|
|
RPROMPT='%F{15}(%F{166}%D{%H:%M}%F{15})%f'
|
|
|
|
EOL
|
|
|
|
|
|
|
|
# Ensure /etc/zsh/zshenv sets ZDOTDIR to the user's config directory
|
2024-10-08 22:40:15 +01:00
|
|
|
[ ! -f /etc/zsh/zshenv ] && "$ESCALATION_TOOL" mkdir -p /etc/zsh && "$ESCALATION_TOOL" touch /etc/zsh/zshenv
|
2024-09-22 17:01:10 +01:00
|
|
|
echo "export ZDOTDIR=\"$HOME/.config/zsh\"" | "$ESCALATION_TOOL" tee -a /etc/zsh/zshenv
|
2024-08-08 21:54:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
checkEnv
|
2024-08-23 14:12:47 +01:00
|
|
|
checkEscalationTool
|
2024-09-17 03:10:02 +01:00
|
|
|
installZsh
|
|
|
|
setupZshConfig
|