From 523ead0cc488266a3f366f6e68fd146bcc26f0f2 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Sun, 5 Nov 2023 02:59:47 +0000 Subject: [PATCH] Fixes ASDF completion symlink and adds GH CLI --- .../run_onchange_before_09-install-gh.sh.tmpl | 28 +++++++++++++++++++ home/dot_config/git/config.tmpl | 2 ++ .../share/zsh-completion/symlink__asdf.tmpl | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 home/.chezmoiscripts/universal/run_onchange_before_09-install-gh.sh.tmpl diff --git a/home/.chezmoiscripts/universal/run_onchange_before_09-install-gh.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_before_09-install-gh.sh.tmpl new file mode 100644 index 00000000..59607a3e --- /dev/null +++ b/home/.chezmoiscripts/universal/run_onchange_before_09-install-gh.sh.tmpl @@ -0,0 +1,28 @@ +{{- if (ne .host.distro.family "windows") -}} +#!/usr/bin/env bash +# @file GH (GitHub CLI) Install +# @brief Ensures GH (the GitHub CLI) is installed via Homebrew +# @description +# This script installs GH via Homebrew. GH is included as a dependency for +# generating the global git config helper since GH provides a credential +# helper that can be used to authenticate calls on `github.com`. + +{{ includeTemplate "universal/profile-before" }} +{{ includeTemplate "universal/logg-before" }} + +### Ensure gh is installed +if ! command -v gh > /dev/null; then + if command -v brew; then + logg 'Installing gh via Homebrew' + brew install gh || GH_EXIT_CODE=$? + if [ -n "$GH_EXIT_CODE" ]; then + logg error 'gh was not successfully installed via Homebrew' + fi + else + logg 'brew is unavailable. Cannot use it to perform a system installation of node.' + fi +else + logg 'gh is available' +fi + +{{ end -}} diff --git a/home/dot_config/git/config.tmpl b/home/dot_config/git/config.tmpl index fe01b25a..3c62aaf9 100644 --- a/home/dot_config/git/config.tmpl +++ b/home/dot_config/git/config.tmpl @@ -62,10 +62,12 @@ [credential] helper = cache --timeout=3600 credentialStore = {{ if eq .host.distro.id "darwin" }}keychain{{ else }}{{ if eq .host.distro.id "windows" }}wincredman{{ else }}secretservice{{ end }}{{ end }} +{{ if (lookPath "asdf") -}} [credential "https://github.com"] helper = !{{- output "which" "gh" | trim }} auth git-credential [credential "https://gist.github.com"] helper = !{{- output "which" "gh" | trim }} auth git-credential +{{- end -}} [delta] features = Betelgeuse [delta "Betelgeuse"] diff --git a/home/dot_local/share/zsh-completion/symlink__asdf.tmpl b/home/dot_local/share/zsh-completion/symlink__asdf.tmpl index 2c38809e..faf0447f 100644 --- a/home/dot_local/share/zsh-completion/symlink__asdf.tmpl +++ b/home/dot_local/share/zsh-completion/symlink__asdf.tmpl @@ -1,3 +1,3 @@ {{- if (lookPath "asdf") -}} -{{- output "echo" "${XDG_DATA_HOME:-$HOME/.local/share}/asdf/completions/_asdf" -}} +{{ .host.home }}/.local/share/asdf/completions/_asdf {{- end -}} \ No newline at end of file