-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.sh
More file actions
258 lines (229 loc) Β· 8.22 KB
/
install.sh
File metadata and controls
258 lines (229 loc) Β· 8.22 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/bash
set -e
REPO="https://github.com/Tanayk07/codeprint"
VERSION="1.0.5"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# ASCII Banner
print_banner() {
echo -e "${BLUE}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${BLUE}β π CODEPRINT INSTALLER v1.0.7 β${NC}"
echo -e "${BLUE}β AI-Ready Code Snapshots for Any Project β${NC}"
echo -e "${BLUE}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo ""
}
# Detect OS
detect_os() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "macos"
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
echo "windows"
else
echo "unknown"
fi
}
# Check for Python
check_python() {
if command -v python3 &> /dev/null; then
echo "python3"
elif command -v python &> /dev/null; then
echo "python"
else
echo ""
fi
}
# Install clipboard dependencies
install_clipboard_deps() {
local os=$1
echo -e "${YELLOW}π Setting up clipboard support...${NC}"
case $os in
linux)
if command -v apt &> /dev/null; then
echo -e "${CYAN}Installing xclip for clipboard support...${NC}"
sudo apt update && sudo apt install -y xclip
elif command -v yum &> /dev/null; then
echo -e "${CYAN}Installing xclip for clipboard support...${NC}"
sudo yum install -y xclip
elif command -v dnf &> /dev/null; then
echo -e "${CYAN}Installing xclip for clipboard support...${NC}"
sudo dnf install -y xclip
elif command -v pacman &> /dev/null; then
echo -e "${CYAN}Installing xclip for clipboard support...${NC}"
sudo pacman -S --noconfirm xclip
else
echo -e "${YELLOW}β Could not auto-install clipboard support${NC}"
echo -e " Install manually: sudo apt install xclip (or equivalent)"
fi
;;
macos)
echo -e "${GREEN}β Clipboard support built-in on macOS${NC}"
;;
windows)
echo -e "${CYAN}Installing pyperclip for clipboard support...${NC}"
pip install pyperclip
;;
esac
}
# Install using pip
install_pip() {
local python_cmd=$1
echo -e "${GREEN}π¦ Installing via pip...${NC}"
$python_cmd -m pip install --upgrade pip
$python_cmd -m pip install codeprint
}
# Install using npm
install_npm() {
echo -e "${GREEN}π¦ Installing via npm...${NC}"
npm install -g codeprint
}
# Install on macOS
install_macos() {
if command -v brew &> /dev/null; then
echo -e "${GREEN}πΊ Installing via Homebrew...${NC}"
brew tap Tanayk07/codeprint
brew install codeprint
else
local python_cmd=$(check_python)
if [ -n "$python_cmd" ]; then
install_pip $python_cmd
else
echo -e "${RED}β Python not found. Please install Python first.${NC}"
exit 1
fi
fi
}
# Install on Linux
install_linux() {
local python_cmd=$(check_python)
if [ -z "$python_cmd" ]; then
echo -e "${YELLOW}π Installing Python...${NC}"
if command -v apt &> /dev/null; then
sudo apt update
sudo apt install -y python3 python3-pip
python_cmd="python3"
elif command -v yum &> /dev/null; then
sudo yum install -y python3 python3-pip
python_cmd="python3"
elif command -v dnf &> /dev/null; then
sudo dnf install -y python3 python3-pip
python_cmd="python3"
elif command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm python python-pip
python_cmd="python3"
else
echo -e "${RED}β Could not install Python automatically${NC}"
exit 1
fi
fi
# Check for snap
if command -v snap &> /dev/null; then
echo -e "${CYAN}Do you want to install via Snap? (y/N): ${NC}"
read -r use_snap
if [[ $use_snap =~ ^[Yy]$ ]]; then
echo -e "${GREEN}π¦ Installing via Snap...${NC}"
sudo snap install codeprint
return
fi
fi
install_pip $python_cmd
}
# Install on Windows
install_windows() {
if command -v choco &> /dev/null; then
echo -e "${GREEN}π« Installing via Chocolatey...${NC}"
choco install codeprint
elif command -v winget &> /dev/null; then
echo -e "${GREEN}π¦ Installing via WinGet...${NC}"
winget install codeprint
else
local python_cmd=$(check_python)
if [ -n "$python_cmd" ]; then
install_pip $python_cmd
else
echo -e "${RED}β Python not found. Please install Python first.${NC}"
exit 1
fi
fi
}
# Run post-install setup
run_post_install() {
echo -e "\n${CYAN}π§ Running post-installation setup...${NC}"
# Try to run setup
if command -v codeprint &> /dev/null; then
codeprint --setup
else
echo -e "${YELLOW}β Could not find codeprint command${NC}"
echo -e " You may need to restart your terminal or add to PATH"
echo -e " Then run: ${CYAN}codeprint --setup${NC}"
fi
}
# Main installation
main() {
print_banner
OS=$(detect_os)
PYTHON=$(check_python)
echo -e "π₯οΈ Detected OS: ${YELLOW}$OS${NC}"
if [ "$OS" != "macos" ] && [ -z "$PYTHON" ]; then
echo -e "${RED}β Python is not installed.${NC}"
echo -e "Please install Python 3.7+ from https://www.python.org/"
exit 1
fi
if [ -n "$PYTHON" ]; then
echo -e "π Python command: ${YELLOW}$PYTHON${NC}"
fi
echo ""
# Install clipboard dependencies first
install_clipboard_deps $OS
echo ""
# Install based on OS
case $OS in
macos)
install_macos
;;
linux)
install_linux
;;
windows)
install_windows
;;
*)
echo -e "${YELLOW}β Unknown OS. Attempting pip installation...${NC}"
if [ -n "$PYTHON" ]; then
install_pip $PYTHON
else
echo -e "${RED}β Cannot install without Python${NC}"
exit 1
fi
;;
esac
echo ""
echo -e "${GREEN}β
Installation complete!${NC}"
# Run post-install setup
run_post_install
echo ""
echo -e "${BLUE}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${BLUE}β π READY TO USE! π β${NC}"
echo -e "${BLUE}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo ""
echo -e "${CYAN}π Getting Started:${NC}"
echo -e " ${YELLOW}codeprint --help${NC} # Show all options"
echo -e " ${YELLOW}codeprint${NC} # Scan current directory"
echo -e " ${YELLOW}codeprint -i${NC} # Interactive mode"
echo -e " ${YELLOW}codeprint -f mcp -c${NC} # MCP format + clipboard"
echo ""
echo -e "${CYAN}π‘ Pro Tips:${NC}"
echo -e " β’ Use ${YELLOW}--ignore${NC} to exclude files/directories"
echo -e " β’ MCP format works great with AI assistants"
echo -e " β’ Interactive mode provides a file browser"
echo ""
echo -e "${GREEN}π Happy coding with CodePrint!${NC}"
}
# Run main function
main