From c719a00bfc97a9a26c9e81abb1d44a6f95ccdd2d Mon Sep 17 00:00:00 2001 From: Scott Ames Date: Tue, 13 Aug 2024 08:34:30 -0700 Subject: [PATCH] fix(fish): gh auth status --- .../private_dot_config/fish/custom_functions.d/aqua.fish | 5 ++--- home/private_dot_config/fish/custom_functions.d/gh.fish | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/home/private_dot_config/fish/custom_functions.d/aqua.fish b/home/private_dot_config/fish/custom_functions.d/aqua.fish index 53814203..9a5ea664 100644 --- a/home/private_dot_config/fish/custom_functions.d/aqua.fish +++ b/home/private_dot_config/fish/custom_functions.d/aqua.fish @@ -4,9 +4,8 @@ function aqua \ --description "Declarative CLI Version manager. Runs behind op, if installed for GitHub API auth." \ --wraps aqua - set -l _KEYRING_AUTH (GITHUB_TOKEN="" command gh auth status | grep 'keyring' | grep '✓ Logged in') - if [ $_KEYRING_AUTH ] - set -e GITHUB_TOKEN + set -l _GH_AUTH_STATUS (GITHUB_TOKEN="" command gh auth status) + if string match -q -r "✓ Logged in" $_GH_AUTH_STATUS set -l GITHUB_TOKEN (gh auth token) command aqua $argv diff --git a/home/private_dot_config/fish/custom_functions.d/gh.fish b/home/private_dot_config/fish/custom_functions.d/gh.fish index cc516bb1..387cd7b4 100644 --- a/home/private_dot_config/fish/custom_functions.d/gh.fish +++ b/home/private_dot_config/fish/custom_functions.d/gh.fish @@ -4,11 +4,10 @@ function gh \ --description "GitHub CLI. Runs behind op, if installed for GitHub API auth." \ --wraps gh - set -l _KEYRING_AUTH (GITHUB_TOKEN="" command gh auth status | grep 'keyring' | grep '✓ Logged in') - if [ $_KEYRING_AUTH ] - set -e GITHUB_TOKEN - - command gh $argv + set -l _GH_AUTH_STATUS (GITHUB_TOKEN="" command gh auth status) + # set -l _KEYRING_AUTH (GITHUB_TOKEN="" command gh auth status | grep 'keyring' | grep -q '✓ Logged in') + if string match -q -r "✓ Logged in" $_GH_AUTH_STATUS + GITHUB_TOKEN="" command gh $argv else if [ $HAS_OP ] op run -- gh $argv else