-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·201 lines (175 loc) · 6.09 KB
/
install.sh
File metadata and controls
executable file
·201 lines (175 loc) · 6.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/usr/bin/env bash
set -e
FTS_DIR="$(cd "$(dirname "$0")" && pwd)"
BACKUP_DIR="$HOME/fts_backup_$(date +%Y%m%d_%H%M%S)"
echo "==> Installing Flip The Script from $FTS_DIR"
# Install Homebrew packages
echo "==> Installing Homebrew packages"
if ! command -v brew &> /dev/null; then
echo " Homebrew not found. Install from https://brew.sh first"
exit 1
fi
PACKAGES=(starship fzf zoxide eza bat)
for pkg in "${PACKAGES[@]}"; do
if brew list "$pkg" &> /dev/null; then
echo " ✓ $pkg already installed"
else
echo " Installing $pkg..."
brew install "$pkg"
fi
done
# Check for Nerd Font (required for icons)
echo "==> Checking for Nerd Font"
NERD_FONT_INSTALLED=false
NERD_FONT_CASK="font-meslo-lg-nerd-font"
# Check if any Nerd Font is installed via Homebrew
if brew list --cask 2>/dev/null | grep -q "nerd-font"; then
NERD_FONT_INSTALLED=true
echo " ✓ Nerd Font already installed"
fi
# Also check system fonts directory
if [[ "$NERD_FONT_INSTALLED" == "false" ]]; then
if ls ~/Library/Fonts/*[Nn]erd* /Library/Fonts/*[Nn]erd* 2>/dev/null | grep -q .; then
NERD_FONT_INSTALLED=true
echo " ✓ Nerd Font found in system fonts"
fi
fi
if [[ "$NERD_FONT_INSTALLED" == "false" ]]; then
echo " ⚠ No Nerd Font detected (required for terminal icons)"
read -p " Install $NERD_FONT_CASK? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo " Installing $NERD_FONT_CASK..."
brew install --cask "$NERD_FONT_CASK"
echo ""
echo " ✓ Font installed! Configure your terminal to use 'MesloLGS Nerd Font'"
else
echo " Skipped. Install a Nerd Font later for icons to display correctly:"
echo " brew install --cask font-meslo-lg-nerd-font"
fi
fi
# Install Node version manager (FNM recommended)
echo "==> Checking Node version manager"
HAS_NVM=false
HAS_FNM=false
if [[ -d "$HOME/.nvm" ]]; then
HAS_NVM=true
echo " ✓ NVM detected at ~/.nvm"
fi
if command -v fnm &> /dev/null; then
HAS_FNM=true
echo " ✓ FNM detected ($(fnm --version))"
fi
if [[ "$HAS_NVM" == "false" && "$HAS_FNM" == "false" ]]; then
echo " ⚠ No Node version manager detected"
echo " FNM (Fast Node Manager) is recommended - 10-50x faster than NVM"
read -p " Install FNM via Homebrew? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo " Skipped. You can install later:"
echo " brew install fnm"
echo " # or for NVM: https://github.com/nvm-sh/nvm#installing-and-updating"
else
echo " Installing fnm..."
brew install fnm
HAS_FNM=true
fi
elif [[ "$HAS_NVM" == "true" && "$HAS_FNM" == "false" ]]; then
echo " 💡 Consider switching to FNM for faster performance"
echo " See docs/FNM_MIGRATION.md for migration guide"
fi
# Install zsh plugins
echo "==> Installing zsh plugins"
ZSH_PLUGINS_DIR="$HOME/.zsh"
mkdir -p "$ZSH_PLUGINS_DIR"
if [[ ! -d "$ZSH_PLUGINS_DIR/zsh-autosuggestions" ]]; then
echo " Installing zsh-autosuggestions..."
git clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_PLUGINS_DIR/zsh-autosuggestions"
else
echo " ✓ zsh-autosuggestions already installed"
fi
if [[ ! -d "$ZSH_PLUGINS_DIR/zsh-syntax-highlighting" ]]; then
echo " Installing zsh-syntax-highlighting..."
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_PLUGINS_DIR/zsh-syntax-highlighting"
else
echo " ✓ zsh-syntax-highlighting already installed"
fi
# Backup existing files that aren't symlinks
backup_if_exists() {
local file=$1
if [[ -e "$file" && ! -L "$file" ]]; then
echo " Backing up existing $file"
mkdir -p "$BACKUP_DIR"
mv "$file" "$BACKUP_DIR/"
fi
}
# Create symlink
link_file() {
local src=$1
local dest=$2
backup_if_exists "$dest"
ln -sf "$src" "$dest"
echo " Linked $dest -> $src"
}
# Link zsh configs
echo "==> Linking zsh configs"
link_file "$FTS_DIR/zsh/zshrc" "$HOME/.zshrc"
link_file "$FTS_DIR/zsh/zshenv" "$HOME/.zshenv"
# Link starship config
echo "==> Linking starship config"
mkdir -p "$HOME/.config"
link_file "$FTS_DIR/starship/starship.toml" "$HOME/.config/starship.toml"
# Link Claude Code config
echo "==> Linking Claude Code config"
mkdir -p "$HOME/.claude"
if [[ -f "$HOME/.claude/settings.json" && ! -L "$HOME/.claude/settings.json" ]]; then
# Existing non-symlink settings — merge rather than overwrite
echo " ⚠ Existing ~/.claude/settings.json found (not a symlink)"
echo " Backing up to $BACKUP_DIR and linking dotfiles version"
mkdir -p "$BACKUP_DIR"
cp "$HOME/.claude/settings.json" "$BACKUP_DIR/claude-settings.json"
fi
link_file "$FTS_DIR/claude/settings.json" "$HOME/.claude/settings.json"
# Create .zshrc.local if it doesn't exist
if [[ ! -f "$HOME/.zshrc.local" ]]; then
echo "==> Creating ~/.zshrc.local for machine-specific config"
cat > "$HOME/.zshrc.local" << 'LOCALEOF'
# Machine-specific zsh config (gitignored)
# Add your secrets, work-specific PATH, aliases, etc. here
# Example:
# export WORK_VPN_TOKEN="..."
# export PATH="/opt/work/bin:$PATH"
LOCALEOF
echo " Created ~/.zshrc.local"
else
echo "==> ~/.zshrc.local already exists, skipping"
fi
# Setup fts CLI
echo "==> Setting up fts CLI"
chmod +x "$FTS_DIR/bin/fts"
if ! grep -q "$FTS_DIR/bin" "$HOME/.zshrc.local" 2>/dev/null; then
echo "export PATH=\"$FTS_DIR/bin:\$PATH\"" >> "$HOME/.zshrc.local"
echo " Added to PATH"
fi
# Enable learning hints
echo "==> Enable learning hints?"
echo " This shows occasional tips about shortcuts as you work (e.g., 'Use gs instead of git status')"
read -p " Enable hints? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
touch "$HOME/.fts_hints"
echo " ✓ Learning hints enabled! Run 'fts hint' anytime"
else
echo " Hints disabled. Enable later with: fts hints"
fi
echo ""
echo "==> Done! Restart your shell or run: exec zsh"
if [[ -d "$BACKUP_DIR" ]]; then
echo " Old configs backed up to: $BACKUP_DIR"
fi
echo ""
echo " Next steps:"
echo " - Set your terminal font to a Nerd Font for icons"
echo " - Run 'fts check' to verify everything works"
echo " - Run 'fts hint' to see productivity tips"
echo " - Run 'fts aliases' to browse available shortcuts"