-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·154 lines (126 loc) · 3.66 KB
/
install
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/sh
set -e
STOW_PACKAGES_PATH="$HOME"/dotfiles/packages
unlink_packages=
verbose=
for i in "$@"; do
case "$i" in
-s|--skip-apps)
skip_apps=1
shift ;;
-v|--verbose)
verbose=1
shift ;;
-u=*|--unlink=*)
unlink_packages="${i#*=}"
shift ;;
-ua|--unlink-all)
unlink_packages="$(ls $STOW_PACKAGES_PATH)"
shift ;;
*) ;;
esac
done
log() {
message=$1
echo 📌 "$message"
}
is_file() {
path="$1"
[ -f "$path" ]
}
is_dir() {
path="$1"
[ -d "$path" ]
}
if [ -n "$unlink_packages" ]; then
log 'Unlinking dotfiles...'
for unlink_pack in $unlink_packages; do
stow -vD -d "$STOW_PACKAGES_PATH" -t ~ "$unlink_pack"
done
exit
fi
# check Mac
if [ "$(uname)" = "Darwin" ]; then
if [ "$(uname -m)" = "x86_64" ]; then
log "Intel mac"
elif [ "$(uname -m)" = "arm64" ]; then
log "arm64"
fi
fi
# checking brew path to see bin file exists or not
arch_name="$(uname -m)"
if [ "${arch_name}" = "x86_64" ]; then
if ! is_file /usr/local/bin/brew; then
log 'Setup Homebrew'
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
elif [ "${arch_name}" = "arm64" ]; then
if ! is_file /opt/homebrew/bin/brew; then
log 'Setup Homebrew'
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
log 'Install Rosetta 2'
sudo softwareupdate --install-rosetta
fi
fi
# zi
# if ! is_dir ~/.zi; then
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/zdharma-continuum/zinit/HEAD/scripts/install.sh)"
# fi
CLONE_PATH=$HOME # <- change it
# if [ ! -d "$CLONE_PATH" ]; then
# mkdir -p "$CLONE_PATH"
# fi
# check whether dotfiles is already cloned or not
if [ ! -d "$CLONE_PATH"/dotfiles ]; then
cd "$CLONE_PATH"
git clone https://github.com/nuovotaka/dotfiles.git # <- change it
fi
brew bundle -v --file "$CLONE_PATH"/dotfiles/Brewfile
if [ ! -d $HOME/.config ]; then
mkdir $HOME/.config/
fi
log 'Symlink by stow'
stow -v -d "$STOW_PACKAGES_PATH" -t $HOME $(ls $STOW_PACKAGES_PATH)
# Neovim
plug_path=~/.local/share/nvim/site/pack/packer/start/packer.nvim
if ! is_file "$plug_path"; then
log 'Setup vim-plug"'
git clone --depth 1 https://github.com/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/start/packer.nvim
fi
# git
if ! is_file ~/.ssh/id_ed25519.pub; then
log 'Setup gpg signing for git'
ssh-keygen -t ed25519 -C "tkn.infomail@gmail.com"
log 'Copy and pates the SSH key below to GitHub'
cat ~/.ssh/id_ed25519.pub
fi
# asdf
for plugin in $(awk '{print $1}' ~/.tool-versions); do
if ! is_dir ~/.asdf/plugins/"$plugin"; then
asdf plugin add "$plugin"
fi
done
is_runtime_versions_changed () {
plugin="$1"
specified=$(grep "$plugin" ~/.tool-versions | awk '{$1=""; print $0}')
installed=$(asdf list "$plugin" 2>&1)
is_changed=
for version in $specified; do
match=$(echo "$installed" | grep "$version")
[ -z "$match" ] && is_changed=1
done
[ "$is_changed" ]
}
for plugin in $(asdf plugin list); do
if is_runtime_versions_changed "$plugin"; then
if [ "$plugin" = nodejs ]; then log "Import release team keyring for Node.JS"
bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
fi
log "Install runtime: $plugin"
asdf install "$plugin"
fi
done
log 'Need Install typescript-language-server'
log 'npm i -g typescript-language-server'