-
Notifications
You must be signed in to change notification settings - Fork 0
/
personal_packages.sh
executable file
·208 lines (179 loc) · 5.02 KB
/
personal_packages.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/env bash
set -euo pipefail
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
function help() {
cat << EOF
personal_packages.sh a dotfiles install script
--install : Install all features including all configs, docker, zsh, go...
--configs : configs, Install just config files
EOF
}
if [[ $# -le 0 ]]; then
help
exit
fi
source utils.sh
trap exit SIGINT
if [ "$EUID" -eq "0" ] && ! (grep -Fq "docker" /proc/1/cgroup) ; then
echo "Please do not run as root"
exit
fi
PPACKAGES=$(pwd)
BUILDS="${HOME}/builds"
function whichos() {
awk -F= '$1=="PRETTY_NAME" { print $2 ;}' /etc/os-release | tr -d \"
}
function whichrepo(){
awk -F@ '"\turl = git"==$1 {print $2;exit;}' ./.git/config
}
function neoneofetch() {
echo "----------------------------------------------------------------------------------------------------------------"
echo -e ""
echo -e ""
echo -e ""
echo -e ""
echo -e ""
echo -e " ┈┈╱▔▔▔▔▔╲┈┈ ${BLUE}User:${NC} $(whoami)"
echo -e " ┈▕╋╋╋╋╋╋╋▏┈ ${BLUE}Hostname:${NC} $(hostname)"
echo -e " ┈▕╳╳╳╳╳╳╳▏┈ ${BLUE}Distro:${NC} $(machine)"
echo -e " ┈┈╲╳╳╳╳╳╱┈┈ ${BLUE}Kernel:${NC} $(uname -r)"
echo -e " ┈┈┈╲╋╋╋╱┈┈┈ ${BLUE}Shell:${NC} $SHELL"
echo -e " ┈┈┈┈╲▂╱┈┈┈┈ ${BLUE}CPU:${NC} "
echo -e " ┈┈┈┈▕▅▏┈┈┈┈ ${BLUE}Dotfiles:${NC} $(whichrepo)"
echo -e " "
echo -e ""
echo -e " "
echo ""
echo "----------------------------------------------------------------------------------------------------------------"
echo ""
}
function create_directories() {
task "Creating directories"
directories=(".ssh"
".config"
$BUILDS
".emacs.d"
)
for d in ${directories[@]}; do
sub_sub "creating ${d}"
mkdir -p "${HOME}/${d}"
done
if [[ ! -a "${HOME}/bin" ]]; then
sub_sub "Linking bin"
ln -s "${PPACKAGES}/bin" "${HOME}"
fi
}
# Move dotfiles
function move_dotfiles() {
# Create directories
dotFiles=(".zshrc"
".aliases"
".bashrc"
".vimrc"
".gitignore_global"
".gitconfig"
".env"
".tmux.conf"
".tmux.conf.local"
".p10k.zsh"
)
create_directories
task "Replacing config files"
sub "Updating env with new PPACKAGES"
# sed -i "s/PPACKAGES=/PPACKAGES=${PPACKAGES//\//\\/}/g" ./config/.env
for i in ${!dotFiles[@]}; do
sub "copying ${dotFiles[i]}"
ln -sf "${PWD}/config/${dotFiles[i]}" "${HOME}/${dotFiles[i]}"
done
sub "copying nvim"
ln -sf "${PWD}/config/nvim" "${HOME}/.config/"
sub "copying emacs config"
# ln -sf "${PWD}/config/init.el" "${HOME}/.emacs.d/"
# ln -sf "${PWD}/config/init.el" "${HOME}"
}
function addSSHLink() {
if [ ! -f "~/.ssh/config" ]
then
./sshconfig/link.sh
else
echo "SSH Config already exists"
fi
}
function install_packages_linux() {
# get the packages that will be used for other packages
task "Initializing install"
sub "Installing packages"
apt_install apt-utils \
gcc \
build-essential \
dialog \
curl \
git \
wget \
software-properties-common \
python3-dev \
python3-pip \
sub_sub "Update Submodules"
}
function install_packages_osx() {
brew install fzf fd ripgrep gnu-sed
}
function install_omz() {
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
}
function main() {
git submodule init
git submodule update
neoneofetch
create_directories
if [[ $machine == "Linux" ]]; then
install_packages_linux
elif [[ $machine == "Mac" ]]; then
install_packages_osx
fi
addSSHLink
move_dotfiles
# This sources all files in modules
# running the function with the filename
# ex: in modules/test.sh, the test function will be called
# this must be done because we only have a global scope, so we can't just use main
# for file in modules/*.sh
# do
# source $file
# _name=${file%.*}
# #name=${x%%.*}
# name=$(basename $_name)
# eval $name
# done
}
while [[ $# -gt 0 && ${1} ]]; do
case "${1}" in
--install)
main
shift
;;
--configs)
move_dotfiles
shift
;;
--neoneofetch | -n)
neoneofetch
shift
;;
--help | -h)
help
break;
;;
*)
echo "Incorrect option provided: ${1}"
break
;;
esac
done