From c78d2ce886c5a0f184041f0e453293670f0be889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Dr=C3=B6=C3=9Fler?= Date: Thu, 13 Feb 2020 14:19:01 +0100 Subject: [PATCH 1/2] support for azure current subscription (async) --- segments/azure/README.md | 27 ++++ segments/azure/azure.p9k | 53 +++++++ segments/azure/segment.png | Bin 0 -> 3550 bytes segments/azure/segment.svg | 282 +++++++++++++++++++++++++++++++++++++ 4 files changed, 362 insertions(+) create mode 100644 segments/azure/README.md create mode 100644 segments/azure/azure.p9k create mode 100644 segments/azure/segment.png create mode 100644 segments/azure/segment.svg diff --git a/segments/azure/README.md b/segments/azure/README.md new file mode 100644 index 000000000..a6d709eef --- /dev/null +++ b/segments/azure/README.md @@ -0,0 +1,27 @@ +# Azure + +![](segment.png) + +## Installation + +To use this segment, you need to activate it by adding `azure` to your +`P9K_LEFT_PROMPT_ELEMENTS` or `P9K_RIGHT_PROMPT_ELEMENTS` array, depending +where you want to show this segment. + +## Configuration + +This segment shows the current active Microsoft Azure subscription using the `az`command provided by [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) + + +### Color Customization + +You can change the foreground and background color of this segment by setting +``` +P9K_AZURE_FOREGROUND='red' +P9K_AZURE_BACKGROUND='blue' +``` + +### Customize Icon + +The main Icon can be changed by setting `P9K_AZURE_ICON="my_icon"`. To change the +icon color only, set `P9K_AZURE_ICON_COLOR="red"`. diff --git a/segments/azure/azure.p9k b/segments/azure/azure.p9k new file mode 100644 index 000000000..9a4d252db --- /dev/null +++ b/segments/azure/azure.p9k @@ -0,0 +1,53 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# @title powerlevel9k Segment - Python Environment +# @source [powerlevel9k](https://github.com/bhilburn/powerlevel9k) +## + +(){ + # Set the right locale to protect special characters + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + ################################################################ + # Register segment + # Parameters: + # segment_name context background foreground Generic Flat/Awesome-Patched Awesome-FontConfig Awesome-Mapped-FontConfig NerdFont + #   ☁ ﴃ + p9k::register_segment "AZURE" "" "69" "231" '' $'\uE60F' $'\uE60F' $'\U2601' $'\uFD03 ' + + ################################################################ +} + +################################################################ +# @description +# Display the current active Microsoft Azure subscription +## +# @args +# $1 string Alignment - left | right +# $2 integer Segment index +# $3 boolean Whether the segment should be joined +## +prompt_azure() { + if [ $commands[az] ]; then + init_az_fetch_script + nohup ~/.az_fetch_sub.sh > /dev/null 2>&1 & + + local subscription_name="" + if [[ -f ~/.az_current_sub ]]; then + subscription_name="$(cat ~/.az_current_sub)" + fi + + if [[ -n "$subscription_name" ]]; then + p9k::prepare_segment "$0" "" $1 "$2" $3 "${subscription_name}" + fi + fi +} + +init_az_fetch_script() { + if [[ ! -f ~/.az_fetch_sub.sh ]]; then + cat < ~/.az_fetch_sub.sh +#!/bin/bash +echo "\$(az account show --query name -o tsv)" > ~/.az_current_sub +EOF + chmod +x ~/.az_fetch_sub.sh + fi +} diff --git a/segments/azure/segment.png b/segments/azure/segment.png new file mode 100644 index 0000000000000000000000000000000000000000..e00231b315eb192643ef04000c9685cf7d0c1449 GIT binary patch literal 3550 zcmV<44I%Q0P)Y>K~#90?VEdaRn?uxKl|P!Bq1*dFF{BG;T2wiC?bkQ5g%Bj zRzV$GqSX4@SOtnJ{tBZye(ARtdsd8R=^h`fSA0ttEC zBsZsjeDCqxXL9o(qUO8SUHjg1_SyTl_x`OvR3P#B9R^B=XQMbp>y(j4P;ySM|`b&l!kLKnVB#A0~ydrPe0Ep>DO zJUic1SzcxUN6$HFUt^3I1h-uUgZh5alzdHL=;^gseb*wZcXQob_Lt>9Ge?10KuyQf z^5sPDG#HrydBY)l0K~_&Z@f!#;JS&B*1cos>nP+6gGKkiB_q$>9Q}L2BX_|q-#B-3 zLkW;tVK*#a)A}*bXXFhR(@q?zb7~8Q z^oOar@KG`BCy^#-oprec0wARg8aXWq=HDiP*j)n8zYWj51*^7b9ZgNG zAM4_|_W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HL8K&b9bB zWincVt%?1GqRCRq6qGUY4;t$m}S{cS;Rwo<^J1}DuK&Lb-<6|J^A(a;F*7pV?0=gN+8TPbV^ zRDNfC?%$9B(U1Lpk=)vgM<`2a!x&{TV`E^;-thd?!6=LIGGplia|W78$=>^v73-3FoIE2&v*9vgkb!-CpWf2u{wC56m_Y&efL@`gJ%4lyBNQN)Y0dV~{uUC9aAtW| zv4S!?&<`#o&7KP5vteJU+!s%StXXch+G8hSn~!m8J#xvey;%PKhaW38NbIH}V;WF=Kyua#ZAi|G^O^1h(b|U!S78Qs@YAJG-z3Q_~K4m(A1<2k0ym^ zqoPWM9b*FhO$&H)s}7>1EVN!ycu3Y_be1wdHflX$f>+)R^rh|G`jxo~{B4}Ag?)#h z#;?9nS|)2be2|0!v|k?|f!8)Tg)>mCB`#J1XQQT0O5n8(&b8BLm9w8cRqmkOzoF3y zz`efx^F-LcMz8J%*EK*2#2D2K3{n#7K7tq51#0kGkLpHuT`!9|X0Xo7e$B?R!k^)m zecGcrQDgKce_k8-_CusGK(trawc4s!#&EZPH5($l)t&#C^)RroRl|RYFnN?J zqfa+e0gZ7haWX8C;C9Ki zvJlNp?Fc?cWvbG=ekVM;TKkZkAbMM3yrcwK!OH5^&6%7C330Nv4PgYdqhT2yUcSIA z3cem5V%)xhk0lL#$8>4!O?x9h)94L-zogyP5p# zd=uusfeu`=U$orbCSIURAiD6?MgtaeS`r9=n8ad!1I+9MqPoz9FASF9{^bvwwbAtb Y2kGP5eRQqUlK=n!07*qoM6N<$f{OFyi2wiq literal 0 HcmV?d00001 diff --git a/segments/azure/segment.svg b/segments/azure/segment.svg new file mode 100644 index 000000000..917602d60 --- /dev/null +++ b/segments/azure/segment.svg @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + Fonts needed:- ubuntu- ubuntu Nerd Font + + + + + + + + + + + + + + + + + + + + ﴃ MySubscription + + + + + + + + + + + + + + + + + + + + + From 97a75aa52acf076d03ac3f48f4d84f7f42284362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Dr=C3=B6=C3=9Fler?= Date: Thu, 13 Feb 2020 15:47:27 +0100 Subject: [PATCH 2/2] added azure segment to the list of cloud-segments --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3ac704cfb..beaefa9f0 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ The segments that are currently available are: * [`docker_machine`](segments/docker_machine/README.md) - The current Docker Machine. * [`kubecontext`](segments/kubecontext/README.md) - The current context of your `kubectl` configuration. * [`dropbox`](segments/dropbox/README.md) - Indicates Dropbox directory and syncing status using `dropbox-cli` +* [`azure`](segments/azure/README.md) - The current active MS Azure subscription. **Other:** * [`custom_*`](segments/custom/README.md) - Create a custom segment to display the