ソースを参照

Added install dir priority & user feedback (#1129)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: thdxr <[email protected]>
opencode-agent[bot] 8 ヶ月 前
コミット
01e7dc2d02
2 ファイル変更28 行追加1 行削除
  1. 15 0
      README.md
  2. 13 1
      install

+ 15 - 0
README.md

@@ -33,6 +33,21 @@ paru -S opencode-bin               # Arch Linux
 > [!TIP]
 > [!TIP]
 > Remove versions older than 0.1.x before installing.
 > Remove versions older than 0.1.x before installing.
 
 
+#### Installation Directory
+
+The install script respects the following priority order for the installation path:
+
+1. `$OPENCODE_INSTALL_DIR` - Custom installation directory
+2. `$XDG_BIN_DIR` - XDG Base Directory Specification compliant path
+3. `$HOME/bin` - Standard user binary directory (if exists or can be created)
+4. `$HOME/.opencode/bin` - Default fallback
+
+```bash
+# Examples
+OPENCODE_INSTALL_DIR=/usr/local/bin curl -fsSL https://opencode.ai/install | bash
+XDG_BIN_DIR=$HOME/.local/bin curl -fsSL https://opencode.ai/install | bash
+```
+
 ### Documentation
 ### Documentation
 
 
 For more info on how to configure opencode [**head over to our docs**](https://opencode.ai/docs).
 For more info on how to configure opencode [**head over to our docs**](https://opencode.ai/docs).

+ 13 - 1
install

@@ -41,9 +41,21 @@ case "$filename" in
     ;;
     ;;
 esac
 esac
 
 
-INSTALL_DIR=$HOME/.opencode/bin
+# Determine installation directory with priority order
+if [ -n "${OPENCODE_INSTALL_DIR:-}" ]; then
+    INSTALL_DIR="$OPENCODE_INSTALL_DIR"
+elif [ -n "${XDG_BIN_DIR:-}" ]; then
+    INSTALL_DIR="$XDG_BIN_DIR"
+elif [ -d "$HOME/bin" ] || mkdir -p "$HOME/bin" 2>/dev/null; then
+    INSTALL_DIR="$HOME/bin"
+else
+    INSTALL_DIR="$HOME/.opencode/bin"
+fi
+
 mkdir -p "$INSTALL_DIR"
 mkdir -p "$INSTALL_DIR"
 
 
+print_message info "Installing to: ${YELLOW}$INSTALL_DIR${GREEN}"
+
 if [ -z "$requested_version" ]; then
 if [ -z "$requested_version" ]; then
     url="https://github.com/sst/opencode/releases/latest/download/$filename"
     url="https://github.com/sst/opencode/releases/latest/download/$filename"
     specific_version=$(curl -s https://api.github.com/repos/sst/opencode/releases/latest | awk -F'"' '/"tag_name": "/ {gsub(/^v/, "", $4); print $4}')
     specific_version=$(curl -s https://api.github.com/repos/sst/opencode/releases/latest | awk -F'"' '/"tag_name": "/ {gsub(/^v/, "", $4); print $4}')