-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·107 lines (90 loc) · 2.95 KB
/
setup.sh
File metadata and controls
executable file
·107 lines (90 loc) · 2.95 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
#!/usr/bin/env bash
# setup.sh
#
# Installs the dotfiles for the user.
# Terminate script on error
set -e
# Get the source directory
# (This may not be portable.)
src_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# If one argument:
# We symlink "$HOME/$1" to "$src_dir/$1".
# If two arguments:
# We symlink "$HOME/$1/$2" to "$src_dir/$1/$2".
# Intermediate parent directories are also created.
# NOTE: "rm" is used instead of the "ln -T" option for compatibility.
function ln_corresponding() {
if [[ "$#" == 1 ]]; then
ln -sfn "$src_dir/$1" "$HOME/$1"
elif [[ "$#" == 2 ]]; then
mkdir -p "$HOME/$1"
ln -sfn "$src_dir/$1/$2" "$HOME/$1/$2"
else
echo "Wrong number of arguments for ln_corresponding()."
exit 1
fi
}
export -f ln_corresponding
# If one argument:
# We symlink "$HOME/$1" to "$src_dir/$1".
# If two arguments:
# We symlink "$HOME/$1/$2" to "$src_dir/$1/$2".
# Intermediate parent directories are also created.
# NOTE: "rm" is used instead of the "ln -T" option for compatibility.
function cp_corresponding() {
if [[ "$#" == 1 ]]; then
cp "$src_dir/$1" "$HOME/$1"
elif [[ "$#" == 2 ]]; then
mkdir -p "$HOME/$1"
cp "$src_dir/$1/$2" "$HOME/$1/$2"
else
echo "Wrong number of arguments for cp_corresponding()."
exit 1
fi
}
export -f cp_corresponding
################################################################################
# We first process the shortcut.
################################################################################
if [[ "$1" == "minimal" ]]; then
echo "Running minimal dotfile installation."
echo
bash "$src_dir/dotfiles/general/setup.sh"
exit 0
elif [[ -n "$1" ]]; then
echo "[ERROR] Unknown mode: $1"
echo "There is currently only one supported mode: minimal"
exit 1
fi
################################################################################
# If we didn't take any shortcuts, we run the full installer.
################################################################################
echo "Detecting system information..."
# System detection
if [[ "$OSTYPE" == "darwin"* ]]; then
os_type="mac"
utils_flavour="bsd"
else
# Catch-all: Assume everything else is GNU.
os_type="gnu"
utils_flavour="gnu"
fi
echo "OSTYPE = $OSTYPE"
echo "os_type = $os_type"
echo "utils_flavour = $utils_flavour"
printf "\n"
echo "Running the setup scripts..."
printf "\n"
bash "$src_dir/dotfiles/general/setup.sh"
if [[ "$os_type" == "gnu" ]]; then
bash "$src_dir/dotfiles/general-linux/setup.sh"
bash "$src_dir/dotfiles/kde/setup.sh"
fi
bash "$src_dir/dotfiles/git/setup.sh"
bash "$src_dir/dotfiles/neovim/setup.sh"
bash "$src_dir/dotfiles/newsboat/setup.sh"
## We no longer install vim by default since I'm using neovim.
## Uncomment this and then rerun setup.sh to install vim.
#bash "$src_dir/dotfiles/vim/setup.sh"
bash "$src_dir/dotfiles/vscodium/setup.sh"
echo "ALL DONE!"