File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff 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
3853For more info on how to configure opencode [ ** head over to our docs** ] ( https://opencode.ai/docs ) .
Original file line number Diff line number Diff line change @@ -41,9 +41,21 @@ case "$filename" in
4141 ;;
4242esac
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+
4555mkdir -p " $INSTALL_DIR "
4656
57+ print_message info " Installing to: ${YELLOW} $INSTALL_DIR ${GREEN} "
58+
4759if [ -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}' )
You can’t perform that action at this time.
0 commit comments