summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Scott <hi@alecbcs.com>2024-10-02 06:34:30 -0700
committerGitHub <noreply@github.com>2024-10-02 15:34:30 +0200
commitf92c5d7a2ed014489deb65e98782bb77cf696aa3 (patch)
tree7fa0eb9080759ec907880d5e468f977eb286d6de
parentdcdc678b19def86b584182bcde47cf8858617e31 (diff)
downloadspack-f92c5d7a2ed014489deb65e98782bb77cf696aa3.tar.gz
spack-f92c5d7a2ed014489deb65e98782bb77cf696aa3.tar.bz2
spack-f92c5d7a2ed014489deb65e98782bb77cf696aa3.tar.xz
spack-f92c5d7a2ed014489deb65e98782bb77cf696aa3.zip
gh: add shell completions (#46701)
-rw-r--r--var/spack/repos/builtin/packages/gh/package.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/gh/package.py b/var/spack/repos/builtin/packages/gh/package.py
index 90f40c6313..dd89fe3686 100644
--- a/var/spack/repos/builtin/packages/gh/package.py
+++ b/var/spack/repos/builtin/packages/gh/package.py
@@ -50,3 +50,19 @@ class GoBuilder(spack.build_systems.go.GoBuilder):
args = super().build_args
args.extend(["-trimpath", "./cmd/gh"])
return args
+
+ @run_after("install")
+ def install_completions(self):
+ gh = Executable(self.prefix.bin.gh)
+
+ mkdirp(bash_completion_path(self.prefix))
+ with open(bash_completion_path(self.prefix) / "gh", "w") as file:
+ gh("completion", "-s", "bash", output=file)
+
+ mkdirp(fish_completion_path(self.prefix))
+ with open(fish_completion_path(self.prefix) / "gh.fish", "w") as file:
+ gh("completion", "-s", "fish", output=file)
+
+ mkdirp(zsh_completion_path(self.prefix))
+ with open(zsh_completion_path(self.prefix) / "_gh", "w") as file:
+ gh("completion", "-s", "zsh", output=file)