Repository navigation
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
·70 lines (59 loc) · 2.5 KB
/
Copy pathbootstrap
File metadata and controls
executable file
·70 lines (59 loc) · 2.5 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
#!/usr/bin/env zsh
set -e
#
# Manual/non-brew installation of stuff
# Particle CLI $ bash <( curl -sL https://particle.io/install-cli )
# Claude Code?
# This repo's real location, worked out from where this script lives, so it
# doesn't matter whether it was cloned into ~/dev, ~/code, or elsewhere.
local DOTFILES_REPO="${0:A:h:h}"
# Strap clones straight into ~/.dotfiles as a real directory. Move it into the
# code directory so ~/.dotfiles can become a symlink to it.
if [[ "$DOTFILES_REPO" == "$HOME/.dotfiles" ]]; then
DIRDEV="${DIRDEV:-$HOME/dev}"
if [[ -e "$DIRDEV/dotfiles" ]]; then
echo "~/.dotfiles is a real directory and $DIRDEV/dotfiles already exists."
echo "Remove one of them, then run $DIRDEV/dotfiles/script/bootstrap again."
exit 1
fi
echo "Moving ~/.dotfiles to $DIRDEV/dotfiles"
mkdir -p "$DIRDEV"
mv "$HOME/.dotfiles" "$DIRDEV/dotfiles"
cd "$DIRDEV/dotfiles"
DOTFILES_REPO="$DIRDEV/dotfiles"
fi
# Code directory is wherever this repo lives (e.g. ~/dev or ~/code), unless set.
local DIRDEV="${DIRDEV:-${DOTFILES_REPO:h}}"
local TOOLSHED_REPO="$DIRDEV/toolshed"
# Clone toolshed (CLI tools, kept separate from dotfiles config) if missing
if [ ! -d "$TOOLSHED_REPO" ]; then
echo "Cloning toolshed into ${TOOLSHED_REPO}"
git clone https://github.com/cobyism/toolshed "$TOOLSHED_REPO"
fi
# Symlink $1 at $2, replacing an existing symlink but never a real file or
# directory. `-n` stops ln following an existing link to a directory, which
# would otherwise create the link inside it (e.g. ~/.dotfiles/dotfiles).
function link() {
local target="$1" link_path="$2"
if [[ -e "$link_path" && ! -L "$link_path" ]]; then
echo "${link_path} exists and isn't a symlink. Move it aside and run this script again."
exit 1
fi
echo "Linking ${link_path} -> ${target}"
ln -sfn "$target" "$link_path"
}
link "$DOTFILES_REPO" "$HOME/.dotfiles"
link "$HOME/.dotfiles/home/rcrc" "$HOME/.rcrc"
# Remember a non-default code directory for this machine.
if [[ "$DIRDEV" != "$HOME/dev" ]] && ! grep -qs DIRDEV "$HOME/.zshenv.local"; then
echo "Recording DIRDEV=${DIRDEV} in ~/.zshenv.local"
echo "export DIRDEV=\"${DIRDEV/#$HOME/\$HOME}\"" >> "$HOME/.zshenv.local"
fi
# Next up: ensure brew installed, install rcm, rest of Brewfile, etc.
# Check if rcm is installed
if ! command -v rcup &> /dev/null; then
echo "rcm could not be found. Please install rcm (e.g., via Homebrew: brew install rcm) and run this script again."
exit 1
fi
# echo "Running rcup to symlink dotfiles into place..."
# rcup -v