From 2ae9aed996051f4ffd6181177ae57f754bb1f9ad Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Wed, 13 Mar 2019 21:59:15 +0100 Subject: [PATCH 1/3] feat(azure): add azure segment This segment adds your currently active Microsoft Azure subscription to your prompt --- README.md | 1 + segments/azure/README.md | 27 +++++++++++++++++++++++++++ segments/azure/azure.p9k | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 segments/azure/README.md create mode 100644 segments/azure/azure.p9k diff --git a/README.md b/README.md index 760f7a12f..716a13fbc 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ The segments that are currently available are: * **AWS Segments:** * [`aws`](segments/aws/README.md) - The current AWS profile, if active. * [`aws_eb_env`](segments/aws_eb_env/README.md) - The current Elastic Beanstalk Environment. +* [`azure`](segments/azure/README.md) - The current Azure subscription, if active. * [`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` 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..df9516939 --- /dev/null +++ b/segments/azure/azure.p9k @@ -0,0 +1,36 @@ +# 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 + local az_account="$(az account show | python -c 'import sys, json; print json.load(sys.stdin)["name"]')" + if [[ -n "$az_account" ]]; then + p9k::prepare_segment "$0" "" $1 "$2" $3 "${az_account}" + fi + fi +} From 7525121e0a79c6babf03f4315c3fdad2349d16b0 Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Wed, 13 Mar 2019 22:09:27 +0100 Subject: [PATCH 2/3] feat(azure): update azure segment, remove python dependency azure cli can already query the json path of the returned object, no need to use python to traverse the json object --- segments/azure/azure.p9k | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/segments/azure/azure.p9k b/segments/azure/azure.p9k index df9516939..b1ea2b47d 100644 --- a/segments/azure/azure.p9k +++ b/segments/azure/azure.p9k @@ -28,7 +28,7 @@ ## prompt_azure() { if [ $commands[az] ]; then - local az_account="$(az account show | python -c 'import sys, json; print json.load(sys.stdin)["name"]')" + local az_account="$(az account show --query name -o tsv)" if [[ -n "$az_account" ]]; then p9k::prepare_segment "$0" "" $1 "$2" $3 "${az_account}" fi From bb2d02d71396d93eb660c85e0f61cea03958c076 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Fri, 22 Mar 2019 13:33:48 +0100 Subject: [PATCH 3/3] Add preview of azure segment --- segments/azure/segment.png | Bin 0 -> 3550 bytes segments/azure/segment.svg | 282 +++++++++++++++++++++++++++++++++++++ 2 files changed, 282 insertions(+) create mode 100644 segments/azure/segment.png create mode 100644 segments/azure/segment.svg 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_|_W6tx74XVA*50)q3B~yYW3lkg#nz$c7MMTzUk@u30P#Ke zfv19OELzabq4>r)n0u`lX!TaOe2n6Xo2J0leNa`~y7AJI)RvxrjJ~o4kFN;r_svT+ z=b<7t-x}Kg2SB;1AN?7|r=yNws0hfVSH$Zxdt{plNo))j4r5M-;CgniUC$Q^a zV81D2p9(3%2YF6pHUmhpY4Sy}C~8 z8#WLQ91#;|^@AVJ*8TcMI9sdO>y&S;gZgS6bsk43GW)?jH|V>k0UEuspt;#nK2NWN z?SBv5lblR_Y*bWfP05Lxw~nDYEzS=Zxb3(%{j(c@xZ&Q$03 z%FXgM`}T0IT{S_AJ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hO$&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 + + + + + + + + + + + + + + + + + + + + +