GeezerVison is showing github.com — Added install dir priority & user feedback (#1129) · toastdriven/opencode@01e7dc2
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: README.md +15Lines changed: 15 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -33,6 +33,21 @@ paru -S opencode-bin # Arch Linux |
33 | 33 | > [!TIP] |
34 | 34 | > Remove versions older than 0.1.x before installing. |
35 | 35 |
|
| 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 | + |
36 | 51 | ### Documentation |
37 | 52 |
|
38 | 53 | For more info on how to configure opencode [**head over to our docs**](https://opencode.ai/docs). |
|
Collapse file
Copy file name to clipboardExpand all lines: install +13-1Lines changed: 13 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -41,9 +41,21 @@ case "$filename" in |
41 | 41 | ;; |
42 | 42 | esac |
43 | 43 |
|
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 | + |
45 | 55 | mkdir -p "$INSTALL_DIR" |
46 | 56 |
|
| 57 | +print_message info "Installing to: ${YELLOW}$INSTALL_DIR${GREEN}" |
| 58 | + |
47 | 59 | if [ -z "$requested_version" ]; then |
48 | 60 | url="https://github.com/sst/opencode/releases/latest/download/$filename" |
49 | 61 | specific_version=$(curl -s https://api.github.com/repos/sst/opencode/releases/latest | awk -F'"' '/"tag_name": "/ {gsub(/^v/, "", $4); print $4}') |
|