feat: Add eza aliases for enhanced directory listing and update setup scripts for package management

This commit is contained in:
Peter Wood
2025-05-28 11:44:27 -04:00
parent c579a5b0d6
commit c76024e6e5
6 changed files with 222 additions and 86 deletions

View File

@@ -16,20 +16,7 @@ NC='\033[0m' # No Color
MAX_INSTALL_ATTEMPTS=3
CURRENT_ATTEMPT=1
# Log file
# C log_both "\n${BLUE}Debugging lolcat package:${NC}" "Debugging lolcat package:"
if [ -f "/usr/games/lolcat" ]; then
log_both "- Lolcat found at /usr/games/lolcat"
ls -la /usr/games/lolcat >> "$LOG_FILE"
else
log_both "- Lolcat not found at /usr/games/lolcat"
fi
if check_command lolcat; then
log_both "- Lolcat found in PATH"
command -v lolcat >> "$LOG_FILE"
else
log_both "- Lolcat not found in PATH"
firectory if it doesn't exist and is writable
# Log file setup - Try to use /logs directory if it doesn't exist and is writable
# First, try creating the logs directory in case it doesn't exist
if [ -d "/logs" ] || mkdir -p /logs 2>/dev/null; then
if [ -w "/logs" ]; then
@@ -68,10 +55,10 @@ echo "Starting setup test at $(date)" > "$LOG_FILE" || {
log_both() {
local colored_message="$1"
local clean_message="$2"
# Display colored message to terminal
echo -e "$colored_message"
# Log clean message to file
if [ -n "$clean_message" ]; then
echo "$clean_message" >> "$LOG_FILE"
@@ -134,9 +121,9 @@ test_package() {
local pkg=$1
local cmd=${2:-$1}
local alt_cmd=$3 # Optional alternative command name
echo -en "Testing if $pkg is installed... "
# Special case for cowsay and lolcat which might be in different paths
if [ "$pkg" = "cowsay" ]; then
if check_command "$cmd"; then
@@ -208,7 +195,7 @@ test_file_exists() {
# Get actual package name based on distribution
get_package_name() {
local pkg=$1
# Handle Debian-specific package name differences
if [[ "$ID" == "debian" ]]; then
case "$pkg" in
@@ -230,16 +217,16 @@ install_missing_packages() {
local packages=("$@")
local install_cmd_name
local install_cmd=()
if [ ${#packages[@]} -eq 0 ]; then
echo -e "${GREEN}No packages to install${NC}"
echo "No packages to install" >> "$LOG_FILE"
return 0
fi
echo -e "\n${BLUE}=== Installing missing packages (Attempt $CURRENT_ATTEMPT of $MAX_INSTALL_ATTEMPTS) ===${NC}"
echo "=== Installing missing packages (Attempt $CURRENT_ATTEMPT of $MAX_INSTALL_ATTEMPTS) ===" >> "$LOG_FILE"
# Determine the best installation command
if check_command nala; then
install_cmd=(sudo DEBIAN_FRONTEND=noninteractive nala install -y)
@@ -252,14 +239,14 @@ install_missing_packages() {
echo -e "${YELLOW}Using apt-get for package installation${NC}"
echo "Using apt-get for package installation" >> "$LOG_FILE"
fi
# Convert package list to distribution-specific names
local install_list=()
for pkg in "${packages[@]}"; do
local actual_pkg=$(get_package_name "$pkg")
install_list+=("$actual_pkg")
done
# Update package lists
echo -e "${YELLOW}Updating package lists...${NC}"
echo "Updating package lists" >> "$LOG_FILE"
@@ -270,30 +257,30 @@ install_missing_packages() {
echo -e "${GREEN}Running: sudo DEBIAN_FRONTEND=noninteractive apt-get update${NC}"
sudo DEBIAN_FRONTEND=noninteractive apt-get update | tee -a "$LOG_FILE"
fi
# Install packages
echo -e "${YELLOW}Installing packages: ${install_list[*]}${NC}"
echo "Installing packages: ${install_list[*]}" >> "$LOG_FILE"
# Show the exact command being run for debugging
echo -e "${BLUE}Running: ${install_cmd[*]} ${install_list[*]}${NC}"
# Execute the install command with the package list
if ! "${install_cmd[@]}" "${install_list[@]}" 2>&1 | tee -a "$LOG_FILE"; then
echo -e "${RED}Failed to install some packages. Check the log for details.${NC}"
echo "Failed to install some packages" >> "$LOG_FILE"
# Try to install packages one by one to identify problematic ones
echo -e "${YELLOW}Trying to install packages individually...${NC}"
echo "Trying to install packages individually" >> "$LOG_FILE"
installed_this_round=()
local failed_this_round=()
for i in "${!packages[@]}"; do
local pkg="${packages[$i]}"
local actual_pkg="${install_list[$i]}"
echo -en "Installing $pkg as $actual_pkg... "
if "${install_cmd[@]}" "$actual_pkg" >> "$LOG_FILE" 2>&1; then
echo -e "${GREEN}${NC}"
@@ -305,7 +292,7 @@ install_missing_packages() {
failed_this_round+=("$pkg")
fi
done
failed_packages=("${failed_this_round[@]}")
return 1
else
@@ -391,10 +378,10 @@ fi
if [ -f "$HOME/shell/setup/packages.list" ]; then
echo -e "${YELLOW}Testing package availability in repositories:${NC}"
echo "Testing package availability:" >> "$LOG_FILE"
# Exclude commented lines and empty lines
packages=$(grep -v '^//' "$HOME/shell/setup/packages.list" | grep -v -e '^$')
for pkg in $packages; do
echo -en "Checking if $pkg is available in repos... "
actual_pkg=$(get_package_name "$pkg")
@@ -441,7 +428,7 @@ while [ $CURRENT_ATTEMPT -le $MAX_INSTALL_ATTEMPTS ]; do
if [ -f "$HOME/shell/setup/packages.list" ]; then
# Exclude commented lines and empty lines
packages=$(grep -v '^//' "$HOME/shell/setup/packages.list" | grep -v -e '^$')
for pkg in $packages; do
case "$pkg" in
"bat")
@@ -465,7 +452,7 @@ while [ $CURRENT_ATTEMPT -le $MAX_INSTALL_ATTEMPTS ]; do
else
log_both "- Cowsay not found in PATH"
fi
if ! test_package "cowsay" "cowsay"; then
((errors++))
missing_packages+=("$pkg")
@@ -486,7 +473,7 @@ while [ $CURRENT_ATTEMPT -le $MAX_INSTALL_ATTEMPTS ]; do
else
echo -e "- Lolcat not found in PATH" | tee -a "$LOG_FILE"
fi
if ! test_package "lolcat" "lolcat"; then
((errors++))
missing_packages+=("$pkg")
@@ -500,24 +487,24 @@ while [ $CURRENT_ATTEMPT -le $MAX_INSTALL_ATTEMPTS ]; do
;;
esac
done
# Report missing packages
if [ ${#missing_packages[@]} -gt 0 ]; then
echo -e "\n${YELLOW}Missing packages:${NC}"
for pkg in "${missing_packages[@]}"; do
echo -e "- ${RED}$pkg${NC}"
done
# Count installed vs. total packages
total_pkgs=$(grep -v '^//' "$HOME/shell/setup/packages.list" | grep -v -e '^$' | wc -l)
installed_pkgs=$((total_pkgs - ${#missing_packages[@]}))
echo -e "${GREEN}$installed_pkgs of $total_pkgs packages installed${NC} (${YELLOW}${#missing_packages[@]} missing${NC})"
echo "$installed_pkgs of $total_pkgs packages installed (${#missing_packages[@]} missing)" >> "$LOG_FILE"
# Install missing packages if we haven't reached the maximum attempts
if [ $CURRENT_ATTEMPT -lt $MAX_INSTALL_ATTEMPTS ]; then
install_missing_packages "${missing_packages[@]}"
echo -e "\n${BLUE}=== Installation Results ===${NC}"
if [ ${#installed_this_round[@]} -gt 0 ]; then
echo -e "${GREEN}Successfully installed:${NC}"
@@ -526,7 +513,7 @@ while [ $CURRENT_ATTEMPT -le $MAX_INSTALL_ATTEMPTS ]; do
done
echo "Successfully installed: ${installed_this_round[*]}" >> "$LOG_FILE"
fi
if [ ${#failed_packages[@]} -gt 0 ]; then
echo -e "${RED}Failed to install:${NC}"
for pkg in "${failed_packages[@]}"; do
@@ -534,7 +521,7 @@ while [ $CURRENT_ATTEMPT -le $MAX_INSTALL_ATTEMPTS ]; do
done
echo "Failed to install: ${failed_packages[*]}" >> "$LOG_FILE"
fi
CURRENT_ATTEMPT=$((CURRENT_ATTEMPT + 1))
echo -e "\n${YELLOW}Continuing to next test iteration...${NC}"
echo "Continuing to next test iteration" >> "$LOG_FILE"
@@ -550,7 +537,7 @@ while [ $CURRENT_ATTEMPT -le $MAX_INSTALL_ATTEMPTS ]; do
echo -e "${RED}packages.list file not found at $HOME/shell/setup/packages.list${NC}"
echo "packages.list file not found" >> "$LOG_FILE"
fi
# If no missing packages or we've reached max attempts, break out of the loop
if [ ${#missing_packages[@]} -eq 0 ] || [ $CURRENT_ATTEMPT -ge $MAX_INSTALL_ATTEMPTS ]; then
break
@@ -563,11 +550,11 @@ done
if [ -d "$HOME/.nvm" ]; then
echo -e "NVM: ${GREEN}Installed${NC}"
echo "NVM: Installed" >> "$LOG_FILE"
# Source NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# Test Node.js installed by NVM
if check_command node; then
node_version=$(node -v)
@@ -619,7 +606,7 @@ for dotfile in "${dotfiles[@]}"; do
if [ -L "$dotfile" ]; then
echo -e "Dotfile $dotfile: ${GREEN}Symlinked${NC}"
echo "Dotfile $dotfile: Symlinked" >> "$LOG_FILE"
# Check if symlink is valid
if [ -e "$dotfile" ]; then
target=$(readlink -f "$dotfile")
@@ -649,7 +636,7 @@ if [ $errors -eq 0 ]; then
else
echo -e "${RED}Found $errors potential issues with your setup.${NC}"
echo "Result: Found $errors potential issues" >> "$LOG_FILE"
# Display missing packages if any
if [ ${#missing_packages[@]} -gt 0 ]; then
echo -e "\n${YELLOW}The following packages were not found:${NC}"
@@ -658,13 +645,13 @@ else
echo -e " - ${RED}$pkg${NC}"
echo " - $pkg" >> "$LOG_FILE"
done
if [ $CURRENT_ATTEMPT -gt $MAX_INSTALL_ATTEMPTS ]; then
echo -e "\n${RED}Reached maximum installation attempts ($MAX_INSTALL_ATTEMPTS).${NC}"
echo -e "${YELLOW}Some packages could not be installed automatically.${NC}"
echo "Reached maximum installation attempts" >> "$LOG_FILE"
fi
echo -e "\n${BLUE}You can manually install these packages with:${NC}"
echo -e " sudo apt-get install ${missing_packages[*]}"
fi
@@ -688,12 +675,12 @@ if [[ "$ID" == "debian" ]]; then
echo "1. Ensure Debian's 'universe' equivalent repositories are enabled (contrib, non-free)"
echo "2. Some packages like 'bat' may have different names in Debian (batcat)"
echo "3. Consider adding Debian-specific adjustments to setup.sh"
# Add specific Debian package name mappings
echo -e "\nOn Debian, you may need these package name adjustments:"
echo " - bat → batcat"
echo " - (add more as needed)"
echo "Debian package name mappings may be required" >> "$LOG_FILE"
fi
@@ -701,16 +688,16 @@ fi
check_bootstrapped_environment() {
echo -e "\n${BLUE}=== Checking for bootstrapped environment ===${NC}"
echo "=== Checking for bootstrapped environment ===" >> "$LOG_FILE"
if [ -d "$HOME/shell" ] && [ -f "$HOME/shell/bootstrap.sh" ]; then
echo -e "${GREEN}Environment appears to be bootstrapped:${NC}"
echo "Environment is bootstrapped" >> "$LOG_FILE"
# Check the shell repository structure
if [ -d "$HOME/shell/setup" ] && [ -f "$HOME/shell/setup/setup.sh" ]; then
echo -e " - ${GREEN}Setup directory and script present${NC}"
echo "Setup directory and script: Present" >> "$LOG_FILE"
# Check if setup.sh is executable
if [ -x "$HOME/shell/setup/setup.sh" ]; then
echo -e " - ${GREEN}Setup script is executable${NC}"
@@ -723,12 +710,12 @@ check_bootstrapped_environment() {
echo -e " - ${RED}Setup directory or setup.sh missing${NC}"
echo "Setup directory or setup.sh: Missing" >> "$LOG_FILE"
fi
# Check packages.list
if [ -f "$HOME/shell/setup/packages.list" ]; then
echo -e " - ${GREEN}Packages list present${NC}"
echo "Packages list: Present" >> "$LOG_FILE"
# Count packages in list
pkg_count=$(grep -v '^//' "$HOME/shell/setup/packages.list" | grep -v -e '^$' | wc -l)
echo -e " - ${GREEN}Package list contains $pkg_count packages${NC}"
@@ -737,12 +724,12 @@ check_bootstrapped_environment() {
echo -e " - ${RED}Packages list missing${NC}"
echo "Packages list: Missing" >> "$LOG_FILE"
fi
# Check dotfiles directory
if [ -d "$HOME/shell/dotfiles" ]; then
echo -e " - ${GREEN}Dotfiles directory present${NC}"
echo "Dotfiles directory: Present" >> "$LOG_FILE"
# Check if dotfiles are properly symlinked
dotfiles_linked=true
for dotfile in "$HOME/.zshrc" "$HOME/.nanorc" "$HOME/.profile" "$HOME/.gitconfig"; do
@@ -759,7 +746,7 @@ check_bootstrapped_environment() {
break
fi
done
if $dotfiles_linked; then
echo -e " - ${GREEN}Dotfiles are properly symlinked${NC}"
echo "Dotfiles symlinked: Yes" >> "$LOG_FILE"