Skip to content

Commit 61ccfbf

Browse files
opencode-agent[bot]thdxr
authored andcommitted
Added install dir priority & user feedback (sst#1129)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: thdxr <thdxr@users.noreply.github.com>
1 parent b2f9144 commit 61ccfbf

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ paru -S opencode-bin # Arch Linux
3333
> [!TIP]
3434
> Remove versions older than 0.1.x before installing.
3535
36+
#### Installation Directory
37+
38+
The install script respects the following priority order for the installation path:
39+
40+
1. `$OPENCODE_INSTALL_DIR` - Custom installation directory
41+
2. `$XDG_BIN_DIR` - XDG Base Directory Specification compliant path
42+
3. `$HOME/bin` - Standard user binary directory (if exists or can be created)
43+
4. `$HOME/.opencode/bin` - Default fallback
44+
45+
```bash
46+
# Examples
47+
OPENCODE_INSTALL_DIR=/usr/local/bin curl -fsSL https://opencode.ai/install | bash
48+
XDG_BIN_DIR=$HOME/.local/bin curl -fsSL https://opencode.ai/install | bash
49+
```
50+
3651
### Documentation
3752

3853
For more info on how to configure opencode [**head over to our docs**](https://opencode.ai/docs).

install

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,21 @@ case "$filename" in
4141
;;
4242
esac
4343

44-
INSTALL_DIR=$HOME/.opencode/bin
44+
# Determine installation directory with priority order
45+
if [ -n "${OPENCODE_INSTALL_DIR:-}" ]; then
46+
INSTALL_DIR="$OPENCODE_INSTALL_DIR"
47+
elif [ -n "${XDG_BIN_DIR:-}" ]; then
48+
INSTALL_DIR="$XDG_BIN_DIR"
49+
elif [ -d "$HOME/bin" ] || mkdir -p "$HOME/bin" 2>/dev/null; then
50+
INSTALL_DIR="$HOME/bin"
51+
else
52+
INSTALL_DIR="$HOME/.opencode/bin"
53+
fi
54+
4555
mkdir -p "$INSTALL_DIR"
4656

57+
print_message info "Installing to: ${YELLOW}$INSTALL_DIR${GREEN}"
58+
4759
if [ -z "$requested_version" ]; then
4860
url="https://github.com/sst/opencode/releases/latest/download/$filename"
4961
specific_version=$(curl -s https://api.github.com/repos/sst/opencode/releases/latest | awk -F'"' '/"tag_name": "/ {gsub(/^v/, "", $4); print $4}')

0 commit comments

Comments
 (0)