Repository navigation
Expand file tree
/
Copy pathsetup-linux.sh
More file actions
executable file
·128 lines (112 loc) · 3.92 KB
/
Copy pathsetup-linux.sh
File metadata and controls
executable file
·128 lines (112 loc) · 3.92 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
#!/bin/bash
# Setup for Arch-based Linux (tested on Omarchy)
# Exit on error
set -e
cd "$(dirname "$0")"
if ! command -v pacman &>/dev/null; then
echo "❌ pacman not found; this setup requires an Arch-based distro"
exit 1
fi
echo "🚀 Starting Linux setup..."
PACMAN_PACKAGES=(
stow zsh zsh-autosuggestions zsh-syntax-highlighting
bat cloc eza fd ffmpeg fzf git-delta gnupg imagemagick jq luarocks
ripgrep tldr tree viu wl-clipboard xclip
ghostty gitui lazygit mise neovim starship tmux yazi zoxide
)
AUR_PACKAGES=(zsh-vi-mode forgit)
# Install official packages (skip sudo entirely if nothing is missing)
missing=$(pacman -T "${PACMAN_PACKAGES[@]}" || true)
if [[ -n "$missing" ]]; then
echo "📦 Installing packages: $missing"
# shellcheck disable=SC2086
sudo pacman -S --needed --noconfirm $missing
else
echo "✅ All official packages already installed"
fi
# Install AUR packages
aur_missing=()
for pkg in "${AUR_PACKAGES[@]}"; do
pacman -Qq "$pkg" &>/dev/null || aur_missing+=("$pkg")
done
if [[ ${#aur_missing[@]} -gt 0 ]]; then
if command -v yay &>/dev/null; then
echo "📦 Installing AUR packages: ${aur_missing[*]}"
yay -S --needed --noconfirm "${aur_missing[@]}"
else
echo "❌ Install yay or install these AUR packages before rerunning setup: ${aur_missing[*]}" >&2
exit 1
fi
else
echo "✅ All AUR packages already installed"
fi
# Stow packages (aerospace & karabiner are macOS-only)
STOW_PACKAGES=(bat cursor ghostty gitui hunk lazygit lvim mise nvim starship tmux wezterm yazi zsh)
# Unfold legacy Cursor links before the backup pass can follow them into the repo.
bash ./setup-cursor.sh
# Back up pre-existing real configs that stow would conflict with
# (e.g. distro defaults from Omarchy), instead of clobbering them
BACKUP_DIR="$HOME/.config/dotfiles-backup-$(date +%Y%m%d-%H%M%S)"
package_targets() {
(
cd "$1" || exit 1
# BSD find (macOS, where the test suite also runs) has no -printf, so strip
# the leading './' with sed instead.
find . -mindepth 1 -maxdepth 1 ! -name .config ! -name .cursor | sed 's#^\./##'
# Only the managed status line may be moved; preserve Cursor auth/state.
if [[ -f .cursor/statusline.sh ]]; then
printf '%s\n' '.cursor/statusline.sh'
fi
if [[ -d .config ]]; then
# Already prints '.config/<name>'.
find .config -mindepth 1 -maxdepth 1
fi
)
}
for pkg in "${STOW_PACKAGES[@]}"; do
while IFS= read -r rel; do
target="$HOME/$rel"
if [[ -e "$target" && ! -L "$target" ]]; then
echo "🗃️ Backing up $target -> $BACKUP_DIR/$rel"
mkdir -p "$BACKUP_DIR/$(dirname "$rel")"
mv "$target" "$BACKUP_DIR/$rel"
fi
done < <(package_targets "$pkg")
done
# Create symlinks using stow
echo "🔗 Creating symlinks..."
if ! stow --restow --target="$HOME" "${STOW_PACKAGES[@]}"; then
echo "❌ stow failed"
[[ -d "$BACKUP_DIR" ]] && echo "💡 Pre-existing configs were moved to $BACKUP_DIR"
exit 1
fi
# Keep Linux-specific Ghostty settings out of the macOS-first tracked config.
ghostty_local="$HOME/.config/ghostty/local.conf"
if [[ ! -f "$ghostty_local" ]]; then
cat >"$ghostty_local" <<'EOF'
# Omarchy/Linux overrides
config-file = ?"~/.local/state/omarchy/current/theme/ghostty.conf"
font-family = ""
font-family = JetBrainsMono Nerd Font Mono
font-family-bold = ""
font-family-italic = ""
font-size = 10
EOF
fi
# Machine-local mise tools; Omarchy's wrappers for these are removed by
# setup-ai-clis.sh, so seed the gitignored conf.d entry that replaces them.
mise_local="$HOME/.config/mise/conf.d/omarchy.toml"
if [[ ! -f "$mise_local" ]]; then
mkdir -p "$(dirname "$mise_local")"
cat >"$mise_local" <<'EOF'
# Machine-local tools (gitignored); merged by mise alongside config.toml.
[tools]
gh = "latest"
hunk = "latest"
EOF
fi
./setup-common.sh
if [[ "$(getent passwd "$USER" | cut -d: -f7)" != *zsh ]]; then
echo "💡 To make zsh your login shell: chsh -s /usr/bin/zsh"
fi
echo "✨ Setup complete!"