Skip to content

Instantly share code, notes, and snippets.

@jstvz
Created April 13, 2017 17:01
Show Gist options
  • Select an option

  • Save jstvz/3d2725eb565aac09bcd1a9aa02482805 to your computer and use it in GitHub Desktop.

Select an option

Save jstvz/3d2725eb565aac09bcd1a9aa02482805 to your computer and use it in GitHub Desktop.
Powerlevel9k SFDX default username Prompt
# the correct way, but slow
#sfdx_prompt(){
# local sfdx_default="$(sfdx force:config:list | grep defaultusername | awk '{print $2}')"
# if [[ -n "$sfdx_default" ]]; then
# echo -n " $sfdx_default"
# fi
#}
# the fast way, but incorrect
sfdx_prompt(){
local config="$(cat .sfdx/sfdx-config.json 2> /dev/null)";
local sfdx_default="$(echo ${config} | jq -r .defaultusername)"
if [[ -n "$sfdx_default" && "$sfdx_default" != "null" ]]; then
echo -n " $sfdx_default"
fi
}
POWERLEVEL9K_CUSTOM_SFDX_DEFAULT="sfdx_prompt"
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(virtualenv pyenv custom_sfdx_default time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment