-
Notifications
You must be signed in to change notification settings - Fork 2
/
init
64 lines (56 loc) · 1.47 KB
/
init
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
#!/bin/bash
[ "${DEBUG:-0}" -eq 1 ] && set -x
OUTPUT="$HOME"
INPUT="https://raw.githubusercontent.com/TxGVNN/dots/master"
# msg SUBJECT CONTENT
msg(){ printf "\e[32m%s\e[0m: %s\n" "$1" "$2";}
banner(){
echo -e '\e[-1;34m'
echo -e ' ##### ### # # # # # #'
echo -e ' # # # # ## # ## #'
echo -e ' # \e[0;31m# #\e[0;34m # ## # # # # # # # #'
echo -e ' # \e[0;31m#\e[0;34m # # # # # ## # ##'
echo -e ' # \e[0;31m# #\e[0;34m ### # # # # #'
echo ''
echo -e ' \e[0;36m[ @author TxGVNN ]\e[0m'
echo ''
}
download OUTPUT LINK
download(){
if type wget >& /dev/null; then
wget -qO "$1" "$2"
return $?
fi
if type curl >& /dev/null; then
curl -sSL -o "$1" "$2"
return $?
fi
echo "Please install wget or curl command!"
exit 1
}
# install OUTPUT LINK
install(){
if [ -e "$1" ]; then
echo "W: $1 is exist, backup first"
cp -v "$1" "$1.$(date +%F@%R.%s)"
fi
echo "I: Install $1"
download "$1" "$2"
}
# install OUTPUT LINK
apply(){
if grep "TxGVNN" "$1" >& /dev/null ; then
echo "I: Skip $1"
return 0
fi
tmp=$(mktemp -t bakXXXXX -u)
echo "O: Apply $1"
download "$tmp" "$2"
cat "$tmp" >> "$1"
return $?
}
# main
banner
install "${OUTPUT}/.screenrc" "${INPUT}/.screenrc"
install "${OUTPUT}/.emacs" "${INPUT}/.emacs"
apply "${OUTPUT}/.bashrc" "${INPUT}/.bashrc"