diff --git a/.docker/apk.yaml b/.docker/apk.yaml new file mode 100644 index 0000000000..e8b49b75fc --- /dev/null +++ b/.docker/apk.yaml @@ -0,0 +1,8 @@ +services: + apk: + build: + context: apk + image: ghcr.io/carapace-sh/carapace-bin:apk + hostname: carapace-bin:apk + volumes: + - '..:/carapace-bin:ro' diff --git a/.docker/apk/Dockerfile b/.docker/apk/Dockerfile new file mode 100644 index 0000000000..7afb6aa8ba --- /dev/null +++ b/.docker/apk/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine + +RUN apk add gcompat +RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community elvish + +RUN mkdir -p ~/.config/elvish \ + && echo -e "set paths = [ /carapace-bin/cmd/carapace \$@paths ]\neval (carapace _carapace|slurp)" > ~/.config/elvish/rc.elv +ENV PATH="/carapace-bin/cmd/carapace:$PATH" + +CMD ["elvish"] diff --git a/cmd/carapace/cmd/invoke.go b/cmd/carapace/cmd/invoke.go index 0de4fbc83d..dd8618884b 100644 --- a/cmd/carapace/cmd/invoke.go +++ b/cmd/carapace/cmd/invoke.go @@ -14,6 +14,7 @@ import ( "github.com/carapace-sh/carapace-bin/cmd/carapace/cmd/completers" "github.com/carapace-sh/carapace-bridge/pkg/actions/bridge" "github.com/carapace-sh/carapace-bridge/pkg/bridges" + "github.com/carapace-sh/carapace/pkg/uid" "github.com/spf13/cobra" ) @@ -233,13 +234,9 @@ func invokeCompleter(completer string) string { out := <-outC os.Stdout = old - executable, err := os.Executable() - if err != nil { - panic(err.Error()) // TODO exit with error message - } - executableName := filepath.Base(executable) - patched := strings.Replace(string(out), fmt.Sprintf("%v _carapace", executableName), fmt.Sprintf("%v %v", executableName, completer), -1) // general callback - patched = strings.Replace(patched, fmt.Sprintf("'%v', '_carapace'", executableName), fmt.Sprintf("'%v', '%v'", executableName, completer), -1) // xonsh callback + executable := uid.Executable() + patched := strings.Replace(string(out), fmt.Sprintf("%v _carapace", executable), fmt.Sprintf("%v %v", executable, completer), -1) // general callback + patched = strings.Replace(patched, fmt.Sprintf("'%v', '_carapace'", executable), fmt.Sprintf("'%v', '%v'", executable, completer), -1) // xonsh callback return patched } diff --git a/compose.yaml b/compose.yaml index 80bae4a978..47afb438e3 100644 --- a/compose.yaml +++ b/compose.yaml @@ -2,6 +2,7 @@ include: # shells and build related services - .docker/carapace.yaml # tools + - .docker/apk.yaml - .docker/bloop.yaml - .docker/fzf-tab.yaml - .docker/gcloud.yaml diff --git a/go.mod b/go.mod index dcc34898ea..328aec13dd 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/carapace-sh/carapace-bin go 1.23.1 require ( - github.com/carapace-sh/carapace v1.5.2 + github.com/carapace-sh/carapace v1.5.3 github.com/carapace-sh/carapace-bridge v1.2.2 github.com/carapace-sh/carapace-selfupdate v0.0.8 github.com/carapace-sh/carapace-shlex v1.0.1 diff --git a/go.sum b/go.sum index 0edeaec514..a68c9e2514 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/carapace-sh/carapace v1.5.2 h1:ddFLVzPLmEUnKTtglMDDnfbFSYyCMEd0xn1ysguSWLw= -github.com/carapace-sh/carapace v1.5.2/go.mod h1:djegtVDi/3duSAqZNU+/nCq7XtDRMRZUb5bW0O/HnEs= +github.com/carapace-sh/carapace v1.5.3 h1:mDLq48Q01OBFUFqGoCEvHt3nh+hntmQEiTQ7OsyI8fg= +github.com/carapace-sh/carapace v1.5.3/go.mod h1:djegtVDi/3duSAqZNU+/nCq7XtDRMRZUb5bW0O/HnEs= github.com/carapace-sh/carapace-bridge v1.2.2 h1:Zlzw7BajF4iHAFBClCYcptEG+7+F324dFyiGzGiU/kw= github.com/carapace-sh/carapace-bridge v1.2.2/go.mod h1:HpN3iEdCmQtAD1pd/qHEnWmAF719CeNyJrY8FJ5/E4o= github.com/carapace-sh/carapace-pflag v1.0.0 h1:uJMhl+vwEM/Eb0UdxZUuv4jo4rUAyPijkRGP5gfCuCE=