-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·162 lines (140 loc) · 4.03 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
#!/bin/bash
# Installation script for m0re's dotfiles
# Author: Michiel - [email protected]
err_report() {
echo "Error on line $1"
}
trap 'err_report $LINENO' ERR
SCRIPT_PATH=$(echo $0 | sed "s|^\.\./|`pwd`/../|" | sed "s|^\./|`pwd`/|")
DOT_FOLDER="$(dirname $SCRIPT_PATH)"
echo "Installing dotfiles from folder $DOT_FOLDER"
echo -n "Do you want to symlink general dotfiles like .bashrc, .gitconfig, etc.. ([y]/n): "
read LINK_GENERAL
LINK_GENERAL=${LINK_GENERAL:-y}
echo -n "Do you want to symlink i3 config ([y]/n): "
read LINK_i3
LINK_i3=${LINK_i3:-y}
echo -n "Do you want to symlink terminator config ([y]/n): "
read LINK_TERMINATOR
LINK_TERMINATOR=${LINK_TERMINATOR:-y}
echo -n "Do you want to symlink vscode config ([y]/n): "
read LINK_VSCODE
LINK_VSCODE=${LINK_VSCODE:-y}
echo -n "Is this a remote setup (y/[n]): "
read REMOTE
REMOTE=${REMOTE:-n}
if [ -z ${HOME+x} ]; then
echo "HOME is unset, not able to check for existing links";
exit 1
else
echo "HOME is set to '$HOME'";
fi
if [[ ! $DOT_FOLDER = *"projects"* ]]; then
echo "dotfiles not in 'projects' folder"
exit 1
fi
export PROJECT_FOLDER="$(dirname $DOT_FOLDER)"
echo "PROJECT_FOLDER is set to '$PROJECT_FOLDER'"
BASH_LOAD="${DOT_FOLDER}/system/.bash_load"
touch ${BASH_LOAD}
echo "Created ${BASH_LOAD}"
link_general () {
echo " -- Setting general symlinks.."
SYS_FILES="$DOT_FOLDER/system/.??*"
GIT_FILES="$DOT_FOLDER/git/.??*"
VIM_FILES="$DOT_FOLDER/vim/.??*"
for f in $SYS_FILES $GIT_FILES $VIM_FILES
do
file="$(basename $f)"
if [[ ! -e "$HOME/$file" ]]; then
echo "Linking $file to $HOME/"
ln -s $f "$HOME/$file"
else
echo "$HOME/$file already linked"
fi
done
}
link_i3 () {
echo " -- Linking i3 related configuration.."
# Link i3 files to ~/.config/i3/
i3_FILES="$DOT_FOLDER/i3/??*"
i3_CONFIG_DIR="$HOME/.config/i3"
# check if i3 config directory exists
if [[ ! -d $i3_CONFIG_DIR ]]; then
mkdir -p $i3_CONFIG_DIR
fi
for f in $i3_FILES
do
file="$(basename $f)"
if [[ ! -e "$i3_CONFIG_DIR/$file" ]]; then
echo "Linking $file to $i3_CONFIG_DIR"
ln -s $f "$i3_CONFIG_DIR/$file"
else
echo "$i3_CONFIG_DIR/$file already linked"
fi
done
i3_STATUS_FILES="$DOT_FOLDER/i3status/??*"
i3_STATUS_CONFIG_DIR="$HOME/.config/i3status/"
# check if i3status config directory exists
if [[ ! -d $i3_STATUS_CONFIG_DIR ]]; then
mkdir -p $i3_STATUS_CONFIG_DIR
fi
for f in $i3_STATUS_FILES
do
file="$(basename $f)"
if [[ ! -e "$i3_STATUS_CONFIG_DIR/$file" ]]; then
echo "Linking $file to $i3_STATUS_CONFIG_DIR/"
ln -s $f "$i3_STATUS_CONFIG_DIR/$file"
else
echo "$i3_STATUS_CONFIG_DIR/$file already linked"
fi
done
}
link_terminator () {
echo " -- Setting Terminator symlinks.."
TERMINATOR_CONFIG_DIR="$HOME/.config/terminator"
file="$DOT_FOLDER/system/terminator.config"
if [[ ! -e "$TERMINATOR_CONFIG_DIR/config" ]]; then
echo "Linking $file to $TERMINATOR_CONFIG_DIR/"
ln -s $file "$TERMINATOR_CONFIG_DIR/config"
else
echo "$TERMINATOR_CONFIG_DIR/$(basename $file) already linked"
fi
}
link_vscode () {
echo " -- Setting vscode symlinks"
VSCODE_CONFIG_DIR="$HOME/.config/Code/User"
VSCODE_FILES="$DOT_FOLDER/vscode/??*"
if [[ ! -d $VSCODE_CONFIG_DIR ]]; then
mkdir -p $VSCODE_CONFIG_DIR
fi
for f in $VSCODE_FILES
do
file="$(basename $f)"
if [[ ! -e "$VSCODE_CONFIG_DIR/$file" ]]; then
echo "Linking $file to $VSCODE_CONFIG_DIR/"
ln -s $f "$VSCODE_CONFIG_DIR/$file"
else
echo "$VSCODE_CONFIG_DIR/$file already linked"
fi
done
}
if [[ "$LINK_GENERAL" == "y" ]]; then
link_general
fi
if [[ "$LINK_i3" == "y" ]]; then
link_i3
fi
if [[ "$LINK_TERMINATOR" == "y" ]]; then
link_terminator
fi
if [[ "$LINK_VSCODE" == "y" ]]; then
link_vscode
fi
if [[ $REMOTE == "n" ]]; then
# Install stuff
sudo apt install fortune cowsay imagemagick scrot
else
echo "export DOT_REMOTE=1" >> ${BASH_LOAD}
fi
echo "Source .bashrc or restart your terminal to load your system changes"