From 1ea7e94af8876dcfdada447f3964b5802b8c8d4d Mon Sep 17 00:00:00 2001 From: Vladimir Kolchurin <18503099+kolchurinvv@users.noreply.github.com> Date: Tue, 9 Aug 2022 02:03:07 +0300 Subject: [PATCH 1/9] tracks firebase project target if inside a firebase project folder --- sections/firebase.zsh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 sections/firebase.zsh diff --git a/sections/firebase.zsh b/sections/firebase.zsh new file mode 100644 index 000000000..1b536d41f --- /dev/null +++ b/sections/firebase.zsh @@ -0,0 +1,36 @@ +# ------------------------------------------------------------------------------ +# Configuration +# ------------------------------------------------------------------------------ +SPACESHIP_FIREBASE_SHOW="${SPACESHIP_FIREBASE_SHOW=true}" +SPACESHIP_FIREBASE_PREFIX="${SPACESHIP_FIREBASE_PREFIX="FB project: "}" +SPACESHIP_FIREBASE_SYMBOL="${SPACESHIP_FIREBASE_SYMBOL="🔥 "}" +SPACESHIP_FIREBASE_COLOR="${SPACESHIP_FIREBASE_COLOR="#d75f00"}" + +# ------------------------------------------------------------------------------ +# Section +# ------------------------------------------------------------------------------ + +# Shows active Firebase Project +spaceship_firebase() { + + # wheather to show this section + [[ $SPACESHIP_FIREBASE_SHOW == false ]] && return + + # check if firebase-tools cli is installed + spaceship::exists firebase || return + + local FBDIR=$(which firebase) + + $FBDIR target 1>/dev/null + if [[ $? -eq 0 ]]; then + local target=$($FBDIR target | awk '{gsub(/\:/, "", $4)} {print $4}') + else + return + fi + + spaceship::section \ + "$SPACESHIP_FIREBASE_COLOR" \ + "$SPACESHIP_FIREBASE_PREFIX" \ + "${SPACESHIP_FIREBASE_SYMBOL}${target}" \ + "$SPACESHIP_NODE_SUFFIX" +} From 1d383d855188d8ccd6558763231fd1474e31b182 Mon Sep 17 00:00:00 2001 From: Vladimir Kolchurin <18503099+kolchurinvv@users.noreply.github.com> Date: Tue, 9 Aug 2022 02:08:36 +0300 Subject: [PATCH 2/9] unnecessary suffix --- sections/firebase.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sections/firebase.zsh b/sections/firebase.zsh index 1b536d41f..38c59f1ec 100644 --- a/sections/firebase.zsh +++ b/sections/firebase.zsh @@ -31,6 +31,6 @@ spaceship_firebase() { spaceship::section \ "$SPACESHIP_FIREBASE_COLOR" \ "$SPACESHIP_FIREBASE_PREFIX" \ - "${SPACESHIP_FIREBASE_SYMBOL}${target}" \ - "$SPACESHIP_NODE_SUFFIX" + "${SPACESHIP_FIREBASE_SYMBOL}${target}" + } From 6bc93b2b3b054d4995587d7075d0f4d274613fe1 Mon Sep 17 00:00:00 2001 From: Vladimir Kolchurin <18503099+kolchurinvv@users.noreply.github.com> Date: Wed, 24 Aug 2022 19:45:21 +0300 Subject: [PATCH 3/9] show current firebase project utilizing jq to parse the config file created by firebse-cli --- sections/firebase.zsh | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/sections/firebase.zsh b/sections/firebase.zsh index 38c59f1ec..00c332340 100644 --- a/sections/firebase.zsh +++ b/sections/firebase.zsh @@ -19,18 +19,34 @@ spaceship_firebase() { # check if firebase-tools cli is installed spaceship::exists firebase || return - local FBDIR=$(which firebase) - - $FBDIR target 1>/dev/null - if [[ $? -eq 0 ]]; then - local target=$($FBDIR target | awk '{gsub(/\:/, "", $4)} {print $4}') - else + # firebase-cli creates this config file with all the settings + local file=~/.config/configstore/firebase-tools.json + if [ ! -f "$file" ]; then return fi - - spaceship::section \ - "$SPACESHIP_FIREBASE_COLOR" \ - "$SPACESHIP_FIREBASE_PREFIX" \ - "${SPACESHIP_FIREBASE_SYMBOL}${target}" - + local currentDir=$(pwd) + # big thanks to https://github.com/jozefcipa/zsh-firebase-prompt for the actual implementation + current_project=$( + cat $file | + jq --arg currentDir $currentDir ' + [ + .activeProjects + | to_entries[] + | .key as $key + | select($currentDir | startswith($key)) + ] | [ + sort_by(.key | length) + | reverse[] + ] | .[0].value' + ) + + if [ "$current_project" != "null" ]; then + # remove the quotations + current_project=$(echo $current_project | awk '{gsub(/[\"]/, "", $1)} {print $1}') + + spaceship::section \ + "$SPACESHIP_FIREBASE_COLOR" \ + "$SPACESHIP_FIREBASE_PREFIX" \ + "${SPACESHIP_FIREBASE_SYMBOL}${current_project}" + fi } From ad2af680d4d42635821571e8c36d64ffbbab6688 Mon Sep 17 00:00:00 2001 From: Vladimir Kolchurin <18503099+kolchurinvv@users.noreply.github.com> Date: Wed, 24 Aug 2022 20:15:37 +0300 Subject: [PATCH 4/9] trailing white space --- sections/firebase.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/firebase.zsh b/sections/firebase.zsh index 00c332340..160ce7036 100644 --- a/sections/firebase.zsh +++ b/sections/firebase.zsh @@ -42,7 +42,7 @@ spaceship_firebase() { if [ "$current_project" != "null" ]; then # remove the quotations - current_project=$(echo $current_project | awk '{gsub(/[\"]/, "", $1)} {print $1}') + current_project=$(echo $current_project | awk '{gsub(/[\"]/, "", $1)} {print $1" "}') spaceship::section \ "$SPACESHIP_FIREBASE_COLOR" \ From 3083387d3fc241f563ece73dc9020558398da947 Mon Sep 17 00:00:00 2001 From: Vladimir Kolchurin <18503099+kolchurinvv@users.noreply.github.com> Date: Fri, 23 Sep 2022 10:34:28 +0200 Subject: [PATCH 5/9] color tag usage --- sections/firebase.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/firebase.zsh b/sections/firebase.zsh index 160ce7036..b5738417b 100644 --- a/sections/firebase.zsh +++ b/sections/firebase.zsh @@ -45,7 +45,7 @@ spaceship_firebase() { current_project=$(echo $current_project | awk '{gsub(/[\"]/, "", $1)} {print $1" "}') spaceship::section \ - "$SPACESHIP_FIREBASE_COLOR" \ + --color "$SPACESHIP_FIREBASE_COLOR" \ "$SPACESHIP_FIREBASE_PREFIX" \ "${SPACESHIP_FIREBASE_SYMBOL}${current_project}" fi From a5b3009a58a7a899f629d9dc03da2913c80d5e6b Mon Sep 17 00:00:00 2001 From: Vladimir Kolchurin <18503099+kolchurinvv@users.noreply.github.com> Date: Fri, 23 Sep 2022 10:35:41 +0200 Subject: [PATCH 6/9] prefix tag usage --- sections/firebase.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/firebase.zsh b/sections/firebase.zsh index b5738417b..1ba0af8d7 100644 --- a/sections/firebase.zsh +++ b/sections/firebase.zsh @@ -46,7 +46,7 @@ spaceship_firebase() { spaceship::section \ --color "$SPACESHIP_FIREBASE_COLOR" \ - "$SPACESHIP_FIREBASE_PREFIX" \ + --prefix "$SPACESHIP_FIREBASE_PREFIX" \ "${SPACESHIP_FIREBASE_SYMBOL}${current_project}" fi } From 8f934ebc177822bab83d962f0d85124de78803f2 Mon Sep 17 00:00:00 2001 From: Vladimir Kolchurin <18503099+kolchurinvv@users.noreply.github.com> Date: Fri, 5 May 2023 16:16:50 +0200 Subject: [PATCH 7/9] a typo in iterm integration prompt --- lib/prompts.zsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/prompts.zsh b/lib/prompts.zsh index 87b52795f..39f014202 100755 --- a/lib/prompts.zsh +++ b/lib/prompts.zsh @@ -15,7 +15,7 @@ spaceship::prompt() { # Allow iTerm integration to work if [[ "${ITERM_SHELL_INTEGRATION_INSTALLED:-}" == "Yes" ]]; then - prompt="%{$(iterm2_prompt_mark)%}${prompt}%{$(iterm2_prompt_end)}" + prompt="%{$(iterm2_prompt_mark)%}${prompt}%{$(iterm2_prompt_end)$}" fi # Should it add a new line before the prompt? @@ -56,7 +56,6 @@ spaceship::ps2() { spaceship::section::render "$ps2" } - # Render the prompt. Compose variables using prompt functoins. # USAGE: # spaceship::populate From 4471d9bcc74c46e6230711ce9156e7d43305b99a Mon Sep 17 00:00:00 2001 From: Vladimir Kolchurin <18503099+kolchurinvv@users.noreply.github.com> Date: Fri, 5 May 2023 16:17:20 +0200 Subject: [PATCH 8/9] another typo (mine this time) --- lib/prompts.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/prompts.zsh b/lib/prompts.zsh index 39f014202..74ef6ee25 100755 --- a/lib/prompts.zsh +++ b/lib/prompts.zsh @@ -15,7 +15,7 @@ spaceship::prompt() { # Allow iTerm integration to work if [[ "${ITERM_SHELL_INTEGRATION_INSTALLED:-}" == "Yes" ]]; then - prompt="%{$(iterm2_prompt_mark)%}${prompt}%{$(iterm2_prompt_end)$}" + prompt="%{$(iterm2_prompt_mark)%}${prompt}%{$(iterm2_prompt_end)%}" fi # Should it add a new line before the prompt? From ad07f5dfbab5af2e42ab3fff860045aa7abf7a3f Mon Sep 17 00:00:00 2001 From: Vladimir Kolchurin <18503099+kolchurinvv@users.noreply.github.com> Date: Mon, 20 Nov 2023 21:46:32 +0100 Subject: [PATCH 9/9] tests folder --- tests/shunit2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/shunit2 b/tests/shunit2 index 3334e5304..47be8b23a 160000 --- a/tests/shunit2 +++ b/tests/shunit2 @@ -1 +1 @@ -Subproject commit 3334e53047ad143669870a9c223b70a81156533a +Subproject commit 47be8b23a46a7897e849f1841f0fb704d34d0f6e