-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlib.azure
40 lines (31 loc) · 913 Bytes
/
lib.azure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
export AZURE_PROMPT_ENABLED=0
function __azure_update_labels() {
test ${AZURE_PROMPT_ENABLED} -eq 0 && {
return 0
}
test ! -f ~/.azure/clouds.config && {
return 0
}
local l_subID=$(awk '/subscription/{print $3}' < ~/.azure/clouds.config)
local l_subName=$(jq ".subscriptions[] | select(.id == \"${l_subID}\") | .name" < ~/.azure/azureProfile.json)
local l_color="lightgray"
if [[ "${l_subName}" == *SAASOFFICE-1* ]]; then
l_subName="prd"
l_color="196"
elif [[ "${l_subName}" == *staging* ]]; then
l_subName="stg"
l_color="202"
elif [[ "${l_subName}" == *sandbox* ]]; then
l_subName="sbx"
l_color="120"
fi
promptcmd_add_labels "az⌈${l_subName}⌉|${l_color}"
}
function azure_enable_prompt() {
AZURE_PROMPT_ENABLED=1
promptcmd_push "__azure_update_labels"
}
function azure_disable_prompt() {
AZURE_PROMPT_ENABLED=0
}