Skip to content

An Oh My Z Shell add-on for displaying your defaultusername in your command prompt

Notifications You must be signed in to change notification settings

Xtremefaith/sfdx-ohmyzsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Salesforce DX Org Config OhMyZSh Prompt

Using Wade Wegner's guide here, I went ahead and created a quick script to put my current scratch org in my OhMyZsh command prompt. Here is a preview of what's to come:

screenshot 2017-12-20 20 38 48

I'm using 'powerlevel9k/powerlevel9k' theme because it's awesome and easy to setup. Not to mention it comes with a convenient ability to add custom command prompt segments.

Installation

Simple clone or download the sfdx.zsh file and put it in your .oh-my-zsh/lib/ directory. Simple right?!

Note: Most likely your .zshrc already has includes your .oh-my-zsh config but if not just verify it's in there. Should look something like this:

export ZSH=/Users/nworth/.oh-my-zsh

That file should run a script to include all .zsh files in the /lib/ folder

Setup

Next we just need to setup or config to use the script within the library. In the .zshrc we need to add our new custom command prompt segment to the prompt elements. To do this we will add custom_sfdx to the POWERLEVEL9K_LEFT_PROMPT_ELEMENTS (or right if you prefer)

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon dir vcs docker_machine custom_sfdx)

Then we will define what custom_sfdx does below with the following.

# Custom Salesforce DX
POWERLEVEL9K_CUSTOM_SFDX="get_sfdx_defaultusername"
POWERLEVEL9K_CUSTOM_SFDX_BACKGROUND='red'
POWERLEVEL9K_CUSTOM_SFDX_FOREGROUND='black'

Conclusion

That's it! You should be good to go. Of course you can make adjustments, pick a different color or a different placement, see the 'powerlevel9k/powerlevel9k' documentation for directions there. Also, I know very little about JQ or custom shell scripts, so my implementation here is pretty basic but it does what I needed, so feel free to expand it till your heart's content. And if you think your changes are valuble to everyone else send me a PR and I'll merge it in.

Thanks! and Good Luck!

About

An Oh My Z Shell add-on for displaying your defaultusername in your command prompt

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages