linutil/tabs/applications-setup/zsh-setup.sh

53 lines
1.2 KiB
Bash
Raw Normal View History

2024-08-08 21:54:37 +01:00
#!/bin/sh
. ../common-script.sh
2024-08-08 21:54:37 +01:00
# Function to install zsh
install_zsh() {
printf "%b\n" "${YELLOW}Install ZSH if not already installed...${RC}"
2024-08-08 21:54:37 +01:00
if ! command_exists zsh; then
case "$PACKAGER" in
pacman)
2024-08-23 14:12:47 +01:00
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm zsh
2024-08-08 21:54:37 +01:00
;;
*)
2024-08-23 14:12:47 +01:00
$ESCALATION_TOOL "$PACKAGER" install -y zsh
2024-08-08 21:54:37 +01:00
;;
esac
else
printf "%b\n" "${GREEN}ZSH is already installed.${RC}"
2024-08-08 21:54:37 +01:00
fi
}
# Function to setup zsh configuration
setup_zsh_config() {
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-08-23 14:12:47 +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
install_zsh
2024-08-23 14:12:47 +01:00
setup_zsh_config