-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·57 lines (43 loc) · 1.06 KB
/
install.sh
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
#!/bin/bash
set -eu
DOT_DIR=$(cd $(dirname $0) && pwd)
SCRIPTS_DIR="$DOT_DIR/scripts/$(uname)"
# gitが無い
if ! type -p git >/dev/null; then
echo "error: git not found on the system" >&2
exit 1
fi
# サポート外の環境
if [[ ! -d "$SCRIPTS_DIR" ]]; then
echo "error: unsupported environment ($(uname))" >&2
exit 1
fi
# スクリプトを実行
function script_run {
if [[ ! -f "$1" ]]; then
echo "❌️ $1 does not exist"
exit 1
fi
sh -c "$1"
}
# .config/ 以下のシンボリックリンクを作成
function link_dotfiles {
echo "🔗 Link dotfiles"
local links=$(script_run "$SCRIPTS_DIR/find.sh")
IFS=$'\n'
for f in $links; do
mkdir -p "$HOME/$(dirname "$f")"
ln -sfv "$DOT_DIR/$f" "$HOME/$f"
done
unset IFS
}
echo "dotfiles (for macOS / Ubuntu)"
# オプション --link-only が指定された場合、リンクのみ作成
if [[ "${1:-}" == "--link-only" ]]; then
link_dotfiles
exit 0
fi
script_run "$DOT_DIR/scripts/gh.sh"
link_dotfiles
script_run "$SCRIPTS_DIR/install_tools.sh"
echo "✅️ Finished!"