-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·96 lines (86 loc) · 3.06 KB
/
install.sh
File metadata and controls
executable file
·96 lines (86 loc) · 3.06 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
#!/bin/bash
set -euo pipefail
git submodule update --init --recursive || true
# Settings #####
DOT_FILES=(.zsh .zshrc .zshenv .vimrc .vim .easystroke .tmux.conf .shenv .pep8 .digrc .bin .bashrc .sh_profile .bash_profile .zprofile Brewfile)
DOT_DIRECTORY_EACH_FILE=(.ssh .aws .awsume)
CONFIG_FILES=(nvim git mise pnpm npm docker uv claude)
CONFIG_FILES_SINGLE_FILE=(jj/config.toml)
OLD_DOT_FILES=(.env .gitignore .pyenv) # 過去管理していたが、現在は管理していないファイル群
OLD_CONFIG_FILES=(claude) # 過去管理していたが、現在は管理していないファイル群
# OLD_CONFIG_FILES_SINGLE_FILE=() # 過去管理していたが、現在は管理していないファイル群(コメントアウトしているのは、空のため)
################
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
# DOT_FILES
for file in "${DOT_FILES[@]}"
do
ln -sfn "${SCRIPT_DIR}/root/${file#.}" "${HOME}/${file}"
done
# OLD_DOT_FILES
for file in "${OLD_DOT_FILES[@]}"
do
if [ -L "${HOME}/${file}" ] && [ ! -e "${HOME}/${file}" ]; then
rm "${HOME}/${file}"
fi
done
# CONFIG_FILES
mkdir -p "$HOME/.config"
for file in "${CONFIG_FILES[@]}"
do
ln -sfn "${SCRIPT_DIR}/config/${file}" "${HOME}/.config/${file}"
done
# CONFIG_FILES_SINGLE_FILE
for file in "${CONFIG_FILES_SINGLE_FILE[@]}"
do
mkdir -p "$(dirname "${HOME}/.config/${file}")"
ln -sfn "${SCRIPT_DIR}/config/${file}" "${HOME}/.config/${file}"
done
# OLD_CONFIG_FILES
for file in "${OLD_CONFIG_FILES[@]}"
do
if [ -L "${HOME}/.config/${file}" ] && [ ! -e "${HOME}/.config/${file}" ]; then
rm "${HOME}/.config/${file}"
fi
done
# OLD_CONFIG_FILES_SINGLE_FILE
# for file in "${OLD_CONFIG_FILES_SINGLE_FILE[@]}"
# do
# if [ -L "${HOME}/.config/${file}" ] && [ ! -e "${HOME}/.config/${file}" ]; then
# rm "${HOME}/.config/${file}"
# fi
# done
# DOT_DIRECTORY_EACH_FILE
for dir in "${DOT_DIRECTORY_EACH_FILE[@]}"
do
TARGET_DIR="${HOME}/${dir}"
if [ ! -e "${TARGET_DIR}" ]; then
mkdir "${TARGET_DIR}"
# .ssh だけ例外的に 700 である必要性がある
if [ "${dir}" = ".ssh" ]; then
chmod 700 "${TARGET_DIR}"
fi
fi
if [ -d "${TARGET_DIR}" ]; then
for file in "${SCRIPT_DIR}/${dir}"/*; do
REL_TARGET_PATH="${file#"${SCRIPT_DIR}"/}"
ln -sfn "${file}" "${HOME}/${REL_TARGET_PATH}"
# .ssh だけ 600 である必要性がある
if [ "${dir}" = ".ssh" ]; then
if [ -d "${HOME}/${REL_TARGET_PATH}" ]; then
chmod 700 "${HOME}/${REL_TARGET_PATH}"
else
chmod 600 "${HOME}/${REL_TARGET_PATH}"
fi
fi
done
fi
done
# Claude Code が XDG の仕様に沿ってないので、仕方なく一部分離
mkdir -p "${CLAUDE_CONFIG_DIR:-"${HOME}/.claude"}"
ln -sfn "${SCRIPT_DIR}/claude_agents" "${CLAUDE_CONFIG_DIR:-"${HOME}/.claude"}/agents"
# Homebrew Bundle
if command -v brew >/dev/null 2>&1; then
pushd "${HOME}"
HOMEBREW_BUNDLE_NO_UPGRADE="1" brew bundle
popd
fi