-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
Β·113 lines (96 loc) Β· 2.9 KB
/
setup.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
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
#!/bin/zsh
DOTFILES_DIR="$HOME/Developer/dotfiles"
echo "β‘οΈ Check sudo privileges..."
if ! sudo -v; then
echo "β This script requires sudo privileges"
exit 1
fi
echo ""
# Keep sudo timeout refreshed
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
osascript -e 'tell application "Terminal" to set the font size of window 1 to 14'
echo "πΊπΊπΊ Setting up Homebrew..."
if (( ! $+commands[brew] )); then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [ $? -ne 0 ]; then
echo "β Homebrew installation failed"
exit 1
fi
# Set up Homebrew PATH
echo "πΊ Setting up Homebrew PATH..."
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
if [ $? -ne 0 ]; then
echo "β Failed to set up Homebrew PATH"
exit 1
fi
else
echo "πΊ Homebrew is already installed"
fi
echo "πΊ Turning off Homebrew analytics..."
brew analytics off
if [ $? -ne 0 ]; then
echo "β Failed to turn off analytics"
exit 1
fi
echo "πΊ Updating Homebrew..."
brew update
if [ $? -ne 0 ]; then
echo "β Update failed"
exit 1
fi
echo ""
echo "π¦ Check and manage dotfiles repository..."
if [ -d "$DOTFILES_DIR" ]; then
echo "π Dotfiles directory exists at $DOTFILES_DIR"
# Change to dotfiles directory
cd "$DOTFILES_DIR" || {
echo "β Failed to change to dotfiles directory"
exit 1
}
# Check if there are any local changes
if ! git diff --quiet HEAD; then
echo "β Local dotfiles have uncommitted changes. Please commit or stash them first."
exit 1
fi
# Fetch remote changes
echo "π¦ Checking for remote changes..."
echo ""
if ! git fetch origin master; then
echo "β Failed to fetch from remote"
exit 1
fi
# Check if local is behind remote
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse @{u})
if [ "$LOCAL" = "$REMOTE" ]; then
echo ""
echo "π¦ Dotfiles are up to date"
else
# Try to fast-forward merge
if ! git merge-base --is-ancestor HEAD FETCH_HEAD; then
echo "β Local and remote histories have diverged. Please resolve manually."
exit 1
else
echo "β³ Pulling latest changes..."
if ! git pull --ff-only origin master; then
echo "β Failed to pull changes"
exit 1
fi
echo ""
echo "π¦ Successfully updated dotfiles"
fi
fi
else
echo "β³ Cloning dotfiles..."
if ! git clone https://github.com/deligoez/dotfiles.git "$DOTFILES_DIR"; then
echo "β Failed to clone dotfiles"
exit 1
fi
fi
cd "$DOTFILES_DIR" || {
echo "β Failed to change to dotfiles directory"
exit 1
}
echo ""
source ./install.sh