Created
November 11, 2022 07:25
-
-
Save ghthor/33a418854e01abc1d83450f3ebcfecef to your computer and use it in GitHub Desktop.
Subject: [PATCH] Add bash/zsh completions and fix version string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 8faf889cf8991cd383ad89bbd1f93d8db2ec5a6a Mon Sep 17 00:00:00 2001 | |
From: Will Owens <[email protected]> | |
Date: Fri, 11 Nov 2022 02:13:38 -0500 | |
Subject: [PATCH] Add bash/zsh completions and fix version string | |
They are embedded in a command that requires sudo to run so I | |
pulled the templates out of their source so we can install them | |
a package build time instead of afterwards. | |
``` | |
$ earthly bootstrap --autocomplete | |
``` | |
Also, I fixed the version string being passed to the build to avoid this | |
warning message from `earthly bootstrap` | |
``` | |
$ earthly bootstrap | |
buildkitd | Starting buildkit daemon as a docker container (earthly-buildkitd)... | |
buildkitd | ...Done | |
buildkitd | Warning: Buildkit version (v0.6.27) is different from Earthly version (0.6.27) | |
``` | |
--- | |
Makefile | 3 +++ | |
PKGBUILD | 16 +++++++++++++--- | |
earthly.bash-completion | 2 ++ | |
earthly.zsh-completion | 8 ++++++++ | |
4 files changed, 26 insertions(+), 3 deletions(-) | |
create mode 100644 Makefile | |
create mode 100644 earthly.bash-completion | |
create mode 100644 earthly.zsh-completion | |
diff --git a/Makefile b/Makefile | |
new file mode 100644 | |
index 0000000..d5871ad | |
--- /dev/null | |
+++ b/Makefile | |
@@ -0,0 +1,3 @@ | |
+.PHONY: shfmt | |
+shfmt: | |
+ shfmt -w -i 4 ./PKGBUILD | |
diff --git a/PKGBUILD b/PKGBUILD | |
index 010abfe..60e7597 100644 | |
--- a/PKGBUILD | |
+++ b/PKGBUILD | |
@@ -10,8 +10,16 @@ license=('MPL2') | |
depends=('docker') | |
makedepends=('git' 'go') | |
BUILDENV+=('!check') | |
-source=("git+https://github.com/earthly/earthly.git#tag=v${pkgver}") | |
-sha256sums=('SKIP') | |
+source=( | |
+ "git+https://github.com/earthly/earthly.git#tag=v${pkgver}" | |
+ "earthly.bash-completion" | |
+ "earthly.zsh-completion" | |
+) | |
+sha256sums=( | |
+ 'SKIP' | |
+ 'd6003dada86fefa4ab84be64d8a314527bfe117591640fd399c90d925de85212' | |
+ '54d597dccde088ca71873f2c3681fe38a4d634b096d4a763c31192157505fb38' | |
+) | |
prepare() { | |
mkdir -p earthly/build | |
@@ -20,7 +28,7 @@ prepare() { | |
build() { | |
local _ldflags='-linkmode=external' | |
_ldflags+=" -X main.DefaultBuildkitdImage=docker.io/earthly/buildkitd:v${pkgver}" | |
- _ldflags+=" -X main.Version=${pkgver}" | |
+ _ldflags+=" -X main.Version=v${pkgver}" | |
_ldflags+=" -X main.GitSha=$(git -C earthly rev-parse HEAD)" | |
local _tags='dfrunmount,dfrunsecurity,dfsecrets,dfssh,dfrunnetwork,dfheredoc,forceposix' | |
export CGO_CPPFLAGS="$CPPFLAGS" | |
@@ -39,4 +47,6 @@ check() { | |
package() { | |
install -D -m755 earthly/build/earthly -t "${pkgdir}/usr/bin" | |
+ install -D -m644 earthly.bash-completion -T "${pkgdir}/usr/share/bash-completion/completions/earthly" | |
+ install -D -m644 earthly.zsh-completion -T "${pkgdir}/usr/share/zsh/site-functions/_earthly" | |
} | |
diff --git a/earthly.bash-completion b/earthly.bash-completion | |
new file mode 100644 | |
index 0000000..e04a341 | |
--- /dev/null | |
+++ b/earthly.bash-completion | |
@@ -0,0 +1,2 @@ | |
+# Sourced from: https://github.com/earthly/earthly/blob/84c74238a21ff7372d61322800da08a4e28a8584/cmd/earthly/autocomplete.go#L164 | |
+complete -o nospace -C '/usr/bin/earthly' earthly | |
diff --git a/earthly.zsh-completion b/earthly.zsh-completion | |
new file mode 100644 | |
index 0000000..18dee29 | |
--- /dev/null | |
+++ b/earthly.zsh-completion | |
@@ -0,0 +1,8 @@ | |
+#compdef _earthly earthly | |
+function _earthly { | |
+ autoload -Uz bashcompinit | |
+ bashcompinit | |
+ complete -o nospace -C '/usr/bin/earthly' earthly | |
+} | |
+ | |
+# Sourced from: https://github.com/earthly/earthly/blob/84c74238a21ff7372d61322800da08a4e28a8584/cmd/earthly/autocomplete.go#L169 | |
-- | |
2.37.3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment