-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·57 lines (49 loc) · 2.24 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·57 lines (49 loc) · 2.24 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
#!/usr/bin/env bash
set -euo pipefail
# Explaining the set flags:
# -e: Exit immediately if a command exits with a non-zero status.
# -u: Treat unset variables as an error and exit immediately.
# -o pipefail: Prevent errors in a pipeline from being masked. If any command in
# a pipeline fails, that return code will be used as the return code
# of the whole pipeline.
# set -x # For debugging, see all commands being executed
SCRIPT_PATH="$(realpath "$0")"
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
DOT_FILES="${SCRIPT_DIR}"
# The options for ln:
# -s: Create symbolic links instead of hard links.
# -f: Remove existing destination files before creating the link.
# -n: Treat the destination as a normal file if it is a symbolic link to a directory.
# -v: Verbose mode, print what is being done.
# Create a symlink, backing up any existing non-symlink target with a timestamp.
# -n is not needed because we explicitly remove any existing symlink before calling ln,
# so ln never sees a symlink-to-directory at the destination and won't dereference it.
# Usage: link_dotfile <source> <target>
link_dotfile() {
local src="$1"
local dst="$2"
if [ -L "$dst" ]; then
rm -v "$dst"
elif [ -e "$dst" ]; then
mv -v "$dst" "${dst}.bak$(date +%s)"
fi
ln -sv "$src" "$dst"
}
link_dotfile "${DOT_FILES}/vim" ~/.vim
link_dotfile "${DOT_FILES}/screenrc" ~/.screenrc
mkdir -p ~/.claude
link_dotfile "${DOT_FILES}/claude/skills" ~/.claude/skills
link_dotfile "${DOT_FILES}/claude/memory" ~/.claude/memory
link_dotfile "${DOT_FILES}/claude/CLAUDE.md" ~/.claude/CLAUDE.md
# Install shell configuration files by sourcing them from the dotfiles repo.
# We can't just symlink them because the user might have customizations.
# Instead, we append a source line to the user's existing config if not already there.
for config in bashrc profile bash_profile; do
home_config="${HOME}/.${config}"
touch "$home_config" # Ensure the file exists before grepping
if ! grep -q "source ${DOT_FILES}/shell/${config}" "$home_config" 2>/dev/null; then
echo "[ -f ${DOT_FILES}/shell/${config} ] && source ${DOT_FILES}/shell/${config}" >> "$home_config"
fi
done
# Make sure the binaries we expect are in place
./provisioning/install.sh