aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-10-10 00:31:33 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-10-10 00:31:33 +0300
commit9a01aeb673f69dc64cdfdaf3b7fe39971a07831b (patch)
tree25804af43683d461451d8b40b5c6160a96c39d14
parent6724f3ae5d6138f007942c69faf45042d33ea7fe (diff)
use jq in azure if available
-rwxr-xr-xinternal/p10k.zsh11
1 files changed, 8 insertions, 3 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 3c08ab87..64919f64 100755
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -3094,9 +3094,14 @@ prompt_java_version() {
prompt_azure() {
(( $+commands[az] )) || return
- if ! _p9k_cache_stat_get $0 ${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json; then
+ local cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json
+ if ! _p9k_cache_stat_get $0 $cfg; then
local name
- name="$(az account show --query name --output tsv 2>/dev/null)" || name=
+ if (( $+commands[jq] )) && name="$(jq -r '[.subscriptions[]|select(.isDefault==true)|.name][]|strings' $cfg 2>/dev/null)"; then
+ name=${name%%$'\n'*}
+ elif ! name="$(az account show --query name --output tsv 2>/dev/null)"; then
+ name=
+ fi
_p9k_cache_stat_set "$name"
fi
[[ -n $_p9k_cache_val[1] ]] || return
@@ -4449,7 +4454,7 @@ _p9k_must_init() {
'${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}'
'${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}'
'${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}'
- '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v5')
+ '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v6')
IFS=$'\2' param_sig="${(e)param_sig}"
[[ $param_sig == $_p9k_param_sig ]] && return 1
[[ -n $_p9k_param_sig ]] && _p9k_deinit