forked from faruryo/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·123 lines (100 loc) · 2.38 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
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
#! /usr/bin/env bash
set -u
e_newline() {
printf "\n"
}
e_header() {
printf "\033[37;1m%s\033[m\n" "$*"
}
e_error() {
printf "\033[31m%s\033[m\n" "✖ $*" 1>&2
}
### check
DOTPATH=${DOTPATH:-$HOME/.dotfiles}
REPO="https://github.com/ryo-murata/dotfiles"
if [ -d "$DOTPATH" ]; then
e_error "$DOTPATH: already exists"
exit 1
fi
# 変数チェック
vars=(GIT_NAME GIT_EMAIL GIT_SIGNINGKEY)
for var in "${vars[@]}"; do
eval 'echo $'$var > /dev/null
done
### install packages by install
brew install zsh-completions
chmod -R go-w $(brew --prefix)/share
BREW_PACKAGES=(
"asdf"
"bat"
"direnv"
"fd"
"fzf"
"google-cloud-sdk"
"iTerm2"
"lazydocker"
"lazygit"
"pinentry-mac"
"rg"
"ripgrep"
"skhd"
"starship"
"tmux"
"visual-studio-code"
"yabai"
"zsh-autosuggestions"
)
brew install ${BREW_PACKAGES[@]}
### install tools by asdf
ASDF_PACKAGES=(
"argocd"
"golang"
"helm"
"hugo"
"kustomize"
"nodejs"
"stern"
)
for p in ${ASDF_PACKAGES[@]}; do
asdf plugin-add ${p}
asdf install ${p} latest
asdf global ${p} latest
done
### install tmux plugins
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
### Setting key repeat
defaults write -g InitialKeyRepeat -int 10
defaults write -g KeyRepeat -float 1.3
e_newline
e_header "Downloading dotfiles..."
git clone --recursive "$REPO" "$DOTPATH"
e_header "Symlink z files..."
XDG_CONFIG_HOME=$HOME/.config
# files
declare -A dot_files
dot_files=(
["zshenv"]="zsh/.zshenv" \
["gitconfig"]="git/gitconfig" \
)
for file in "${!dot_files[@]}"; do
if [[ -f $HOME/.$file && ! -L $HOME/.$file ]]; then
mv -v $HOME/.$file $HOME/.$file.$(date +'%Y%m%d%H%M%S').backup
fi
ln -vsnf $DOTPATH/${dot_files[$file]} $HOME/.$file
done
# directories
link_dirs=(git skhd tmux tmux yabai)
for dir in "${link_dirs[@]}"; do
if [[ -d "$XDG_CONFIG_HOME/$dir" && ! -L "$XDG_CONFIG_HOME/$dir" ]]; then
mv -v $XDG_CONFIG_HOME/$dir $XDG_CONFIG_HOME/$dir.$(date +'%Y%m%d%H%M%S').backup
fi
ln -vsnf $DOTPATH/$dir $XDG_CONFIG_HOME/$dir
done
# template展開
vars_str=\$$(echo ${vars[@]} | sed 's/ /$/g')
for dir in "${link_dirs[@]}"; do
for file in $(find ${DOTPATH} -path "${DOTPATH}/${dir}/*.tmpl"); do
echo "$file => ${file%.tmpl}"
cat ${file} | envsubst "${vars_str}" > ${file%.tmpl}
done
done