forked from iadnah/bashrc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·63 lines (51 loc) · 1.38 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
#!/bin/bash
for old in .bashrc .bash_aliases .bash_completion .bash_functions; do
if [ -f "${HOME}/${old}" ]; then
echo "Found existing ${old}, backing up to ${old}.bak"
mv ${HOME}/${old} ${HOME}/${old}.bak
fi
done
for new in bashrc bash_aliases bash_functions bash_completion; do
if [ -f "./${new}" ]; then
echo "Installing ${new}"
cp -v "./${new}" "${HOME}/.${new}" 2>/dev/null | awk '{print "\t" $0}'
fi
done
unset $new
for new in bashrc.precustom bashrc.postcustom; do
if [ -f "./${new}" ]; then
if [ -f "${HOME}/.${new}" ]; then
loop=1
while [ $loop == 1 ]; do
read -p "Overwrite ${HOME}/.${new} [Y/n] " overwrite
case "$overwrite" in
'Y'|'y'|'yes')
cp -v "./${new}" "${HOME}/.${new}" 2>/dev/null | awk '{print "\t" $0}'
loop=0
;;
'N'|'n'|'no')
echo "No"
loop=0
;;
*)
echo "Type 'yes' or 'no' (I'm lazy)"
;;
esac
unset $overwrite
done
else
echo "Installing ${new}"
cp -v "./${new}" "${HOME}/.${new}" 2>/dev/null | awk '{print "\t" $0}'
fi
fi
done
for newd in bash_aliases bash_functions bash_completion; do
if [ ! -d "${HOME}/.${newd}.d}" ]; then
echo "Creating ${HOME}/.${newd}.d:"
mkdir -pv "${HOME}/.${newd}.d"
chmod 0700 "${HOME}/.${newd}.d"
fi
if [ -d "${HOME}/.${newd}.d" ]; then
cp -rv ./${newd}.d/* ${HOME}/.${newd}.d/ 2>/dev/null | awk '{print "\t" $0}'
fi
done