Bash shell customization through .bashrc involves configuring interactive options like CD spell (auto-corrects directory misspellings), auto CD (changes directories without explicit command), and aliases (shortcuts for frequently used commands), along with feature detection to ensure commands work across different systems, and using prompt_command to customize the terminal title bar.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Bash Scripting Course - Customizing Bash with your .bashrc (pt57)Added:
Cool. So, now that you know how to customize your prompt if you wanted to, let's go back up and let's talk about some of the stuff we have in our bashrc because I did kind of gloss over some stuff. I talked about the basic stuff, but let's go down here to my shell options. CD spell, check win size, and extglob. We've already talked about extglob. extglob is super useful for extended globbing. I haven't talked about CD spell, and I haven't talked about auto CD. I'm going to talk about these. Notice that these are wrapped in a way where they hide the error messages if they fail. That's because on older versions of Bash, these aren't supported, but I still really like them.
So, we have CD spell, we have dir spell, and we have auto CD. When you combine a bunch of this stuff, it's really nice.
So, CD spell is, let's say I misspell a directory, e m t p y. That's not how you spell empty. And it still works. It prints the fixed version of it, and it CDs me in there, which is super nice.
This only works interactively. You wouldn't ever want this in a script, so please don't put this in scripts.
Um but yeah, this only works when you're interactive, but this is super nice when I just like misspell something when I'm like how I CD into foo. Oh, whoops, I typed it wrong. Okay. Auto CD allows me to CD into directories even if I don't give the CD command. There's some ambiguity around this, but it does kind of work out pretty nice. Say I'm like trying to go somewhere. I'm like, "What is this? Files? Uh I think there's something in there. Let me just hit that." It runs CD and brings me there.
Now, that's super nice, but don't think you can combine the two. If you have a misspelling, if I spell done like this and I don't actually put CD in front of it, it doesn't know what to do. So, it'll correct your spelling with CD, or it will auto CD if you spelled it correctly. Don't assume the two can ever really mix. So, those are those options.
I really like those options. I think they're super nice. Um dot dot is another example. I abuse dot dot if you've seen me in this. I love using the dot dot command just to go up one directory. So, now I don't even know where I am. Huh. There we go. Now we're back in foo. So, yeah, I I abuse I love dot dot. I think it's super great. But again, this is interactive only. This is when I'm on the shell that I want this in a script. I don't want things to be doing typo detection. That is Oh my god, I can't even imagine the issues that would crop up because of that. So, yeah, don't want that there. Let's talk about some of my aliases cuz I use a lot. As you can see, I alias dot dot to be that way. Now, auto CD should handle this, but I have used Bash on versions that don't have auto CD. So, I just put this here. So, even if auto CD fails, I have my own alias of dot dot doing it for me.
So, I like it. Um I used to use the silver searcher. Now I use ripgrep, and I'm sorry, but it's easier for me to type ag than it is to type rg just because of the Dvorak keyboard layout that I type in. So, I alias one command over another command.
I feel really bad about that, but you know, hey, it is what it is. chomd because I misspell chmod a lot. I have one called external IP. This curls my own website. I'm not going to run this because I don't want to give out my external IP, but you can run this on your own machine, and it will give you your external IP. Don't trust my server to be up 100% of the time. I just use it for my own little way of finding out what my IP address is. Super nice. You don't need the HTTPS if you don't want it. I prefer it. I alias grp to grep because I make spelling mistakes.
hl is really cool. This uses ripgrep.
This is a Rust tool you can install, rg.
It uses the pass-through flag. I want to show you why I like this because it's that awesome. Let's go ahead and look at our done file, and let's look at What do we have in file.txt? We have foo, bar, and baz. Let's go ahead and highlight bar.
Look how nice it is. It shows you the same file, but it highlights exactly what you're looking for. Let's go ahead and highlight b. There's every b in the file. Let's go ahead and highlight a and b.
There we go. There's every a and b in the file. Highlight is stupidly useful.
I love it. Thank you, ripgrep. Ripgrep is a super great program. Oh, man.
Uh alias ls. ll is a long listing of ls.
So, I do sometimes ll if I want to do this. It's the same as ls lha. l for long, h for human readable, a for all files.
Let's go back into it. And suad for sudo because again, I really like to make typos.
Here's where things get a little bit gnarly, but I want to at least equip you guys to be able to deal with some of this stuff. Let's take a look at what's happening here. There's two separate commands. grep --color=auto read in from dev/null and write to dev/null. Now, this ampersand greater than dev/null means both standard error and standard out go to dev/null.
And if that's successful, then we set an alias. So, what is that actually doing?
Here's what I'm doing. I'm reading in from nothing. I'm writing to nothing.
So, that should be successful. This is a way of checking to see does grep support the --color=auto, or am I on a machine with GNU grep? So, I literally do feature detection to see if this flag is available. And if that flag is available, then I alias my grep to use that flag. This is super useful.
Sometimes I'm on a machine where grep doesn't support that flag, so I don't want to have an alias to grep that's broken. I only alias grep if that flag is supported. That's what that line does here.
xdg-open is like a Linux command open files directly from the terminal. I check --version. I check if I'm able to run xdg-open with the --version flag. If that works, if that's successful, then I alias open to xdg-open. Otherwise, I'm on my Mac, which has an open command.
So, this way I only ever have to run the open command, and it kind of works on most systems that I'm on, which is super nice.
ls is another weird one. ls has the GNU variant, but then I've been using a like a version of like Solaris or Illumos ls, so things can be a little bit wild here.
If we do a little check, if the color=auto flag is supported, we just ls dev/null, so that'll be pretty fast. If the color=auto is supported, then we set the alias to this. Otherwise, we set the alias to that. The difference is the -g flag I just assume is going to give me color output. Otherwise, I do the --color=auto.
p is nice because if I wanted to, here I'll show you something. If I run ls, it's technically running this for me. If I wanted to run ls without those flags, I could run command ls, and now it runs ls without using my alias. There's another trick I've seen people do where they do \ls. That's another way to do it. You just backslash the command, and that will avoid the aliases for you, which is kind of nice. But as you can see, this is what ls would look like normally. Let's go ahead and add the color=auto flag. Now we have color. And then uh oh, let's put the backslash here. There we go. And then do you see what's missing? Let me give -p. Now directories have a slash at the end of them, so I can easily identify that they are directories. That's what that does.
That's what those are.
So, we've been this. We have our make prompt. We've already talked about this.
We have prompt command. I haven't talked about this, but this is really cool.
This is built into Bash prompt command, and this is code that will run every time a new prompt is generated. So, basically, every time I hit enter, that code is running. Now, what that code actually does is it runs this function prompt command, and this function gets my username. It gets the host name. It trims off anything to the right of the host name, so it's a very small host name. We get the present working directory, and we swap out if it looks like my home directory with the literal tilde character because it's easier to see. And then we check if there was an SSH client, meaning are we SSH'd somewhere? Then we append this string to it, and then we run this. It's a pretty gnarly printf command, but look at this. We've already seen this. This is the escape sequence. Why I chose to use 033, I don't really know. Um I could have just put the escape uh character there. But we run this gnarly thing, which prints the SSH string if it was set, the user, the host, and the PWD, but then it puts it where? We have this weird like escape sequence of zero semicolon, and then we close it with a seven. So, what's going on here? I will show you. Look up here. Follow my mouse all the way at the top. You see that terminal? Dave@studio, and then it has my directory up there. That's how I set that. That is what's going on here. That is how to set the actual title bar of your terminal.
So, I could do something like copy and paste all that stuff here. Let's get rid of all the percent s's here, and let's just say hello world. And we run that, and it doesn't work because the prompt command immediately overrode it. So, if we unset prompt now it won't change it. If we run this, look at the top of my terminal. Hello world. So, if I wanted to, I could like put an animation up there or something crazy. Maybe I'll do it in the future video. Be a lot of fun. That's what that's doing. Let's go ahead and re-exec Bash, so now it will update that title bar for us. But that's what the prompt command is doing. It is updating my title bar. So, if you ever wondered how title bars are updated, that's how.
I won't go into all this. This is a little wrapper function that I really like. I didn't get to use it at all during this course, but when you diff two files, which is to see the difference between two files, actually, let me let me let me show you a quick example of that. If I go into the done directory, remember how we had simple.csv and complex? I can do a diff of simple to complex, and it will show me the differences between them. That's well and good, but I like my little wrapper that runs colordiff, and then shows it like this. Um I wrote this maybe like 15 years ago, so I mean, there's probably better tools that do it now, but I find it a lot easier to read it with color in a red and green. It makes it so much easier to see.
Um probably won't go through the rest of these cuz there's a couple other functions you guys can feel free to look at. There's that color function, which we actually ended up writing ourselves.
There's a nice little copy wrapper, so I can paste things to copy, and it puts it in my clipboard with whatever tool is available to put it in my clipboard. And then we have uh oh, we have this one.
This one's really fun, the true color rainbow. Remember that 24-bit color thing I was talking about? We could technically run this, and you can see what a 24-bit color rainbow looks like on that. So again, I would encourage you all to check out this code, go take a look at it, and kind of look through it yourself, and mess around with it. Have fun. Make your own bashrc, make your own dot file repos on GitHub, and go ahead and start customizing your environment.
It's a ton of fun.
Related Videos
VALORANT's Latest 'Exclusive' Tier Bundle is Rough...
KangaValorant
17K views•2026-05-28
Flight Attendant Mocks Poor Looking Black Woman — Mid Air Announcement Exposes Her Real Power
SkyboundStories-b4r
184 views•2026-05-28
I FIXED My Friend’s Blown Turbo RX-8… Then Sold It
Cameron-RX8
134 views•2026-05-28
NewsWatch 12 at 5: Top Stories
NewsWatch12
1K views•2026-05-28
Simon Jordan & Danny Murphy deliver PREDICTIONS for Arsenal's Champions League FINAL with PSG
talkSPORTArsenal
6K views•2026-05-28
Botting is OUT OF CONTROL in Classic WoW (Again)...
SolheimGaming
108 views•2026-05-28
The "AI Job Apocalypse" is CANCELLED!
WesRoth
9K views•2026-05-28
STREET FIGHTER 6 - INGRID Story Walkthrough @ 4K 60ᶠᵖˢ ✔
RajmanGamingHD
12K views•2026-05-28











