Check out a free preview of the full Complete Intro to Linux and the Command-Line course

The "Colors & Awesome Bash" Lesson is part of the full, Complete Intro to Linux and the Command-Line course featured in this preview video. Here's what you'd learn in this lesson:

Brian continues to demonstrate how to customize the prompt by adding new colors and recommends the use of Awesome Bash to take the prompt customization a step further.


Transcript from the "Colors & Awesome Bash" Lesson

>> The next thing I wanted to tell you is, /bin/echo. Okay. So, a peculiarity of echo and particularly with Bash, if I say echo -e hi. It is doing it correctly, nevermind. But if I do echo help, is that working? Yeah, so it actually echoes out help, right, which is not what you expect, you actually want it to be the flag.

But it is smart enough to respect the -e, which is kind of interesting. So, you can have echo echo out colors so if I say echo -e, this is how you make colour and then the way you do green is \e[32mgreen]. Like that. There you go. So this little bit right here, it's some escaped character that Bash understands, this represents that everything after this is gonna end up being green, and there's a bunch of colors.

And you might ask, why would I use this directly? And typically you don't, but I wanted to let you know that you can set colors for things that you're echoing out like when you're writing Bash scripts. Color makes it very easy to parse things out. So you can say, if this is green, it means it passed, if it's red, it means it failed.

And the way that it's doing is these escape things. And if I don't do this -e, it's actually going to literally output this string which is not what you want, the -e means go through, and make sure that you're finding the color characters. Now, I typically don't do this very much myself.

I'll use other libraries, there's Bash things that you can include that will help you do colors or, in general, when I'm getting that in depth in something, I'll write it note I'll use something like chalk to help with that. But that's how you do it. And then one of the last things I'll just share with you really quick is there's a thing called Awesome Bash.

It's on GitHub. So Awesome Bash, that's a tongue twister for me. And this is just a huge long list of very cool stuff that you can do with Bash everything from how to do aliases which we didn't talk a lot about. Bash git prompt that was one of them that I was just talking about.

Bash powerline, that's the one that I did just show you how to do. There's a bunch of really cool stuff in here. That's where I found the 2048 game. So if you want to dig in and find some other really cool stuff you can do with Bash, definitely a good place to come check it out.

Definitely more materials for you to learn. All right. Any questions about customizing your shells or colors or anything else? I talked about changing your caps lock earlier in the course but I left another note here if you want to learn how to change your caps lock key to be control or escape.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now