-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmini_installer.sh
More file actions
executable file
·45 lines (37 loc) · 1.2 KB
/
mini_installer.sh
File metadata and controls
executable file
·45 lines (37 loc) · 1.2 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
#!/bin/bash
# Colors for output
GREEN="\033[0;32m"
RED="\033[0;31m"
RESET="\033[0m"
# Create bin directory if it doesn't exist
mkdir -p "$HOME/bin" || {
echo -e "${RED}Failed to create $HOME/bin directory${RESET}"
exit 1
}
# Clean and rebuild the project
echo -e "${GREEN}Building and cleaning minishell...${RESET}"
make allclean
# Check if build was successful
if [ ! -f "./minishell" ]; then
echo -e "${RED}Build failed! minishell executable not found${RESET}"
exit 1
fi
# Copy minishell to user's bin directory
echo -e "${GREEN}Installing minishell...${RESET}"
cp "./minishell" "$HOME/bin/" || {
echo -e "${RED}Failed to copy minishell to $HOME/bin${RESET}"
exit 1
}
chmod +x "$HOME/bin/minishell" || {
echo -e "${RED}Failed to make minishell executable${RESET}"
exit 1
}
# Add to PATH if not already there
if [[ ":$PATH:" != *":$HOME/bin:"* ]]; then
echo 'export PATH="$HOME/bin:$PATH"' >> "$HOME/.bashrc"
echo 'export PATH="$HOME/bin:$PATH"' >> "$HOME/.zshrc"
echo -e "${GREEN}Added $HOME/bin to PATH in .bashrc and .zshrc${RESET}"
fi
make fclean
echo -e "${GREEN}Installation complete!${RESET}"
echo -e "Run minishell by typing ${GREEN}minishell${RESET} in your terminal!"