143 lines
3.6 KiB
Bash
Executable File
143 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#=============================================================================
|
|
# ZSH + Oh-My-Zsh Installation Script
|
|
#=============================================================================
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "${SCRIPT_DIR}/lib.sh"
|
|
|
|
init_installer
|
|
|
|
print_header "ZSH Shell Setup"
|
|
|
|
# Install ZSH and plugins
|
|
zsh_pkgs=(
|
|
zsh
|
|
zsh-autosuggestions
|
|
zsh-syntax-highlighting
|
|
zsh-completions
|
|
)
|
|
|
|
echo -e "${NOTE} Installing ZSH packages..."
|
|
install_packages_sequential "${zsh_pkgs[@]}"
|
|
|
|
# Install Oh-My-Zsh
|
|
if [[ ! -d "$HOME/.oh-my-zsh" ]]; then
|
|
echo -e "\n${NOTE} Installing Oh-My-Zsh..."
|
|
|
|
# Download and install Oh-My-Zsh
|
|
export RUNZSH=no
|
|
export CHSH=no
|
|
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
|
|
|
echo -e "${OK} Oh-My-Zsh installed."
|
|
else
|
|
echo -e "${INFO} Oh-My-Zsh already installed."
|
|
fi
|
|
|
|
# Install additional plugins
|
|
echo -e "\n${NOTE} Installing additional plugins..."
|
|
|
|
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
|
|
|
|
# Powerlevel10k theme (optional, fast)
|
|
if [[ ! -d "$ZSH_CUSTOM/themes/powerlevel10k" ]]; then
|
|
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
|
|
"$ZSH_CUSTOM/themes/powerlevel10k" 2>/dev/null || true
|
|
fi
|
|
|
|
# zsh-autosuggestions plugin
|
|
if [[ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]]; then
|
|
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions \
|
|
"$ZSH_CUSTOM/plugins/zsh-autosuggestions" 2>/dev/null || true
|
|
fi
|
|
|
|
# zsh-syntax-highlighting plugin
|
|
if [[ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]]; then
|
|
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting \
|
|
"$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" 2>/dev/null || true
|
|
fi
|
|
|
|
# Create optimized .zshrc
|
|
echo -e "\n${NOTE} Creating optimized .zshrc..."
|
|
|
|
# Backup existing .zshrc
|
|
[[ -f "$HOME/.zshrc" ]] && cp "$HOME/.zshrc" "$HOME/.zshrc.backup"
|
|
|
|
cat << 'EOF' > "$HOME/.zshrc"
|
|
# Optimized ZSH Configuration
|
|
# Generated by Hyprland Installer
|
|
|
|
# Performance: Disable compinit check
|
|
skip_global_compinit=1
|
|
|
|
# Oh-My-Zsh configuration
|
|
export ZSH="$HOME/.oh-my-zsh"
|
|
|
|
# Theme - choose one:
|
|
# ZSH_THEME="powerlevel10k/powerlevel10k"
|
|
ZSH_THEME="agnoster"
|
|
|
|
# Plugins (keep minimal for performance)
|
|
plugins=(
|
|
git
|
|
sudo
|
|
zsh-autosuggestions
|
|
zsh-syntax-highlighting
|
|
)
|
|
|
|
# Performance: Lazy load completions
|
|
autoload -Uz compinit
|
|
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
|
|
compinit
|
|
else
|
|
compinit -C
|
|
fi
|
|
|
|
source $ZSH/oh-my-zsh.sh
|
|
|
|
# User configuration
|
|
export EDITOR='nano'
|
|
export VISUAL='nano'
|
|
|
|
# Aliases
|
|
alias ls='ls --color=auto'
|
|
alias ll='ls -lah'
|
|
alias grep='grep --color=auto'
|
|
alias update='sudo pacman -Syu'
|
|
alias cleanup='sudo pacman -Rns $(pacman -Qtdq) 2>/dev/null || echo "No orphans"'
|
|
|
|
# Hyprland specific
|
|
alias hypr='Hyprland'
|
|
alias hyprconf='$EDITOR ~/.config/hypr/hyprland.conf'
|
|
|
|
# History configuration (optimized)
|
|
HISTSIZE=5000
|
|
SAVEHIST=5000
|
|
HISTFILE=~/.zsh_history
|
|
setopt HIST_IGNORE_DUPS
|
|
setopt HIST_IGNORE_SPACE
|
|
setopt SHARE_HISTORY
|
|
|
|
# Key bindings
|
|
bindkey '^[[A' history-search-backward
|
|
bindkey '^[[B' history-search-forward
|
|
|
|
# Fastfetch on terminal start (optional)
|
|
# command -v fastfetch &>/dev/null && fastfetch
|
|
EOF
|
|
|
|
# Change default shell to ZSH
|
|
echo -e "\n${NOTE} Setting ZSH as default shell..."
|
|
if [[ "$SHELL" != *"zsh"* ]]; then
|
|
chsh -s "$(which zsh)" 2>/dev/null || {
|
|
echo -e "${WARN} Could not change shell automatically."
|
|
echo -e "${NOTE} Run: chsh -s \$(which zsh)"
|
|
}
|
|
fi
|
|
|
|
echo -e "\n${OK} ZSH setup complete!"
|
|
echo -e "${NOTE} Log out and back in, or run 'zsh' to start using ZSH."
|