This repository has been archived by the owner on Dec 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·60 lines (48 loc) · 1.89 KB
/
install
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
#!/bin/bash
declare notice_color='\e[93m'
declare error_color='\e[91m'
declare wipe="\033[1m\033[0m"
declare INSTALL_BOOT="source $HOME/.bash.d/boot"
declare INSTALL_FILE=$HOME/.bash_profile
if [ ! -f $INSTALL_FILE ]; then
INSTALL_FILE=$HOME/.bashrc
fi
if [ ! -f $INSTALL_FILE ]; then
printf "${error_color}Can't install because neither .bashrc or .bash_profile were found in \"${HOME}\".${wipe}\n"
exit 1;
fi
if grep -q "$INSTALL_BOOT" $INSTALL_FILE; then
printf "Boot settings found in ${notice_color}${INSTALL_FILE}${wipe}. Skipping ...\n"
else
echo $INSTALL_BOOT >> $INSTALL_FILE
printf "Boot settings have been saved to your ${notice_color}$(basename $INSTALL_FILE)${wipe} file.\n"
fi
for source_file in $HOME/.bash.d/dot-files/*; do
target_file=$HOME/.$(basename $source_file)
if [ ! -f $target_file ]; then
printf "Linking ${notice_color}${source_file}${wipe} to ${notice_color}${target_file}${wipe}\n"
ln -s $source_file $target_file
else
printf "${notice_color}${target_file}${wipe} already exists. Skipping ...\n"
fi
done
unset source_file
unset target_file
declare CUSTOM_SCRIPTS_DIR="$HOME/.bash.custom"
if [ ! -d $CUSTOM_SCRIPTS_DIR ]; then
mkdir -p $CUSTOM_SCRIPTS_DIR
fi
declare CUSTOM_GIT_SETTINGS_FILE="$CUSTOM_SCRIPTS_DIR/git.bash"
if [ ! -f $CUSTOM_GIT_SETTINGS_FILE ]; then
touch $CUSTOM_GIT_SETTINGS_FILE
fi
if ! grep -q "GIT_AUTHOR_NAME" $CUSTOM_GIT_SETTINGS_FILE; then
read -p "GIT user name: " git_user_name
echo "export GIT_AUTHOR_NAME=\"${git_user_name}\"" >> $CUSTOM_GIT_SETTINGS_FILE
printf "Wrote user name to ${notice_color}${CUSTOM_GIT_SETTINGS_FILE}${wipe}\n"
fi
if ! grep -q "export EMAIL" $CUSTOM_GIT_SETTINGS_FILE; then
read -p "GIT email: " git_email
echo "export EMAIL=\"${git_email}\"" >> $CUSTOM_GIT_SETTINGS_FILE
printf "Wrote email to ${notice_color}${CUSTOM_GIT_SETTINGS_FILE}${wipe}\n"
fi