This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·170 lines (137 loc) · 3.86 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
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
#!/bin/bash
# _ _ _ _
# (_)_ __ ___| |_ __ _| | |
# | | '_ \/ __| __/ _` | | |
# | | | | \__ \ || (_| | | |
# |_|_| |_|___/\__\__,_|_|_|
function createBackupDir () {
local __bkdir="~/.bk/$(date +%Y-%m-%d-%H%M%S)"
# create a backup directory if it doesn't exist
mkdir -p "$__bkdir"
# move files into backup directory
for i in .bash_profile .bashrc .profile .vimrc .viminfo .alias; do
# if not a symlink, backup the file
if [ ! -h "~/$i" ]; then
mv "$i" "$__bkdir"
fi
done
}
function setupBash () {
# deploy symlinks to new files
if [ -f "$(find ~/dotfiles/bash/bashrc -type f)" ]; then
ln -fs ~/dotfiles/bash/bashrc ~/.bashrc
else
printf "~/dotfiles/bash/bashrc NOT FOUND\n"
fi
if [ -f "$(find ~/dotfiles/bash/bash_profile -type f)" ]; then
ln -fs ~/dotfiles/bash/bash_profile ~/.bash_profile
else
printf "~/dotfiles/bash/bash_profile NOT FOUND\n"
fi
# reload .bash_profile
source ~/.bash_profile
}
function setupVIM () {
mkdir -p ~/dotfiles/vim/colors
# symlink the vim color directory
ln -fs ~/dotfiles/vim ~/.vim
# symlink over vim stuff
ln -fs ~/dotfiles/vim/vimrc ~/.vimrc
# download vim themes
curl -s -O https://raw.githubusercontent.com/Yggdroot/duoduo/master/colors/duoduo.vim
mv duoduo.vim ~/dotfiles/vim/colors/
}
function installAptCyg () {
# download apt-cyg
if [ "$(which lynx)" ]; then
lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
else
printf "Make sure that lynx is installed prior to running cygwin setup"
exit 1
fi
# install apt-cyg
install apt-cyg /bin
}
function installApps () {
local __apps=(vim tmux zip unzip rar unrar rsync curl pv git wget bc gh)
local __appsLinux=(htop)
local __appsCygwin=()
# determine if cygwin and install apt-cyg
if [ "$(uname -s | grep -ic 'cygwin')" -eq 1 ] && [ ! "$(command -v apt-cyg)" ]; then
printf "Detected Cygwin..."
installAptCyg
fi
# apt
if [ "$(command -v apt-get)" ]; then
# install generic apps
for i in ${__apps[@]}; do
sudo apt-get install -y $i
done
# install linux specific
for i in ${__appsLinux[@]}; do
sudo apt-get install -y $i
done
elif [ "$(command -v yum)" ]; then
# install generic apps
for i in ${__apps[@]}; do
sudo yum install -y $i
done
# install linux specific
for i in ${__appsLinux[@]}; do
sudo yum install -y $i
done
elif [ "$(command -v apt-cyg)" ]; then
# install generic apps
for i in ${__apps[@]}; do
apt-cyg install $i
done
# install cygwin specific
for i in ${__appsCygwin[@]}; do
apt-cyg install $i
done
else
printf "install method not known, skipping app install..."
fi
}
# the loop
while true; do
printf "dotfiles installation menu...\n\n"
printf "0 - Automatic Install and Setup\n"
printf "1 - Install apps\n"
printf "2 - BASH Profile\n"
printf "3 - VIM Profile\n"
printf "Q - Quit\n"
# take in input
read -p "Enter Choice: " choice
case "$choice" in
0 )
# automatic install and setup
installApps
setupBash
setupVIM
exit 0
;;
1 )
# install apps
installApps
break
;;
2 )
# setupBash
setupBash
break
;;
3 )
# setupVIM
setupVIM
break
;;
q|Q )
# quit
exit 0
;;
* )
printf "Choice not recognized, try again..."
;;
esac
done