Commit local changes before merging with remote

This commit is contained in:
Peter Wood
2025-05-29 11:25:02 -04:00
parent 868b340fb5
commit be4f6a8d8c
75 changed files with 14107 additions and 562 deletions

View File

@@ -39,7 +39,7 @@ determine_pkg_manager() {
# Set up package management based on OS
if [ "$OS_NAME" = "fedora" ]; then
echo -e "${YELLOW}Setting up Fedora Tsrepositories and package management...${NC}"
echo -e "${YELLOW}Setting up Fedora repositories and package management...${NC}"
# Install prerequisites for Fedora
sudo dnf install -y wget gpg
@@ -55,6 +55,14 @@ if [ "$OS_NAME" = "fedora" ]; then
# Use a different approach to add the GitHub CLI repo to avoid the "--add-repo" error
sudo curl -fsSL https://cli.github.com/packages/rpm/gh-cli.repo -o /etc/yum.repos.d/gh-cli.repo
# Setup COPR repository for eza
echo -e "${YELLOW}Setting up COPR repository for eza...${NC}"
sudo dnf copr enable -y alternateved/eza
# Setup COPR repository for lazygit
echo -e "${YELLOW}Setting up COPR repository for lazygit...${NC}"
sudo dnf copr enable -y shaps/lazygit
# Update package lists
echo -e "${YELLOW}Updating package lists for Fedora...${NC}"
sudo dnf check-update -y || true
@@ -90,6 +98,19 @@ else
fi
fi
# Setup eza repository for Ubuntu/Debian
echo -e "${YELLOW}Setting up eza repository...${NC}"
if ! apt-cache show eza &>/dev/null; then
# Add eza repository for older Ubuntu/Debian versions
echo -e "${YELLOW}Adding eza repository...${NC}"
sudo mkdir -p -m 755 /etc/apt/keyrings
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
else
echo -e "${GREEN}Eza is available in standard repositories${NC}"
fi
# Setup VS Code repository
echo -e "${YELLOW}Setting up VS Code repository...${NC}"
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/packages.microsoft.gpg
@@ -130,22 +151,40 @@ PKG_MANAGER=$(determine_pkg_manager)
echo -e "${GREEN}Using package manager: $PKG_MANAGER${NC}"
# Load packages from package list
mapfile -t pkgs < <(grep -v '^//' "$SCRIPT_DIR/packages.list" | grep -v -e '^$')
mapfile -t pkgs < <(grep -v '^//' "$SCRIPT_DIR/packages.list" | grep -v -e '^$' | sed 's|//.*||' | awk '{print $1}' | grep -v '^$')
# Map Debian/Ubuntu package names to Fedora equivalents if needed
declare -A fedora_pkg_map
fedora_pkg_map["bat"]="bat"
fedora_pkg_map["fd-find"]="fd" # On Fedora, the package is called 'fd'
# eza is available from COPR repository
fedora_pkg_map["eza"]="eza"
# lazygit is available from COPR repository
fedora_pkg_map["lazygit"]="lazygit"
# lazydocker will be installed manually from GitHub releases
# Add more package mappings as needed
# Process the package list based on OS
install_pkg_list=()
special_installs=()
for pkg in "${pkgs[@]}"; do
# Skip nala package on non-Debian/Ubuntu systems
if [ "$pkg" = "nala" ] && [ "$OS_NAME" != "ubuntu" ] && [ "$OS_NAME" != "debian" ]; then
continue
fi
# Handle packages that need special installation
if [ "$pkg" = "lazydocker" ]; then
special_installs+=("$pkg")
continue
fi
# Handle lazygit - available in COPR for Fedora, special install for Debian/Ubuntu
if [ "$pkg" = "lazygit" ] && [ "$OS_NAME" != "fedora" ]; then
special_installs+=("$pkg")
continue
fi
# Check if we need to map the package name for Fedora
if [ "$OS_NAME" = "fedora" ] && [[ -n "${fedora_pkg_map[$pkg]}" ]]; then
install_pkg_list+=("${fedora_pkg_map[$pkg]}")
@@ -165,10 +204,13 @@ case $PKG_MANAGER in
sudo rm -f /etc/apt/sources.list.d/nala-sources.list 2>/dev/null
# Try to fetch mirrors with less aggressive settings
if ! sudo nala fetch --auto --fetches 1 --country auto; then
echo -e "${YELLOW}Mirror selection failed, continuing with system default mirrors...${NC}"
echo -e "${YELLOW}Attempting to find faster mirrors (this may fail and that's okay)...${NC}"
if ! sudo nala fetch --auto --fetches 1 --country auto 2>/dev/null; then
echo -e "${YELLOW}Note: Fast mirror selection failed, using default mirrors (this is normal and safe)${NC}"
# Remove any potentially corrupted Nala sources
sudo rm -f /etc/apt/sources.list.d/nala-sources.list 2>/dev/null
else
echo -e "${GREEN}Fast mirrors configured successfully!${NC}"
fi
# Install packages using Nala
@@ -189,6 +231,44 @@ esac
echo -e "${GREEN}Package installation completed for $OS_NAME $OS_VERSION.${NC}"
# Handle special installations that aren't available through package managers
echo -e "${YELLOW}Installing special packages...${NC}"
for pkg in "${special_installs[@]}"; do
case $pkg in
"lazydocker")
if ! command -v lazydocker &> /dev/null; then
echo -e "${YELLOW}Installing Lazydocker from GitHub releases...${NC}"
LAZYDOCKER_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazydocker/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazydocker.tar.gz "https://github.com/jesseduffield/lazydocker/releases/latest/download/lazydocker_${LAZYDOCKER_VERSION}_Linux_x86_64.tar.gz"
mkdir -p lazydocker-temp
tar xf lazydocker.tar.gz -C lazydocker-temp
sudo mv lazydocker-temp/lazydocker /usr/local/bin
rm -rf lazydocker-temp lazydocker.tar.gz
echo -e "${GREEN}Lazydocker installed successfully!${NC}"
else
echo -e "${GREEN}Lazydocker is already installed${NC}"
fi
;;
"lazygit")
if ! command -v lazygit &> /dev/null; then
echo -e "${YELLOW}Installing Lazygit from GitHub releases...${NC}"
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
mkdir -p lazygit-temp
tar xf lazygit.tar.gz -C lazygit-temp
sudo mv lazygit-temp/lazygit /usr/local/bin
rm -rf lazygit-temp lazygit.tar.gz
echo -e "${GREEN}Lazygit installed successfully!${NC}"
else
echo -e "${GREEN}Lazygit is already installed${NC}"
fi
;;
*)
echo -e "${YELLOW}Unknown special package: $pkg${NC}"
;;
esac
done
# Install Zsh if not already installed
echo -e "${YELLOW}Installing Zsh...${NC}"
if ! command -v zsh &> /dev/null; then
@@ -247,20 +327,6 @@ else
echo -e "${YELLOW}Warning: nvm installation may require a new shell session${NC}"
fi
# Install Lazydocker (not available in apt repositories)
echo -e "${YELLOW}Installing Lazydocker...${NC}"
if ! command -v lazydocker &> /dev/null; then
LAZYDOCKER_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazydocker/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazydocker.tar.gz "https://github.com/jesseduffield/lazydocker/releases/latest/download/lazydocker_${LAZYDOCKER_VERSION}_Linux_x86_64.tar.gz"
mkdir -p lazydocker-temp
tar xf lazydocker.tar.gz -C lazydocker-temp
sudo mv lazydocker-temp/lazydocker /usr/local/bin
rm -rf lazydocker-temp lazydocker.tar.gz
echo -e "${GREEN}Lazydocker installed successfully!${NC}"
else
echo -e "Lazydocker is already installed"
fi
# Define a reusable function for cloning Zsh plugins
clone_zsh_plugin() {
local plugin_url=$1
@@ -279,6 +345,24 @@ clone_zsh_plugin "https://github.com/zsh-users/zsh-autosuggestions" "$PLUGINS_DI
clone_zsh_plugin "https://github.com/zsh-users/zsh-syntax-highlighting" "$PLUGINS_DIR/zsh-syntax-highlighting"
clone_zsh_plugin "https://github.com/MichaelAquilina/zsh-you-should-use" "$PLUGINS_DIR/zsh-you-should-use"
# Set up bash completion for backup scripts
echo -e "${YELLOW}Setting up bash completion for backup scripts...${NC}"
COMPLETION_SCRIPT="$DOTFILES_DIR/completions/backup-scripts-completion.bash"
if [ -f "$COMPLETION_SCRIPT" ]; then
# Create completions directory in home
mkdir -p "$HOME/.local/share/bash-completion/completions"
# Copy completion script to user's completion directory
cp "$COMPLETION_SCRIPT" "$HOME/.local/share/bash-completion/completions/"
# Make sure it's executable
chmod +x "$HOME/.local/share/bash-completion/completions/backup-scripts-completion.bash"
echo -e "${GREEN}Bash completion script installed successfully!${NC}"
else
echo -e "${YELLOW}Warning: Bash completion script not found at $COMPLETION_SCRIPT${NC}"
fi
# Set up dotfiles
echo -e "${YELLOW}Setting up dotfiles...${NC}"
# Consolidate symbolic link creation for dotfiles
@@ -294,10 +378,23 @@ ALIASES_FILE="$ZSH_CUSTOM/aliases.zsh"
mkdir -p "$ZSH_CUSTOM"
# Create a copy of the original aliases file for backup
cp "$DOTFILES_SUBDIR/my-aliases.zsh" "$ALIASES_FILE.bak"
cp "$DOTFILES_SUBDIR/my-aliases.zsh.original" "$ALIASES_FILE.bak"
# First, copy all general aliases except those we'll modify based on OS
grep -v "alias cat=" "$DOTFILES_SUBDIR/my-aliases.zsh" | grep -v "alias fd=" | grep -v "alias fzf=" > "$ALIASES_FILE"
# First, copy all general aliases except those we'll modify based on OS and available commands
grep -v "^alias cat=" "$DOTFILES_SUBDIR/my-aliases.zsh.original" | \
grep -v "^alias fd=" | \
grep -v "^alias fzf=" | \
grep -v "^alias ls=" | \
grep -v "^alias ll=" | \
grep -v "^alias la=" | \
grep -v "^alias l=" | \
grep -v "^alias tree=" | \
grep -v "^alias lt=" | \
grep -v "^alias llt=" | \
grep -v "^alias lg=" | \
grep -v "^alias lh=" | \
grep -v "^alias lr=" | \
grep -v "^alias lx=" > "$ALIASES_FILE"
# Function to check for command existence and add appropriate alias
add_conditional_alias() {
@@ -342,13 +439,39 @@ if command -v fzf &> /dev/null; then
fi
fi
# Also create a symlink from the custom aliases file back to the dotfiles directory for persistence
# This allows changes made to aliases.zsh to be tracked in the dotfiles repo
echo -e "${YELLOW}Creating symlink to save customized aliases back to dotfiles...${NC}"
# Set up eza aliases if eza is available
if command -v eza &> /dev/null; then
echo -e "${YELLOW}Setting up eza aliases...${NC}"
cat >> "$ALIASES_FILE" << 'EOF'
# 🌟 Eza aliases - Modern replacement for ls
alias ls="eza --icons=always -a --color=auto --group-directories-first"
alias la="eza --icons=always -la --color=auto --group-directories-first"
alias ll="eza --icons=always -la --classify=always -h --color=auto --group-directories-first"
alias l="eza --icons=always -1 -a --color=auto --group-directories-first"
alias lt="eza --icons=always -a --tree --level=2 --color=auto --group-directories-first"
alias llt="eza --icons=always -la --tree --level=2 --color=auto --group-directories-first"
alias lg="eza --icons=always -la --git --color=auto --group-directories-first"
alias lh="eza --icons=always -la --color=auto --group-directories-first --sort=size"
alias lr="eza --icons=always -la --color=auto --group-directories-first --sort=modified"
alias lx="eza --icons=always -la --color=auto --group-directories-first --sort=extension"
alias tree="eza --icons=always -a --tree --color=auto --group-directories-first"
EOF
echo -e "${GREEN}Eza aliases configured successfully!${NC}"
else
echo -e "${YELLOW}Eza not found. Using traditional ls aliases.${NC}"
cat >> "$ALIASES_FILE" << 'EOF'
# Traditional ls aliases
alias ll="ls -laFh --group-directories-first --color=auto"
EOF
fi
# Save the customized aliases to the dotfiles directory for reference
echo -e "${YELLOW}Saving customized aliases to dotfiles directory...${NC}"
if [ -f "$ALIASES_FILE" ]; then
# Save a copy of the original for reference
cp "$DOTFILES_SUBDIR/my-aliases.zsh" "$DOTFILES_SUBDIR/my-aliases.zsh.original" 2>/dev/null || true
# Replace the my-aliases.zsh with the new customized one
# Copy the customized aliases to the dotfiles directory as my-aliases.zsh
# This file will be ignored by git but serves as a local reference
cp "$ALIASES_FILE" "$DOTFILES_SUBDIR/my-aliases.zsh"
fi