forked from szorfein/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·173 lines (153 loc) · 4.8 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/sh
set -ue
GIT=$(which git)
###############################################################
# Check deps
[[ -z $GIT ]] && echo "You have to install git plz" && exit 1
###############################################################
# Local functions
anim() {
i=0
sp='/-\|'
n=${#sp}
printf ' '
while sleep 0.1; do
printf "%s\b" "${sp:i++%n:1}"
done
}
# Download with git ( arg1 = url | arg2 = path )
dl() {
local pid
echo -n "dl $1..."
anim &
pid=$!
$($GIT clone $1 $2 2>/dev/null || exit 1)
echo "[ok]"
kill $pid # kill anim()
}
# Check if file exist else download ( arg1 = url | arg2 = path )
chk() {
if [[ -d $2 ]] ; then
echo "$2 is found"
else
dl $1 $2
fi
}
forZsh() {
OH_MY_ZSH=~/.oh-my-zsh
SPACESHIP=$OH_MY_ZSH/themes/spaceship-prompt
[ -s $OH_MY_ZSH/themes/spaceship.zsh-theme ] && unlink $OH_MY_ZSH/themes/spaceship.zsh-theme
[ -d $SPACESHIP ] && rm -rf $SPACESHIP
[ -d $OH_MY_ZSH ] && {
read -p "Clearing oh-my-zsh for updates? [y/n] "
if [[ $REPLY =~ ^y|^Y ]] ; then
rm -rf $OH_MY_ZSH
else
echo "Ok, we keep your directory..."
fi
}
chk https://github.com/robbyrussell/oh-my-zsh.git $OH_MY_ZSH
chk https://github.com/denysdovhan/spaceship-prompt.git $SPACESHIP
# create symbolic link
ln -s $SPACESHIP/spaceship.zsh-theme $OH_MY_ZSH/themes/spaceship.zsh-theme
}
pathogen() {
[[ ! -d ~/.vim/bundle ]] && mkdir -p $HOME/.vim/bundle
chk https://github.com/kaicataldo/material.vim ~/.vim/bundle/material.vim
chk https://github.com/szorfein/fantasy.vim ~/.vim/bundle/fantasy.vim
chk https://github.com/szorfein/darkest-space ~/.vim/bundle/darkest-space
chk https://github.com/szorfein/fromthehell.vim ~/.vim/bundle/fromthehell.vim
chk https://github.com/szorfein/lightline.vim ~/.vim/bundle/lightline.vim
chk https://github.com/edkolev/tmuxline.vim ~/.vim/bundle/tmuxline.vim
chk https://github.com/sainnhe/gruvbox-material ~/.vim/bundle/gruvbox-material
}
get_image() {
img_name="$1"
url="$2"
wget -O /tmp/image "https://api.pcloud.com/getpubthumb?code=${url#*=}&linkpassword=undefined&size=2048x2048&crop=0&type=auto"
if file /tmp/image | grep -iE jpeg\|jpg >/dev/null ; then
echo "copying $DEST/$1.jpg..."
mv /tmp/image $DEST/$1.jpg
elif file /tmp/image | grep -i png >/dev/null ; then
echo "copying $DEST/$1.png..."
mv /tmp/image $DEST/$1.png
else
echo "extension for $1 is no found :("
exit 1
fi
img_name= url=
}
download_images() {
DEST=~/images
[ -d ~/images ] || mkdir ~/images
filename=
link=
while read line; do
filename=$(echo ${line%-*} | tr -d " ")
link=$(echo ${line#*-} | tr -d " ")
if [ -f "${DEST}/${filename}.png" ] ; then
echo "file: $filename.png exist"
elif [ -f "${DEST}/${filename}.jpg" ] ; then
echo "file: $filename.jpg exist"
else
echo "file: $filename no exist, download..."
get_image $filename $link
fi
done < hidden-stuff/wallpapers-list.txt
filename= link= DEST=
}
banner() {
printf "%s\n" \
'
▓█████▄ ▒█████ ▄▄▄█████▓ █████▒██▓ ██▓ ▓█████ ██████
▒██▀ ██▌▒██▒ ██▒▓ ██▒ ▓▒▓██ ▒▓██▒▓██▒ ▓█ ▀ ▒██ ▒
░██ █▌▒██░ ██▒▒ ▓██░ ▒░▒████ ░▒██▒▒██░ ▒███ ░ ▓██▄
░▓█▄ ▌▒██ ██░░ ▓██▓ ░ ░▓█▒ ░░██░▒██░ ▒▓█ ▄ ▒ ██▒
░▒████▓ ░ ████▓▒░ ▒██▒ ░ ░▒█░ ░██░░██████▒░▒████▒▒██████▒▒
▒▒▓ ▒ ░ ▒░▒░▒░ ▒ ░░ ▒ ░ ░▓ ░ ▒░▓ ░░░ ▒░ ░▒ ▒▓▒ ▒ ░
'
}
usage() {
banner
printf "%s\n" \
"-z, --zsh Download and install dependencies of zsh"
printf "%s\n" \
"-v, --vim Download and install dependencies of vim for pathogen"
printf "%s\n" \
"-h, --help Display this really usefull message"
}
###############################################################
# Command line options
if [ "$#" -eq 0 ]; then
printf "%s\\n" "$prog_name: Argument required"
printf "%s\\n" "Try '$prog_name --help' for more information."
exit 1
fi
while [ "$#" -gt 0 ] ; do
case "$1" in
-z | --zsh)
banner
forZsh
shift
;;
-v | --vim)
banner
pathogen
shift
;;
-i | --images)
banner
download_images
shift
;;
-h | --help)
usage
shift
;;
*)
usage
printf "\\n%s\\n" "$prog_name: Invalid option '$1'"
exit 1
;;
esac
done