-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·138 lines (111 loc) · 2.73 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
set -ex
# set -x
dotfiles=( \
.bash_profile \
.profile \
.editorconfig \
.bashrc \
.common_env \
.common_shrc \
.editrc \
.gemrc \
.gitconfig \
.gitignore \
.gitmessage \
.inputrc \
.spacemacs \
.tmux-osx.conf \
.tmux.conf \
.zlogin \
.zshenv \
.zshrc \
.ideavimrc \
.vifm \
.vimrc \
.vim \
.plugins.vim \
.xsessionrc \
.Xdefaults \
.Xresources \
.Xmodmap \
bin \
)
function fail() {
echo "$1\n"
exit 1
}
projects_dir=$HOME/projects
command -v git &> /dev/null || fail "Install git first"
command -v mise &> /dev/null || fail "Install mise first"
case $1 in
-dots)
if [[ $(uname) == "Linux" ]]; then
if ! python3 -m pip list | grep i3ipc > /dev/null; then
python3 -m pip install --user --upgrade i3ipc
fi
fi
if ! python3 -m pip list | grep pynvim > /dev/null; then
python3 -m pip install --user --upgrade pynvim
fi
for file in "${dotfiles[@]}"; do
ln -f -s "$(pwd)/$file" ~/
done
mkdir -p $HOME/.config
for dir in $(pwd)/.config/* $(pwd)/.config/.*; do
if [[ "$dir" =~ \.$ ]]; then
continue
fi
if [[ -d $dir ]]; then
target_dir=~/.config/$(basename $dir)/
mkdir -p $target_dir
for file in $dir/*; do
ln -f -s $file $target_dir
done
else
ln -f -s $dir ~/.config
fi
done
mkdir -p ~/.ssh
for file in $(pwd)/.ssh/*; do
ln -f -s $file ~/.ssh
done
if [[ ! -d ~/.config/i3blocks-contrib ]]; then
git clone https://github.com/vivien/i3blocks-contrib.git ~/.config/i3blocks-contrib
fi
mkdir -p $projects_dir
if [[ ! -d $HOME/.zsh/completion ]]; then
git clone https://github.com/zsh-users/zsh-completions.git $HOME/.zsh/completion
fi
if [[ ! -d $HOME/.zsh/zplug ]]; then
git clone https://github.com/zplug/zplug $HOME/.zsh/zplug
fi
if [[ ! -d ~/.fzf ]]; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
yes | ~/.fzf/install
fi
if [[ ! -d ~/.tmux/plugins/tpm ]]; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
if [[ ! -d ~/.local/share/mime/packages ]]; then
mkdir -r ~/.local/share/mime/packages
fi
for file in ./mime/*; do
ln -f -s "$(pwd)/$file" ~/.local/share/mime/packages/
done
;;
-tmux)
command -v tmux &> /dev/null || fail "Install tmux first"
tpm_home=~/.tmux/plugins/tpm
if [ ! -d $tpm_home ]; then
git clone https://github.com/tmux-plugins/tpm $tpm_home
fi
tmux new -d -s temp
~/.tmux/plugins/tpm/tpm
$tpm_home/scripts/install_plugins.sh >/dev/null 2>&1
tmux kill-session -t temp
;;
*)
$0 -dots
;;
esac