-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·183 lines (129 loc) · 3.6 KB
/
setup
File metadata and controls
executable file
·183 lines (129 loc) · 3.6 KB
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
#!/usr/bin/env bash
set -e
[ -n "$DEBUG" ] && set -x
check_requirement() {
if ! command -v $1 &> /dev/null; then
echo "Ops! $2 was not found, you will have to install it and try again."
if [[ "$0" = "$BASH_SOURCE" ]] then
exit 1
fi
fi
}
backup() {
if [[ -f "$1/$2" ]] then
cp -d "$1/$2" "$3/$2"
fi
}
config() {
if [[ -f "$3/$2" ]] then
rm "$3/$2"
fi
cp "$1/$2" "$3/$2"
}
echo "Starting to setup your Linux..."
USER="${USER:-$(id -u -n)}"
HOME_DIR="${HOME_DIR:-$(getent passwd $USER 2>/dev/null | cut -d: -f6)}"
CONFIG_DIR="$HOME_DIR/.config"
FONTS_DIR="$HOME_DIR/.local/share/fonts"
BIN_DIR="$HOME_DIR/.local/bin"
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo
echo "Please, review the information bellow."
echo "User name: ${USER}"
echo "Home folder: ${HOME_DIR}"
echo
echo "Existing configuration files will be overwritten."
echo
read -p "Continue? [y/n] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]] then
echo "Exiting..."
if [[ "$0" = "$BASH_SOURCE" ]] then
exit 1
fi
fi
echo
echo "Checking for all requirements..."
check_requirement "curl" "curl"
check_requirement "git" "git"
check_requirement "kitty" "kitty"
check_requirement "zsh" "zsh"
echo "All good!"
BACKUP_FOLDER="$HOME_DIR/dotfiles_backup"
echo
echo "Backing up existent files..."
if [[ -d $BACKUP_FOLDER ]] then
rm -r $BACKUP_FOLDER
fi
mkdir -p $BACKUP_FOLDER
backup $HOME_DIR ".aliases" $BACKUP_FOLDER
backup $HOME_DIR ".localrc" $BACKUP_FOLDER
backup $HOME_DIR ".zshrc" $BACKUP_FOLDER
backup $HOME_DIR ".gitconfig" $BACKUP_FOLDER
backup $HOME_DIR ".gitconfig.local" $BACKUP_FOLDER
backup "$CONFIG_DIR/kitty" "kitty.conf" $BACKUP_FOLDER
echo "Saved at $BACKUP_FOLDER"
echo
echo "Installing brew..."
export PATH="$PATH:/home/linuxbrew/.linuxbrew/bin"
NONINTERACTIVE=1 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh?NONINTERACTIVE)">/dev/null
echo "Done!"
echo
echo "Installing zgenom..."
if [[ ! -d "$HOME_DIR/.zgenom" ]] then
git clone --quiet --depth=1 https://github.com/jandamm/zgenom.git $HOME_DIR/.zgenom
fi
echo "Done!"
echo
echo "Setting up git..."
config "$SOURCE_DIR/config" ".gitconfig" $HOME_DIR
config "$SOURCE_DIR/config" ".gitconfig.local" $HOME_DIR
echo "Done!"
echo
echo "Setting up shell..."
config "$SOURCE_DIR/config" ".aliases" $HOME_DIR
config "$SOURCE_DIR/config" ".localrc" $HOME_DIR
if [[ ! -d "$BIN_DIR" ]] then
mkdir -p "$BIN_DIR"
fi
echo "Done!"
echo
echo "Setting up zsh..."
config "$SOURCE_DIR/config" ".zshrc" $HOME_DIR
chsh -s $(which zsh) >/dev/null
echo "Done!"
echo
echo "Setting up p10k..."
if [[ ! -d "$HOME_DIR/powerlevel10k" ]] then
git clone --quiet --depth=1 https://github.com/romkatv/powerlevel10k.git $HOME_DIR/powerlevel10k
fi
config "$SOURCE_DIR/config" ".p10k.zsh" $HOME_DIR
echo "Done!"
echo
echo "Setting up kitty..."
if [[ ! -d "$CONFIG_DIR/kitty" ]]; then
mkdir -p "$CONFIG_DIR/kitty"
fi
config "$SOURCE_DIR/config" "kitty.conf" "$CONFIG_DIR/kitty"
chsh -s $(which zsh) >/dev/null
echo "Done!"
echo
echo "Installing diff-so-fancy, xclip, bat and glow..."
brew install --quiet diff-so-fancy xclip bat glow
echo "Done!"
echo
echo "Setting up custom fonts..."
if [[ ! -d "$FONTS_DIR" ]]; then
mkdir "$FONTS_DIR"
fi
for FONT_FOLDER in "$SOURCE_DIR/fonts"/*; do
if [[ -d "$FONT_FOLDER" ]]; then
FONT_NAME="$(basename "$FONT_FOLDER")"
TARGET_DIR="$FONTS_DIR/$FONT_NAME"
cp -r "$FONT_FOLDER" "$TARGET_DIR"
fi
done
sudo fc-cache -f
echo "Done!"
echo
echo "All done! Go ahead and make a good use of your OS."