👈🏼 Go back

Custom colors in your ZSH prompt

I have been using ZSH as my main shell for nearly a year & I really love it! Most of my days are between iterm2 & Sublime Text 2. So customizing both are a natural thing for me.

So I have already customized my terminal to a very good extend but lately I have been more into trying to do some shell scripts to fasten my workflow. Like pushing, Committing, minifying and/or compiling my Sass code. I wanted to output some colored messages in the terminal but I didn’t like my limited color pallet in the terminal (Red, Green, Yellow, Cyan, White, Black, etc…) I wanted different color hues & some fancy stuff.

So I searched for this if it’s possible & I found this for ZSH & iterm2, another search for “Spectrum” & I found this function Actually, it turned out that the spectrum function is already in ohmyzsh . Drop this function inside your .zshrc file then call spectrum_ls in the terminal & boom! watch the magic.

zsh-colors

Now all you need to is to reference the color code outputted like so $FG[000] in your ZSH theme, just replace “000” with the color code “000” is black btw & you are good to go! for example in create a new ZSH theme & try this PROMPT='$FG[154]%~%{$reset_color%} '.

I hope someone can find this useful, I didn’t know about it before & I’m really in love with the terminal.

© 2017