-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
60 lines (43 loc) · 1.43 KB
/
install.sh
File metadata and controls
60 lines (43 loc) · 1.43 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
#!/bin/bash
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Detect OS
if [[ "$OSTYPE" == "darwin"* ]]; then
OS="mac"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
else
echo "Unsupported OS: $OSTYPE"
exit 1
fi
sudo -v
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
################################### Symlink stuff ############################
################### (Backs up the previous versions if they exist) ###########
# symlinks
DOTFILES_ROOT="$(pwd)"
backup_and_symlink() {
local file=$1
local target=$2
if [[ -e "$target" ]]; then
cp "$target" "${target}_bak"
fi
ln -sf "$DOTFILES_ROOT/$file" "$target"
}
# Install brew on macOS
if [[ "$OS" == "mac" ]]; then
if ! command_exists brew; then
/usr/bin/ruby -e "$(curl -fsSL https://github.com/Homebrew/install/master/install)"
fi
# Install via brew
brew bundle --file=./Brewfile
backup_and_symlink ".aliases" "$HOME/.aliases"
backup_and_symlink ".gitconfig" "$HOME/.gitconfig"
backup_and_symlink ".config/fish/config.fish" "$HOME/.config/fish/config.fish"
elif [[ "$OS" == "linux" ]]; then
echo "Please ensure you have the necessary packages installed via your package manager."
backup_and_symlink ".aliases" "$HOME/.aliases"
backup_and_symlink ".gitconfig" "$HOME/.gitconfig"
fi