Skip to content

Instantly share code, notes, and snippets.

@wadewegner
Last active February 11, 2020 00:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wadewegner/9709ffa87b71c5821174e02fda8e8f82 to your computer and use it in GitHub Desktop.
Save wadewegner/9709ffa87b71c5821174e02fda8e8f82 to your computer and use it in GitHub Desktop.
My ZSH theme that includes some stuff for SFDX
# wadewegner.zsh-theme
prompt_fn() {
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)"
username=$globaldefaultusername
if [ ! $defaultusername = "null" ]
then
username=$defaultusername
fi
devhub=$globaldefaultdevhubusername
if [ ! $defaultdevhubusername = "null" ]
then
devhub=$defaultdevhubusername
fi
prompt="%{$fg[blue]%}d:%{$reset_color%} $devhub, %{$fg[blue]%}u:%{$reset_color%} $username"
echo $prompt
}
PROMPT='%{$fg_bold[green]%}%~%{$reset_color%} %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}% %{$reset_color%}%{$fg[red]%}❯%{$reset_color%} '
ZSH_THEME_GIT_PROMPT_PREFIX="±(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}) "
RPROMPT='$(prompt_fn)'
@patmcclellan
Copy link

Question... instead of displaying defaultdevhumusername, could it be the alias? What would I have to change in lines 9 and 11?

@patmcclellan
Copy link

Nevermind, I see that you're reading it from the sfdx-config.json, so that property doesn't exist in that file.

Cool functionality, nevertheless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment