-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·138 lines (112 loc) · 3.82 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# Get the absolute path of the dotfiles directory
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
RED="\033[31m"
NC='\033[0m'
print_header() {
echo -e "\n${YELLOW}==== $1 ====${NC}"
}
setup_dotfiles_dir() {
print_header "Setting up dotfiles directory"
# Create symbolic link from the actual repository location to ~/.dotfiles
if [ ! -L "$HOME/.dotfiles" ]; then
ln -sf "$DOTFILES_DIR" "$HOME/.dotfiles"
echo -e "${GREEN}✓${NC} Created symlink from $DOTFILES_DIR to ~/.dotfiles"
else
echo -e "${GREEN}✓${NC} ~/.dotfiles symlink already exists"
fi
}
setup_symlinks() {
print_header "Creating symlinks"
ln -sf "$DOTFILES_DIR/.githelpers" "$HOME/.githelpers"
ln -sf "$DOTFILES_DIR/.gitconfig" "$HOME/.gitconfig"
echo -e "${GREEN}✓${NC} Created symlink for .gitconfig"
if [[ "$(uname)" == "Darwin" ]]; then
ln -sf "$DOTFILES_DIR/.zshrc" "$HOME/.zshrc"
ln -sf "$DOTFILES_DIR/.zshrc-utils" "$HOME/.zshrc-utils"
echo -e "${GREEN}✓${NC} Created symlink for .zshrc"
elif [[ "$(uname)" == "Linux" ]]; then
ln -sf "$DOTFILES_DIR/.bashrc" "$HOME/.bashrc"
echo -e "${GREEN}✓${NC} Created symlink for .bashrc"
fi
ln -sf "$DOTFILES_DIR/.profile" "$HOME/.profile"
echo -e "${GREEN}✓${NC} Created symlink for .profile"
}
install_additional_tools() {
print_header "Installing additional tools"
if [[ "$(uname)" == "Darwin" ]]; then
if ! command -v brew >/dev/null 2>&1; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo -e "${GREEN}✓${NC} Homebrew installed"
else
echo -e "${GREEN}✓${NC} Homebrew already installed"
fi
brew_packages=(
git
wget
vim
)
echo "Installing packages with Homebrew..."
for package in "${brew_packages[@]}"; do
if ! brew list "$package" &>/dev/null; then
brew install "$package"
echo -e "${GREEN}✓${NC} Installed $package"
else
echo -e "${GREEN}✓${NC} $package already installed"
fi
done
elif [[ "$(uname)" == "Linux" ]]; then
echo "Checking if package manager is available..."
if pgrep -f apt > /dev/null || pgrep -f dpkg > /dev/null; then
echo -e "${YELLOW}⚠️ Another package manager process is running.${NC}"
echo "The additional tools installation will be skipped."
echo "You can run the separate installation script later with:"
echo -e "${GREEN}bash ${DOTFILES_DIR}/install_packages.sh${NC}"
return 0
fi
if ! sudo apt-get update; then
echo -e "${RED}✗${NC} Failed to update package lists. Continuing anyway..."
fi
apt_packages=(
git
wget
vim
)
echo "Installing packages..."
for package in "${apt_packages[@]}"; do
if ! dpkg -s "$package" &>/dev/null; then
echo "Installing $package..."
if ! sudo apt-get install -y "$package"; then
echo -e "${RED}✗${NC} Failed to install $package"
else
echo -e "${GREEN}✓${NC} Installed $package"
fi
else
echo -e "${GREEN}✓${NC} $package already installed"
fi
done
fi
}
print_header "Starting dotfiles installation"
cd ~ || exit
mkdir -p ~/.config
setup_dotfiles_dir
setup_symlinks
if [[ "$(uname)" == "Darwin" ]]; then
# shellcheck disable=SC1091
source "$DOTFILES_DIR/.zshrc-utils"
install_oh_my_zsh
install_zsh_plugins
fi
install_additional_tools
print_header "Verifying installation"
if [ -f "$HOME/.gitconfig" ]; then
echo -e "${GREEN}✓${NC} Verified .gitconfig is installed at $HOME/.gitconfig"
ls -la "$HOME/.gitconfig"
else
echo -e "${RED}✗${NC} Failed to create .gitconfig at $HOME/.gitconfig"
fi
print_header "Installation complete!"