-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·105 lines (88 loc) · 1.98 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
#!/usr/bin/env bash
# TODO: what if no ruby?
readonly src_dir=$(dirname $(dirname $0))
readonly home_dir=$1
readonly local_rb=${home_dir}/.local.rb
readonly gitconfig=${home_dir}/.gitconfig
function prompt_for_username {
if [ -z "$username" ]
then
read -p "username: " username
fi
}
function prompt_for_email {
if [ -z "$email" ]
then
read -p "email: " email
fi
}
function create_local_rb {
if [ ! -e $local_rb ]
then
prompt_for_username
prompt_for_email
# ' or \ in input will cause problems
echo -n $'$username = ' >> $local_rb
echo -n "'" >> $local_rb
echo -n $username >> $local_rb
echo -n "'" >> $local_rb
echo >> $local_rb
echo -n $'$email = ' >> $local_rb
echo -n "'" >> $local_rb
echo -n $email >> $local_rb
echo -n "'" >> $local_rb
echo >> $local_rb
fi
}
function install_templates {
(
cd templates
for f in .*.erb
do
echo $f
echo ${home_dir}
echo erb -r $local_rb $f ${home_dir}/${f%.erb}
erb -r $local_rb $f > ${home_dir}/${f%.erb}
done
)
}
cd $src_dir
if [ $# -lt 1 ]
then
echo "USAGE: install.sh DIR"
exit 1
fi
if [ ! -d $home_dir ]
then
echo "NOT A DIRECTORY: " $home_dir
exit 1
fi
for dot_file in .[a-zA-Z]*
do
if [ \( $dot_file != .git \) -a \( $dot_file != .gitignore \) ]
then
if [ $dot_file = .config ]
then
:
elif [ -d $dot_file ]
then
rm -rf $home_dir/$dot_file
cp -R $dot_file $home_dir
else
cp $dot_file $home_dir
fi
fi
done
(cd ~/.emacs.d/lib && make lisp)
mkdir -p $home_dir/.config/shell
for file in .config/shell/*
do
cp $file $home_dir/.config/shell
done
mkdir -p $home_dir/Local/share
for file in Local/share/*
do
sed "s:HOME_DIR:${HOME}:" < $file > $home_dir/$file
done
create_local_rb
install_templates