-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·165 lines (148 loc) · 5.8 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·165 lines (148 loc) · 5.8 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
#!/bin/bash
set -e
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
echo "Installing dotfiles..."
mkdir -p ~/.config
# link_file <src> <dest>
# Creates a symlink dest -> src, replacing any existing symlink with the wrong
# target. Reports already-linked when target matches. A pre-existing real
# file/dir at dest (e.g. ~/.config/karabiner created by Karabiner-Elements
# before install) is moved aside to dest.bak first, so we never link inside it
# or clobber it.
link_file() {
local src="$1" dest="$2"
local label="${dest/#${HOME}/~}"
if [[ -L "${dest}" ]] && [[ "$(readlink "${dest}")" = "${src}" ]]; then
echo "✓ ${label} already linked"
return
fi
if [[ -e "${dest}" ]] && [[ ! -L "${dest}" ]]; then
if [[ -e "${dest}.bak" ]]; then
echo "✗ ${label} is a real path and ${label}.bak already exists; move it aside manually" >&2
exit 1
fi
mv "${dest}" "${dest}.bak"
echo "✓ Backed up ${label} -> ${label}.bak"
fi
ln -sfn "${src}" "${dest}"
echo "✓ Linked ${label}"
}
# Ensure ~/dotfiles resolves to this repo. Several configs reference the repo by
# the absolute path ~/dotfiles (tmux source-file, git include path, ghostty
# config-file, fastfetch source, zsh sources) and those tools cannot resolve the
# path dynamically. Cloning elsewhere therefore breaks them unless ~/dotfiles
# points here. Done explicitly (not via link_file) so an existing real ~/dotfiles
# directory is never clobbered.
DOTFILES_LINK="${HOME}/dotfiles"
if [[ "${DOTFILES_DIR}" != "${DOTFILES_LINK}" ]]; then
if [[ -L "${DOTFILES_LINK}" ]] && [[ "$(readlink "${DOTFILES_LINK}")" = "${DOTFILES_DIR}" ]]; then
echo "✓ ~/dotfiles already linked"
elif [[ -e "${DOTFILES_LINK}" ]]; then
echo "✗ ~/dotfiles exists and is not this repo; configs expect the repo at ~/dotfiles" >&2
exit 1
else
ln -s "${DOTFILES_DIR}" "${DOTFILES_LINK}"
echo "✓ Linked ~/dotfiles -> ${DOTFILES_DIR}"
fi
fi
# Symlink configs in .config directory
configs=(
"nvim"
"tmux"
"gh"
"ghostty"
"fastfetch"
"karabiner"
"yazi"
)
for config in "${configs[@]}"; do
link_file "${DOTFILES_DIR}/${config}" "${HOME}/.config/${config}"
done
# Git configuration (special case - goes in home directory)
link_file "${DOTFILES_DIR}/git/gitconfig" "${HOME}/.gitconfig"
# Git ignore file
link_file "${DOTFILES_DIR}/git/ignore" "${HOME}/.gitignore_global"
# eza theme (single file, not a whole-dir config). Points at the vendored
# tokyonight-moon theme so `eza`/`ls` output matches the rest of the palette.
mkdir -p "${HOME}/.config/eza"
link_file "${DOTFILES_DIR}/themes/tokyonight-moon/eza/tokyonight_moon.yml" "${HOME}/.config/eza/theme.yml"
# Shell configuration (symlink to home directory)
shell_configs=(
"zshrc:.zshrc"
"zprofile:.zprofile"
"zshenv:.zshenv"
)
for entry in "${shell_configs[@]}"; do
shell_src="${entry%%:*}"
shell_dest="${entry##*:}"
link_file "${DOTFILES_DIR}/zsh/${shell_src}" "${HOME}/${shell_dest}"
done
# Claude Code configuration
mkdir -p "${HOME}/.claude"
claude_files=(
"CLAUDE.md"
"settings.json"
"statusline.sh"
)
for file in "${claude_files[@]}"; do
link_file "${DOTFILES_DIR}/claude/${file}" "${HOME}/.claude/${file}"
done
# Claude Code skills (link each skill individually, ~/.claude/skills/ may have other content)
mkdir -p "${HOME}/.claude/skills"
for skill_dir in "${DOTFILES_DIR}/claude/skills"/*/; do
skill_name="$(basename "${skill_dir}")"
link_file "${skill_dir}" "${HOME}/.claude/skills/${skill_name}"
done
# Claude Code hooks (link each hook individually, ~/.claude/hooks/ may have other content)
mkdir -p "${HOME}/.claude/hooks"
for hook_file in "${DOTFILES_DIR}/claude/hooks"/*.sh; do
[[ -f "${hook_file}" ]] || continue
hook_name="$(basename "${hook_file}")"
link_file "${hook_file}" "${HOME}/.claude/hooks/${hook_name}"
done
# fzf-git.sh (sourced by zshrc; no Homebrew formula available)
FZF_GIT_DIR="${HOME}/.local/share/fzf-git.sh"
if [[ -d "${FZF_GIT_DIR}" ]]; then
echo "✓ fzf-git.sh already installed"
else
mkdir -p "$(dirname "${FZF_GIT_DIR}")"
git clone --depth 1 https://github.com/junegunn/fzf-git.sh.git "${FZF_GIT_DIR}"
echo "✓ Cloned fzf-git.sh"
fi
# tmux plugin manager (tpm) + declared plugins (resurrect/continuum session persistence)
TPM_DIR="${HOME}/.config/tmux/plugins/tpm"
if [[ -d "${TPM_DIR}" ]]; then
echo "✓ tpm already installed"
else
mkdir -p "$(dirname "${TPM_DIR}")"
git clone --depth 1 https://github.com/tmux-plugins/tpm.git "${TPM_DIR}"
echo "✓ Cloned tpm"
fi
if command -v tmux &>/dev/null; then
"${TPM_DIR}/bin/install_plugins" >/dev/null && echo "✓ tmux plugins installed"
fi
# Sync Neovim plugins (Neovim's own colorscheme only; terminal/app themes are
# vendored under themes/ via themes/sync.sh and no longer depend on this step)
if command -v nvim &>/dev/null; then
echo "Syncing Neovim plugins..."
nvim --headless "+Lazy! sync" +qa
echo "✓ Neovim plugins synced"
fi
# bat theme: bat needs the tmTheme copied into its themes dir + a cache rebuild
# (it can't read an arbitrary path). Sourced from the vendored copy so it works
# without the nvim plugin. Used by standalone `bat` (BAT_THEME) and by delta,
# which calls bat under the hood (syntax-theme = tokyonight_moon).
TOKYONIGHT_BAT_THEME="${DOTFILES_DIR}/themes/tokyonight-moon/bat/tokyonight_moon.tmTheme"
BAT_THEMES_DIR="${HOME}/.config/bat/themes"
if command -v bat &>/dev/null && [[ -f "${TOKYONIGHT_BAT_THEME}" ]]; then
mkdir -p "${BAT_THEMES_DIR}"
# Re-copy + rebuild when the vendored theme changes (e.g. after themes/sync.sh).
if ! cmp -s "${TOKYONIGHT_BAT_THEME}" "${BAT_THEMES_DIR}/tokyonight_moon.tmTheme"; then
cp "${TOKYONIGHT_BAT_THEME}" "${BAT_THEMES_DIR}/"
bat cache --build >/dev/null
echo "✓ Installed bat theme tokyonight_moon"
else
echo "✓ bat theme tokyonight_moon already installed"
fi
fi
echo "Dotfiles installed successfully!"