-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·192 lines (167 loc) · 4.41 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CURRENT_DIR=`pwd`
OS_TYPE=$(uname)
C_R="\e[1;31m"
C_G="\e[1;32m"
C_B="\e[1;34m"
C_Y="\e[1;33m"
C_NC="\e[0m"
B="\e[1m"
I="\e[3m"
U="\e[4m"
if [ $(echo $TERM | grep 256 | wc -l) -eq 0 ]; then
C_R=""
C_G=""
C_B=""
C_Y=""
C_NC=""
B=""
fi
echo -e "$B"
echo '_________ .__ ________ '
echo '\_ ___ \_____ _______| | / _____/ '
echo '/ \ \/\__ \\_ __ \ | / \ ___ '
echo '\ \____/ __ \| | \/ |_\ \_\ \ '
echo ' \______ (____ /__| |____/\______ / '
echo ' \/ \/ \/ '
echo '________ __ _____.__.__ '
echo '\______ \ _____/ |__/ ____\__| | ____ ______'
echo ' | | \ / _ \ __\ __\| | | _/ __ \ / ___/'
echo ' | ` ( <_> ) | | | | | |_\ ___/ \___ \ '
echo '/_______ /\____/|__| |__| |__|____/\___ >____ >'
echo ' \/ \/ \/ '
echo -e "$C_NC"
echo -e "$B* Looking for required binaries$C_NC"
for b in git curl; do
echo -n " $b: "
command -v $b &> /dev/null && echo -e "${C_G}installed$C_NC" || ( echo -e "$b: ${C_R}not installed$C_NC"; exit 1 )
done
echo ""
function link_file {
file=$(basename $2)
if [ -L $2 ]; then
echo -e "$C_Y Symlink $2 exists$C_NC"
elif [ -d $2 ]; then
echo -e "$C_R Dir $2 exists$C_NC"
elif [ -f $2 ]; then
echo -e "$C_R File $2 exists$C_NC"
elif [ ! -L $2 ]; then
echo -e "$C_G Symlinking $file$C_NC"
ln -s $1 $2
fi
}
echo -e "$B* Looking for required tools$C_NC"
echo -n " oh-my-zsh: "
test ! -d $HOME/.oh-my-zsh && {
echo -e "${C_Y}not installed$C_NC"
curl -L https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
test -L $HOME/.zshrc || rm $HOME/.zshrc
} || {
echo -e "${C_G}installed$C_NC"
}
echo -n " rustup: "
test ! command -v rustup &> /dev/null && {
echo -e "${C_Y}not installed$C_NC"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup component add rust-src
rustup component add clippy rustfmt
} || {
echo -e "${C_G}installed$C_NC"
}
echo -n " tmux tpm: "
test ! -d $HOME/.tmux/plugins/tpm && {
echo -e "${C_Y}not installed$C_NC"
mkdir -p $HOME/.tmux/plugins
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
} || {
echo -e "${C_G}installed$C_NC"
}
echo ""
echo -e "$B* Looking for recommended binaries$C_NC"
for b in nvim tmux zsh gpg ; do
echo -n " $b: "
command -v $b &> /dev/null && echo -e "${C_G}installed$C_NC" || echo -e "${C_R}not installed$C_NC"
done
echo -n " wasmtime: "
test ! -d $HOME/.wasmtime && {
echo -e "${C_R}not installed$C_NC"
curl https://wasmtime.dev/install.sh -sSf | bash
rustup target add wasm32-wasi
cargo install cargo-wasi
} || {
echo -e "${C_G}installed$C_NC"
}
echo ""
echo -e "$B* Looking for rust tools$C_NC"
while IFS=, read -r name bin; do
echo -n " $name: "
! command -v $bin &> /dev/null && {
echo -e "${C_Y}not installed$C_NC"
cargo install $name
} || {
echo -e "${C_G}installed$C_NC"
}
done << EOL
eza,eza
starship,starship
ripgrep,rg
hyperfine,hyperfine
bat,bat
jless,jless
tokei,tokei
htmlq,htmlq
difftastic,difft
fd-find,fd
cargo-update,cargo-install-update
topgrade,topgrade
cargo-sweep,cargo-sweep
cargo-cranky,cargo-cranky
EOL
echo ""
COMMON=(
config/nvim
config/tmux
config/alacritty
config/mutt
config/nushell
config/starship.toml
config/topgrade.toml
config/wezterm
gitconfig
psqlrc
zshrc
ripgreprc
cargo/config.toml
)
BIN=$(ls $DIR/bin)
cd $CURRENT_DIR
test ! -d $HOME/.cargo && mkdir $HOME/.cargo
if [ ! -d $HOME/.config ]; then
echo "** Creating ~/.config/"
mkdir -p $HOME/.config
echo ""
fi
echo "* Linking files"
for file in ${COMMON[@]}; do
link_file $DIR/home/$file $HOME/.$file
done
echo ""
if [ ! -d $HOME/.local/bin ]; then
echo "* Creating ~/.local/bin/"
mkdir -p $HOME/.local/bin
echo ""
fi
echo "* Linking bin"
for file in ${BIN[@]}; do
link_file $DIR/bin/$file $HOME/.local/bin/$file
done
echo ""
IFS='
'
echo "* Looking for broken symlinks in home directory"
for l in $(find $HOME -maxdepth 3 -type l -exec file {} \; | grep -v 'snap' | grep broken | cut -d\ -f1,6); do
path=$(echo $l | cut -d: -f1)
echo -e "${C_R} rm $path$C_NC"
done
unset IFS