-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·58 lines (48 loc) · 1.56 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·58 lines (48 loc) · 1.56 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
#!/bin/bash
set -euo pipefail
# The .claude tree is routed to Claude Code's config dir so that e.g.
# `CLAUDE_CONFIG_DIR=~/.claude.personal ./deploy.sh osx` installs it there.
# Everything else installs under $HOME.
CLAUDE_CONFIG_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
CLAUDE_CONFIG_DIR="${CLAUDE_CONFIG_DIR%/}"
# Map a repo-relative path to its install destination.
function dest_for() {
case "$1" in
.claude ) echo "$CLAUDE_CONFIG_DIR" ;;
.claude/* ) echo "${CLAUDE_CONFIG_DIR}/${1#.claude/}" ;;
* ) echo "$HOME/$1" ;;
esac
}
function install_homedir() {
local os=$1
cd "home/${os}"
echo "- Installing ${os} dotfiles"
for i in $(find ./ -maxdepth 1 -type f | cut -c3-); do
ln -svfn "$PWD/$i" "$(dest_for "$i")"
done
for i in $(find . -mindepth 1 -type d | cut -c3-); do
local dest; dest=$(dest_for "$i")
echo "-- creating directory $dest"
mkdir -p "$dest"
for j in $(find "$i" -maxdepth 1 -type f); do
ln -svfn "$PWD/$j" "$(dest_for "$j")"
done
done
cd -
}
function install_general() {
mv -v "$HOME/.bashrc" "$HOME/.bashrc.bak" || echo "- No bashrc, skipping backup!"
install_homedir general
install_homedir bin
}
function install_os() {
local os=$1
echo "- Installing dotfiles for OS: '${os}'"
install_homedir "$os"
}
case ${1:-} in
linux|termux|osx ) install_general ; install_os "$1" ;;
bin ) install_homedir bin ;;
wsl ) install_general ; install_os linux ; install_os "$1" ;;
* ) echo "must choose linux/osx/termux/wsl/bin" ; exit 1;;
esac