Created
April 8, 2017 20:16
-
-
Save wadewegner/2c9339618983c9b40cc58b03d700e2b9 to your computer and use it in GitHub Desktop.
Want to display a hint showing your default Salesforce DX org configuration in your bash prompt? You'll learn how in this post!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bldwht='\e[1;37m' # White | |
bldgrn='\e[1;32m' # Green | |
txtylw='\e[0;33m' # Yellow | |
get_usernames() { | |
config="$(cat .sfdx/sfdx-config.json 2> /dev/null)"; | |
globalConfig="$(cat ~/.sfdx/sfdx-config.json)"; | |
defaultusername="$(echo ${config} | jq -r .defaultusername)" | |
defaultdevhubusername="$(echo ${config} | jq -r .defaultdevhubusername)" | |
globaldefaultusername="$(echo ${globalConfig} | jq -r .defaultusername)" | |
globaldefaultdevhubusername="$(echo ${globalConfig} | jq -r .defaultdevhubusername)" | |
echoString="$bldwht""hub: $bldgrn"; | |
if [ ! $defaultdevhubusername = "null" ] | |
then | |
echoString=$echoString$defaultdevhubusername"$txtylw (local)" | |
else | |
echoString=$echoString$globaldefaultdevhubusername"$txtylw (global)" | |
fi | |
echo "\n"$echoString | |
echoString="$bldwht""default: $bldgrn" | |
if [ ! $defaultusername = "null" ] | |
then | |
echoString=$echoString$defaultusername"$txtylw (local)" | |
else | |
echoString=$echoString$globaldefaultusername"$txtylw (global)" | |
fi | |
echo $echoString"\n" | |
} | |
print_before_the_prompt () { | |
printf "$(get_usernames)" | |
} | |
PROMPT_COMMAND=print_before_the_prompt | |
PS1='-> ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment