-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·58 lines (48 loc) · 1.23 KB
/
run
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
#!/usr/bin/env bash
## set -o errexit
## Exits the current script if any of statements return non-true value.
set -e
## set -o nounset
## Exits the script if an uninitialized variable is used.
set -u
## Trap errors in subshells and functions.
set -o errtrace
## If any of the commands fail with a non-zero exit code, then abort the
## entire pipeline with that exit code.
set -o pipefail
HOST_OS=$(uname)
if test "$HOST_OS" = "Darwin"; then
echo "Running on MacOS!"
elif test "$HOST_OS" = "Linux"; then
echo "Running on Linux!"
else
echo "Unknown host OS: $HOST_OS"
exit 1
fi
CWD="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$CWD"
remove_not_needed () {
rm -f ~/.profile
rm -f ~/.bash_logout
}
create_home_symlinks () {
cd "${CWD}"/home/
for dot in *
do
if [[ "$dot" =~ ^vim.* ]] || [[ "$dot" =~ ^bash.* ]]; then
continue
fi
echo "Linking ${dot} file."
rm -f "$HOME/.${dot}"
ln -sf "${CWD}/home/${dot}" "$HOME/.${dot}"
done
}
create_neovim_symlink () {
cd "${CWD}"
echo "Linking config/nvim file."
rm -rf "$HOME"/.config/nvim
ln -sf "${CWD}/config/nvim" "$HOME/.config/nvim"
}
remove_not_needed
create_home_symlinks
create_neovim_symlink