-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·86 lines (76 loc) · 2.71 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
#!/bin/bash
# TABLE OF CONTENTS
# 1. Create and verify symbolic links of config files
# 2. Install Homebrew and Brewfile
# 3. Install macOS specific settings
# 4. Terminal, and TMUX setup
# Function to create and verify symbolic links
create_and_verify_symlink() {
# source_file is where we make changes
local source_file=$1
# clone file is the blank file we want to point at the source_file
local clone_file=$2
if [ -f "$source_file" ]; then
ln -sf "$source_file" "$clone_file"
if [ "$(readlink "$clone_file")" == "$source_file" ]; then
echo "Successfully linked $clone_file to $source_file"
else
echo "Failed to link $clone_file to $source_file"
fi
else
echo "$source_file not found!"
fi
}
# create symbolic links required for proper system function
create_and_verify_symlink ~/.dotfiles/git/.gitconfig ~/.gitconfig
create_and_verify_symlink ~/.dotfiles/git/.gitignore_global ~/.gitignore_global
create_and_verify_symlink ~/.dotfiles/config/.zshrc ~/.zshrc
create_and_verify_symlink ~/.dotfiles/config/tmux.conf ~/.tmux.conf
create_and_verify_symlink ~/.dotfiles/config/starship.toml ~/.config/starship.toml
# check if homebrew is installed, otherwise install it
if test ! $(which brew); then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
# update homebrew if already installed
brew update
fi
# if the first argument is not --no-brew, install from Brewfile
if [ "${1:-}" != "--no-brew" ]; then
if [ -f ~/.dotfiles/config/Brewfile ]; then
# install everything in the Brewfile
brew bundle --file ~/.dotfiles/config/Brewfile
else
echo "Brewfile not found in ~/.dotfiles!"
fi
fi
# Check if the OS is macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
# Execute the .macos script
if [ -f ~/.dotfiles/config/.macos ]; then
echo "Executing ~/.dotfiles/config/.macos"
chmod +x ~/.dotfiles/config/.macos
~/.dotfiles/config/.macos
echo "Finished executing ~/.dotfiles/config/.macos"
killall Dock
else
echo "~/.dotfiles/config/.macos not found!"
fi
else
echo "This script is intended for macOS. Skipping macOS-specific configurations."
fi
# Terminal set up
# download the catppuccin mocha theme
curl -Lo ~/.config/alacritty/catppuccin-mocha.toml https://github.com/catppuccin/alacritty/raw/main/catppuccin-mocha.toml
# Install TPM (Tmux Plugin Manager)
TPM_DIR="$HOME/.tmux/plugins/tpm"
if [ ! -d "$TPM_DIR" ]; then
echo "TPM not found. Installing..."
git clone https://github.com/tmux-plugins/tpm "$TPM_DIR"
if [ $? -eq 0 ]; then
echo "TPM installed successfully."
else
echo "Failed to install TPM. Please check your internet connection and try again."
fi
else
echo "TPM is already installed."
fi