Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dotfiles

## Installation
## Instal
```
$ curl -sL https://raw.githubusercontent.com/dev-satoshi/dotfiles/main/install.sh | sh
```
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ else
git clone https://github.com/dev-satoshi/dotfiles "$INSTALL_DIR"
fi

sh "$INSTALL_DIR/scripts/setup.sh"
sh "$INSTALL_DIR/scripts/setup/setup.sh"
26 changes: 26 additions & 0 deletions scripts/setup/android_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env zsh
set -euo pipefail

echo "「Android」のセットアップを開始しました"

SDK_DIR="/opt/homebrew/share/android-commandlinetools"
CMDLINE_TOOLS_DIR="/opt/homebrew/share/android-commandlinetools/cmdline-tools/latest"

if [ -d "$CMDLINE_TOOLS_DIR" ]; then
:
else
# パッケージをインストール
sdkmanager --install "cmdline-tools;latest" \
"platform-tools" \
"platforms;android-34" \
"build-tools;34.0.0" \
"emulator"
fi

# Androidのライセンスに同意
yes | flutter doctor --android-licenses || true

# FlutterにSDKパスを教える
flutter config --android-sdk "$SDK_DIR"

echo "「Android」のセットアップが完了しました"
18 changes: 18 additions & 0 deletions scripts/setup/asdf_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env zsh
set -euo pipefail

echo "「ASDF」のセットアップを開始しました"

# プラグインをインストール
while IFS=$'\t ' read -r name url; do
asdf plugin add "$name" "$url" >/dev/null 2>&1 || true
done < ~/dotfiles/asdf/plugins.txt

# .tool-versions に書いてあるバージョンをインストール
while IFS=' ' read -r plugin version; do
[[ -z "$plugin" || -z "$version" ]] && continue
echo "→ Installing $plugin $version"
asdf install "$plugin" "$version"
done < ~/dotfiles/asdf/.tool-versions

echo "「ASDF」のセットアップが完了しました"
20 changes: 20 additions & 0 deletions scripts/setup/homebrew_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env zsh
set -euo pipefail

echo "「Homebrew」のセットアップを開始しました"

# brewのインストール
if ! command -v brew >/dev/null 2>&1; then
echo "「Homebrew」が見つかりません。インストールを開始します..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "「Homebrew」は既にインストールされています"
fi

# パッケージリストを更新
brew update

# Brewfileを元にインストール
brew bundle --file=~/dotfiles/homebrew/Brewfile

echo "「Homebrew」のセットアップが完了しました"
47 changes: 47 additions & 0 deletions scripts/setup/link_dotfiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env zsh
set -euo pipefail

echo "「シンボリックリンク」の作成を開始しました"

DOTFILES_DIR="$HOME/dotfiles"

# リンクを作成するファイル一覧(キー:シンボリックリンク先、値:dotfiles内の実ファイル)
LINKS=(
"$DOTFILES_DIR/zsh/.zshrc:$HOME/.zshrc"
"$DOTFILES_DIR/zsh/.zshenv:$HOME/.zshenv"
"$DOTFILES_DIR/git/.gitconfig:$HOME/.gitconfig"
"$DOTFILES_DIR/git/.gitignore:$HOME/.gitignore"
"$DOTFILES_DIR/git/.gitattributes:$HOME/.gitattributes"
"$DOTFILES_DIR/asdf/.tool-versions:$HOME/.tool-versions"
"$DOTFILES_DIR/aws/config:$HOME/.aws/config"
"$DOTFILES_DIR/vscode/settings.json:$HOME/Library/Application Support/Code/User/settings.json"
"$DOTFILES_DIR/android/sdk:$HOME/Library/Android/sdk"
"/opt/homebrew/share/android-commandlinetools/cmdline-tools/latest:$DOTFILES_DIR/android/sdk/cmdline-tools/latest"
)

# すべてのリンクを作成
for link in "${LINKS[@]}"; do
src=$(echo "$link" | cut -d':' -f1)
dest=$(echo "$link" | cut -d':' -f2)

# 親ディレクトリが無ければ作成
mkdir -p "$(dirname "$dest")"

# 既存のファイルやリンクがあればバックアップ
# if [ -e "$dest" ] || [ -L "$dest" ]; then
# echo "$dest をバックアップ: ${dest}.backup"
# mv "$dest" "${dest}.backup"
# fi

# 既存のファイルやリンクを削除(バックアップは取らない)
if [ -e "$dest" ] || [ -L "$dest" ]; then
echo "既存の $dest を削除"
rm -rf "$dest"
fi

# シンボリックリンクを作成
echo "$src → $dest"
ln -s "$src" "$dest"
done

echo "「シンボリックリンク」の作成が完了しました"
15 changes: 15 additions & 0 deletions scripts/setup/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env zsh
set -euo pipefail

echo "「dotfiles」のセットアップを開始しました"

INSTALL_DIR="$HOME/dotfiles"

sh "$INSTALL_DIR/scripts/setup/link_dotfiles.sh"
sh "$INSTALL_DIR/scripts/setup/homebrew_setup.sh"
sh "$INSTALL_DIR/scripts/setup/asdf_setup.sh"
sh "$INSTALL_DIR/scripts/setup/vscode_setup.sh"
sh "$INSTALL_DIR/scripts/setup/xcode_setup.sh"
sh "$INSTALL_DIR/scripts/setup/android_setup.sh"

echo "「dotfiles」のセットアップが完了しました"
9 changes: 9 additions & 0 deletions scripts/setup/vscode_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env zsh
set -euo pipefail

echo "「VSCode」のセットアップを開始しました"

# 拡張機能をインストール
xargs -L 1 code --install-extension < ~/dotfiles/vscode/extensions.txt

echo "「VSCode」のセットアップが完了しました"
12 changes: 12 additions & 0 deletions scripts/setup/xcode_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env zsh
set -euo pipefail

echo "「Xcode」のセットアップを開始しました"

# podのインストール
gem install cocoapods

# xcodebuildのライセンスを受諾
yes | sudo xcodebuild -license accept || true

echo "「Xcode」のセットアップが完了しました"