From f5a73109ca50125685fdf7ac09d099c5b274502b Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Mon, 1 Jan 2024 13:07:33 +0300 Subject: [PATCH] Refactor JFrog CLI completion configuration --- jfrog-oauth/run.sh | 9 ++++----- jfrog-token/run.sh | 9 +++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/jfrog-oauth/run.sh b/jfrog-oauth/run.sh index cf3473b..a2c5255 100644 --- a/jfrog-oauth/run.sh +++ b/jfrog-oauth/run.sh @@ -101,10 +101,9 @@ fi # Configure the JFrog CLI completion echo "📦 Configuring JFrog CLI completion..." jf completion $SHELL --install -# Append the completion script to the shell profile if its bash or zsh if it isn't already there. -if [ "$SHELL" = "/bin/bash" ] || [ "$SHELL" = "/bin/zsh" ]; then - if ! grep -q "source $HOME/.jfrog/jfrog_$${SHELL}_completion" ~/.$${SHELL}rc; then - echo "📦 Adding JFrog CLI completion to shell profile..." - echo "source $HOME/.jfrog/jfrog_$${SHELL}_completion" >> ~/.$${SHELL}rc +SHELLNAME=$(basename $SHELL) +if [ "$SHELLNAME" == "bash" ] || [ "$SHELLNAME" == "zsh" ]; then + if ! grep -q "source $HOME/.jfrog/jfrog_$${SHELLNAME}_completion" ~/.$${SHELLNAME}rc; then + echo "source $HOME/.jfrog/jfrog_$${SHELLNAME}_completion" >> ~/.$${SHELLNAME}rc fi fi \ No newline at end of file diff --git a/jfrog-token/run.sh b/jfrog-token/run.sh index ba11550..40658d0 100644 --- a/jfrog-token/run.sh +++ b/jfrog-token/run.sh @@ -101,11 +101,8 @@ fi # Configure the JFrog CLI completion echo "📦 Configuring JFrog CLI completion..." jf completion $SHELL --install -# Append the completion script to the shell profile if its bash or zsh if it isn't already there. -if [ "$SHELL" = "/bin/bash" ] || [ "$SHELL" = "/bin/zsh" ]; then - if ! grep -q "source $HOME/.jfrog/jfrog_$${SHELL}_completion" ~/.$${SHELL}rc; then - echo "📦 Adding JFrog CLI completion to shell profile..." - echo "source $HOME/.jfrog/jfrog_$${SHELL}_completion" >> ~/.$${SHELL}rc +if [ "$SHELLNAME" == "bash" ] || [ "$SHELLNAME" == "zsh" ]; then + if ! grep -q "source $HOME/.jfrog/jfrog_$${SHELLNAME}_completion" ~/.$${SHELLNAME}rc; then + echo "source $HOME/.jfrog/jfrog_$${SHELLNAME}_completion" >> ~/.$${SHELLNAME}rc fi fi -