 Hello and welcome to a video from filmsbychris.com. That's Chris with the K, I'm Chris. And this is a script that I wrote as an example. Let me go ahead and run that. So here's the script in the top half of the screen in Vim. And now I'm just gonna run that command. And what does it do? Well, it outputs this. It has different lines with different characters, some texts, some more characters, lines. And what this script does is it draws those horizontal lines across the screen with whatever character you give it. And it automatically adjusts. So if I was to split the screen like this and I was to run that command again over here, you'll see that when it runs again, it puts the proper number of characters to draw that line without having them go down to the next line. So let's go ahead and close that. And let's go ahead and have a look at how the script works. So I have a main function here, which is the functions written here. And then we call it down here. And the reason I do that is because I have this line function that draws those lines based on what characters you give it. And to call a function has to be stated already. So if I was to just write line down here and run line up here, it's not gonna work. And I like to have my main function near the top. So I call main down here, little side note on all that. But what are we doing? So here we give it the function line. And what that's gonna do is it's going to print square characters or rectangular characters all the way across the screen because we didn't tell it what character to use. Then we're gonna print another line using the equal character. Then we're gonna print our text. And then here I give it a plus and minus as an example. So it doesn't print a plus and minus sign. If I run the script again, you'll see it just does the first character which is the plus sign. And I'll explain that in a moment. And again, here we have line with nothing. So it's gonna use that rectangular character and then it exits out of the program. So let's look at the magic here in the line function. What it's gonna do is it's gonna look at what's past. Okay, is it is the variable past, the argument that's past, is it greater than zero? So was something past? If nothing was past, I'm just looking at it, if it's less than one. So if nothing was past, well then just use this default rectangular character right here, which disappears when I highlight it. But it's right there. So if you don't pass anything, it's going to use that. Otherwise, it's going to look at that first variable and get the first character. This is saying start at zero and go to one. Why do I do that? So an example here, if you were to give it more than one character, it's going to throw things off. Because down here, we're using the tput command to tput columns. What does that command do? Let's go ahead and run that down here. What it does is it gives you the number of columns across the screen. So the number of characters across the screen. Again, if I was to split this and run that command again, well now it's gonna give us half that number because we just split the screen in half. And if I was to increase the text size, the font size and run it again smaller now. So it's taking into account everything and telling you how many columns or characters the screen width currently is. And what I'm doing here is I'm using the printf command to say print that character from up here that many times. That's basically what this is doing. It's saying print it that many times. But it's basing it on one character. So if we were to give it two characters, it would actually end up being double the length. So that's why we're making sure here that we're only grabbing the first character. And that's how we're drawing lines across the screen. And then I use the echo command to give us a new line character. I could probably build that into the printf command. This script probably could be cleaned up. I wrote this a long, long time ago and have had it on my list of tutorials to do. But I wanna give you an example here. If I was to like type my name, Chris, right? Save that. Come down here. I'm going to run our line script again. And you can see here, it just used the first letter and just prints the Ks all across the screen. And again, if I didn't do that, then it would go down the new line because it would print that variable this number of times. But we don't want that. We just want the one character. Anyway, if you want to print lines across your screen, there's different ways to do it. In fact, I've done a similar tutorial on this before, but I thought I'd share this function. I'll link to it in the, this whole script in the description of this video. But then you can throw this function into your scripts and at any time print lines as long as you have tput installed, which is fairly common, but not always. So you have to take that into mind, take that into account. Yeah, thanks for watching. Filmsbychrist.com, that's Chris the K. There's a link in the description. Again, to the script here, but also my website where you can find a support section. You can also search through all my videos. I also have a Patreon, you know, if you wanted to support me over there, I would love it. I would appreciate it so much, even if it's just a little tiny bit. And if you can't support financially, think about liking, sharing, subscribing, commenting, all that good stuff. I thank you for watching. And as again, as always, I hope that you have a great day.