-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·81 lines (70 loc) · 2.45 KB
/
setup.sh
File metadata and controls
executable file
·81 lines (70 loc) · 2.45 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
#!/bin/bash
set -euo pipefail
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
echo "=== Dotfiles Setup ==="
echo "Dotfiles directory: $DOTFILES_DIR"
# --- Homebrew ---
if ! command -v brew &> /dev/null; then
echo ">>> Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
echo ">>> Installing Homebrew packages..."
brew bundle --file="$DOTFILES_DIR/Brewfile"
# --- Symlinks ---
echo ">>> Creating symlinks..."
create_symlink() {
local src="$1"
local dest="$2"
if [ -L "$dest" ]; then
echo " Skipping (already linked): $dest"
elif [ -e "$dest" ]; then
echo " Backing up existing: $dest → ${dest}.bak"
mv "$dest" "${dest}.bak"
ln -s "$src" "$dest"
echo " Linked: $src → $dest"
else
mkdir -p "$(dirname "$dest")"
ln -s "$src" "$dest"
echo " Linked: $src → $dest"
fi
}
# ホームディレクトリ直下の dotfiles
create_symlink "$DOTFILES_DIR/.zshrc" "$HOME/.zshrc"
create_symlink "$DOTFILES_DIR/.zprofile" "$HOME/.zprofile"
create_symlink "$DOTFILES_DIR/.zshenv" "$HOME/.zshenv"
create_symlink "$DOTFILES_DIR/.gitconfig" "$HOME/.gitconfig"
# .config 配下
create_symlink "$DOTFILES_DIR/.config/nvim" "$HOME/.config/nvim"
create_symlink "$DOTFILES_DIR/.config/wezterm" "$HOME/.config/wezterm"
create_symlink "$DOTFILES_DIR/.config/starship.toml" "$HOME/.config/starship.toml"
create_symlink "$DOTFILES_DIR/.config/sheldon" "$HOME/.config/sheldon"
# --- シークレット・個人設定用ファイル ---
if [ ! -f "$HOME/.zshrc.local" ]; then
echo ">>> Creating ~/.zshrc.local for secrets..."
cat > "$HOME/.zshrc.local" << 'SECRETS'
# このファイルは git 管理されません
# API キー・秘密の環境変数・プロジェクト固有 alias をここに書いてください
SECRETS
echo " Created: ~/.zshrc.local"
fi
if [ ! -f "$HOME/.gitconfig.local" ]; then
echo ">>> Creating ~/.gitconfig.local for git identity..."
cat > "$HOME/.gitconfig.local" << 'GITLOCAL'
[user]
email = your-email@example.com
name = Your Name
# signingkey = ~/.ssh/id_rsa.pub
# [gpg]
# format = ssh
# [commit]
# gpgsign = true
GITLOCAL
echo " Created: ~/.gitconfig.local (set your git identity here)"
fi
echo ""
echo "=== Setup Complete! ==="
echo "Next steps:"
echo " 1. Edit ~/.gitconfig.local to set your git identity"
echo " 2. Edit ~/.zshrc.local to add your secret keys"
echo " 3. Restart your terminal"