Skip to content

Commit 2437801

Browse files
committed
Add install script
1 parent c123c7a commit 2437801

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ Ever found the perfect wallpaper but couldn't get your terminal colors to match?
2424

2525
## Installation
2626

27+
### Quick Install (Recommended)
28+
29+
```bash
30+
curl -fsSL https://raw.githubusercontent.com/bjarneo/peachy/main/install.sh | bash
31+
```
32+
2733
### Prerequisites
2834

29-
- **Go 1.21+**
3035
- **ImageMagick** (for color extraction)
3136

3237
```bash
@@ -42,6 +47,8 @@ brew install imagemagick
4247

4348
### Build from Source
4449

50+
Requires **Go 1.21+**
51+
4552
```bash
4653
git clone https://github.com/bjarneo/peachy.git
4754
cd peachy

install.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
# Function to get latest release version
4+
get_latest_version() {
5+
curl -sS https://api.github.com/repos/bjarneo/peachy/releases/latest | grep "tag_name" | cut -d '"' -f 4
6+
}
7+
8+
# Function to detect OS and architecture
9+
detect_system() {
10+
local os
11+
local arch
12+
13+
# Detect OS
14+
case "$(uname -s)" in
15+
Darwin*) os="darwin" ;;
16+
Linux*) os="linux" ;;
17+
*) echo "Unsupported operating system" && exit 1 ;;
18+
esac
19+
20+
# Detect architecture
21+
case "$(uname -m)" in
22+
x86_64) arch="amd64" ;;
23+
arm64) arch="arm64" ;;
24+
aarch64) arch="arm64" ;;
25+
*) echo "Unsupported architecture" && exit 1 ;;
26+
esac
27+
28+
echo "${os}-${arch}"
29+
}
30+
31+
# Main installation process
32+
main() {
33+
echo "Detecting system..."
34+
local system=$(detect_system)
35+
local version=$(get_latest_version)
36+
37+
echo "Latest version: ${version}"
38+
echo "System detected: ${system}"
39+
40+
# Check if peachy already exists
41+
if command -v peachy >/dev/null 2>&1; then
42+
echo "peachy is already installed at $(which peachy)"
43+
# Only prompt if running interactively (not piped)
44+
if [ -t 0 ]; then
45+
read -p "Do you want to override the existing installation? (y/N) " response
46+
case "$response" in
47+
[yY][eE][sS]|[yY])
48+
echo "Proceeding with installation..."
49+
;;
50+
*)
51+
echo "Installation cancelled"
52+
exit 0
53+
;;
54+
esac
55+
else
56+
echo "Upgrading..."
57+
fi
58+
fi
59+
60+
local binary_name="peachy-${system}"
61+
local download_url="https://github.com/bjarneo/peachy/releases/download/${version}/${binary_name}"
62+
63+
echo "Downloading peachy..."
64+
if ! curl -sSL -o peachy "${download_url}"; then
65+
echo "Failed to download peachy"
66+
exit 1
67+
fi
68+
69+
echo "Making binary executable..."
70+
chmod +x peachy
71+
72+
echo "Moving to /usr/local/bin..."
73+
if ! sudo mv peachy /usr/local/bin/peachy; then
74+
echo "Failed to move peachy to /usr/local/bin"
75+
echo "Please run with sudo or check permissions"
76+
exit 1
77+
fi
78+
79+
echo "peachy has been successfully installed!"
80+
echo "You can now use it by running: peachy --help"
81+
}
82+
83+
main

0 commit comments

Comments
 (0)