chore: Updated font installation 14ab15de
Steve Simkins · 2025-06-25 14:24 1 file(s) · +86 −22
install.sh +86 −22
1 1
#!/bin/bash
2 2
3 -
# Terminal Setup - Opinionated terminal configuration installer
3 +
# Darkmatter Terminal Setup - Opinionated terminal configuration installer
4 4
# Requires: Homebrew (https://brew.sh)
5 5
6 6
set -e  # Exit on any error
42 42
# Install packages via Homebrew
43 43
install_packages() {
44 44
    print_status "Installing packages via Homebrew..."
45 -
    
45 +
46 46
    local packages=(
47 47
        "zsh"
48 -
        "zsh-autosuggestions" 
48 +
        "zsh-autosuggestions"
49 49
        "zsh-syntax-highlighting"
50 50
        "starship"
51 51
        "eza"
52 52
        "zoxide"
53 53
    )
54 -
    
54 +
55 55
    local cask_packages=(
56 56
        "ghostty"
57 57
    )
58 -
    
58 +
59 59
    # Install regular packages
60 60
    for package in "${packages[@]}"; do
61 61
        print_status "Installing $package..."
66 66
            print_success "Installed $package"
67 67
        fi
68 68
    done
69 -
    
69 +
70 70
    # Install cask packages
71 71
    for package in "${cask_packages[@]}"; do
72 72
        print_status "Installing $package (cask)..."
82 82
# Backup existing config files
83 83
backup_configs() {
84 84
    print_status "Backing up existing configuration files..."
85 -
    
85 +
86 86
    local timestamp=$(date +%Y%m%d_%H%M%S)
87 87
    local backup_dir="$HOME/.config_backup_$timestamp"
88 -
    
88 +
89 89
    mkdir -p "$backup_dir"
90 -
    
90 +
91 91
    if [ -f "$HOME/.zshrc" ]; then
92 92
        cp "$HOME/.zshrc" "$backup_dir/"
93 93
        print_success "Backed up .zshrc to $backup_dir"
94 94
    fi
95 -
    
95 +
96 96
    if [ -f "$HOME/.config/ghostty/config" ]; then
97 97
        cp "$HOME/.config/ghostty/config" "$backup_dir/"
98 98
        print_success "Backed up ghotty config to $backup_dir"
99 99
    fi
100 -
    
100 +
101 101
    if [ -f "$HOME/.config/starship.toml" ]; then
102 102
        mkdir -p "$backup_dir/.config"
103 103
        cp "$HOME/.config/starship.toml" "$backup_dir/.config/"
105 105
    fi
106 106
}
107 107
108 +
# Install fonts from assets directory
109 +
install_fonts() {
110 +
    print_status "Installing CommitMono Nerd Font..."
111 +
112 +
    local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
113 +
    local assets_dir="$script_dir/assets"
114 +
115 +
    if [ ! -d "$assets_dir" ]; then
116 +
        print_warning "Assets directory not found, skipping font installation"
117 +
        return
118 +
    fi
119 +
120 +
    # Create user fonts directory
121 +
    local user_fonts_dir="$HOME/Library/Fonts"
122 +
    mkdir -p "$user_fonts_dir"
123 +
124 +
    # Count fonts to install
125 +
    local font_count=0
126 +
    for font_file in "$assets_dir"/*.{otf,ttf,OTF,TTF}; do
127 +
        [ -f "$font_file" ] && ((font_count++))
128 +
    done
129 +
130 +
    if [ $font_count -eq 0 ]; then
131 +
        print_warning "No font files found in assets directory"
132 +
        return
133 +
    fi
134 +
135 +
    print_status "Found $font_count CommitMono font files to install"
136 +
137 +
    # Install fonts
138 +
    local installed_count=0
139 +
    for font_file in "$assets_dir"/*.{otf,ttf,OTF,TTF}; do
140 +
        if [ -f "$font_file" ]; then
141 +
            local font_name=$(basename "$font_file")
142 +
            local dest_file="$user_fonts_dir/$font_name"
143 +
144 +
            # Check if font already exists
145 +
            if [ -f "$dest_file" ]; then
146 +
                print_warning "Font $font_name already installed, skipping"
147 +
            else
148 +
                cp "$font_file" "$dest_file"
149 +
                print_success "Installed font: $font_name"
150 +
                ((installed_count++))
151 +
            fi
152 +
        fi
153 +
    done
154 +
155 +
    if [ $installed_count -gt 0 ]; then
156 +
        # Clear font cache on macOS
157 +
        print_status "Refreshing font cache..."
158 +
159 +
        # Clear system font cache
160 +
        sudo atsutil databases -remove 2>/dev/null || true
161 +
        atsutil server -shutdown 2>/dev/null || true
162 +
        atsutil server -ping 2>/dev/null || true
163 +
164 +
        print_success "Installed $installed_count new fonts!"
165 +
        print_status "You may need to restart applications to see the new fonts"
166 +
    else
167 +
        print_success "All CommitMono fonts are already installed"
168 +
    fi
169 +
}
170 +
108 171
# Copy configuration files from the repo
109 172
copy_configs() {
110 173
    print_status "Copying configuration files..."
111 -
    
174 +
112 175
    local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
113 -
    
176 +
114 177
    # Copy .zshrc
115 178
    if [ -f "$script_dir/.zshrc" ]; then
116 179
        cp "$script_dir/.zshrc" "$HOME/"
118 181
    else
119 182
        print_warning ".zshrc not found in repo"
120 183
    fi
121 -
    
184 +
122 185
    # Copy ghostty config
123 186
    if [ -f "$script_dir/config" ]; then
124 187
        mkdir -p "$HOME/.config/ghostty"
125 188
        cp "$script_dir/config" "$HOME/.config/ghostty/"
126 -
        print_success "Copied ghostty config"
189 +
        print_success "Copied Ghostty config"
127 190
    else
128 191
        print_warning "Ghostty config not found in repo"
129 192
    fi
130 -
    
193 +
131 194
    # Copy starship config
132 195
    if [ -f "$script_dir/starship.toml" ]; then
133 196
        mkdir -p "$HOME/.config"
142 205
set_default_shell() {
143 206
    local current_shell=$(echo $SHELL)
144 207
    local zsh_path=$(which zsh)
145 -
    
208 +
146 209
    if [ "$current_shell" != "$zsh_path" ]; then
147 210
        print_status "Setting zsh as default shell..."
148 -
        
211 +
149 212
        # Add zsh to /etc/shells if not present
150 213
        if ! grep -q "$zsh_path" /etc/shells; then
151 214
            echo "$zsh_path" | sudo tee -a /etc/shells
152 215
        fi
153 -
        
216 +
154 217
        # Change default shell
155 218
        chsh -s "$zsh_path"
156 219
        print_success "Default shell set to zsh"
165 228
    echo "🌑 Darkmatter Setup Installer"
166 229
    echo "=========================="
167 230
    echo
168 -
    
231 +
169 232
    check_homebrew
170 233
    install_packages
171 234
    backup_configs
172 235
    copy_configs
236 +
    install_fonts
173 237
    set_default_shell
174 -
    
238 +
175 239
    echo
176 240
    print_success "Installation complete! 🌌"
177 241
    echo
178 242
    print_status "Next steps:"
179 243
    echo "  1. Restart your terminal or run: exec zsh"
180 244
    echo "  2. Open Ghostty to use your new terminal setup"
181 -
    echo "  3. Enjoy your opinionated terminal experience!"
245 +
    echo "  3. Enjoy your Darkmatter terminal experience!"
182 246
}
183 247
184 248
# Run main function