forked from seanbell/term-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·87 lines (76 loc) · 2.12 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
#!/bin/bash
echo "$0: TERM-TOOLS INSTALLER"
echo ""
# if -f, make sure it is intended
for f in $@; do
if [ "$f" == "-f" ]; then
echo "Note: -f was provided as an argument, which may overwrite any existing configuration"
read -r -p "Are you sure? [y/N] " response
case $response in
[yY][eE][sS]|[yY])
:
;;
*)
exit 1
;;
esac
else
echo "Error: unknown argument: $f"
exit 1
fi
done
# trap errors
function print_err() {
echo "ERROR: install incomplete"
}
trap print_err ERR
set -e
# Load submodules
git pull
git submodule init
git submodule update
# run through the installers
for f in $(ls -1 installers/*.sh); do
inst="y"
read -r -p "Install config for $(basename $f .sh)? [Y/n] " response
if [ -z "$response" ] || [[ $response =~ ^[Yy]$ ]] ; then
if bash $f $@; then
echo "SUCCESS: $f"
else
echo "ERROR: $f"
exit 1
fi
else
echo "SKIPPING: $f"
fi
done
for f in ~/.zshrc ~/.bashrc; do
if [[ -s $f ]]; then
if [[ $(grep -c 'source ~/term-tools/config/shrc.sh' $f) == "0" ]]; then
echo '[[ -s ~/term-tools/config/shrc.sh ]] && source ~/term-tools/config/shrc.sh' >> $f
fi
if [[ $(grep -c 'source ~/term-tools/ssh-find-agent/ssh-find-agent.bash' $f) == "1" ]]; then
echo 'source ~/term-tools/ssh-find-agent/ssh-find-agent.bash' >> $f
echo 'if [ ! -e $SSH_AUTH_SOCK ]; then' >> $f
echo ' set_ssh_agent_socket' >> $f
echo 'fi' >> $f
fi
if [[ $(grep -c 'source ~/term-tools/config/shrc-tmux.sh' $f) == "0" ]]; then
echo '' >> $f
echo '# This line starts all new shells inside tmux (if tmux is installed and set up).' >> $f
echo '# It must be the last command in this file.' >> $f
echo '[[ -s ~/term-tools/config/shrc-tmux.sh ]] && source ~/term-tools/config/shrc-tmux.sh' >> $f
fi
fi
done
set +x
echo ""
echo " == INSTALL COMPLETE =="
echo ""
echo "To overwrite existing config, rerun with -f (this will delete any existing configuration)"
echo ""
echo "To make zsh the default shell, run:"
echo " chsh -s /bin/zsh"
echo "and then restart the terminal (or re-login for Ubuntu)"
echo ""
echo " ======================"