Bash PS1 Colors and More Space

Below is a script I use for adding some jazz and meta information to my prompt in bash. Although I do use oh-my-zsh now-a-days, a nice Bash prompt is still useful when I am on a server without zshell.

I'm not sure if this is best way to achieve this, but I use `echo` in order to add the color variables in the PS1 string, which should be evaluated only per PS1, not at the time of definition. I originally was using double quotes to surround the entire thing, but then realized that `git_ps1` was getting executed only when PS1 was being defined, instead of when PS1 was being evaluated.

On most systems, you can save this script at /etc/profile.d/ and it will be automatically evaluated. If you do set your PS1 using oh-my-zsh, then whatever value was set here will be overridden.


Jaime said…
You should screenshot your terminal with that PS1 see what it looks like.
Anonymous said…
Thanks! This is just what I was looking for. Coloring a bash terminal from a function is very unintuitive. Your code is great!

Recent posts