 When it comes to scripting or programming, you really have to start thinking about how the user is going to interact with the program that you write. And there's really three main interfaces as far as programs. You have CLI or command line interface. So these are simple command line programs where you enter something at the command line and you get output given to you at the command line. So those are like your standard GNU Core Utils. Almost all of those are command line interface programs. All you do is interact at the command line. There's no real user experience to talk of, right? And then the next step is the terminal user interface, or sometimes people refer to it as the text user interface. And this would be what we often just call TUI programs. TUI programs are, they're kind of like graphical programs, but they really, they have to run inside a terminal emulator. They're designed to run inside a terminal. They use a library called incurses, typically. And examples of these incurses programs would be something like Htop or Vim. These are TUI programs. They have to run inside a terminal emulator. They can't be run outside of a terminal. And then, of course, we have our traditional GUI applications or graphical user interface applications. And these are your traditional graphical windows with menus and buttons and widgets. And these are typically written using the GTK toolkit or the Qt toolkit, at least on Linux. And like most people, I started with some basic scripting. Most of my basic scripting was strictly CLI programs. And then I wanted to get more into graphical programs. So you guys know here lately I've been experimenting a little bit with writing my own GTK applications. But then I skipped over that middle ground. What about TUI interfaces? What about creating something using incurses? Well, incurses, I may eventually explore it, but it's written in C. I really don't know the C programming language. It would have a little bit of a learning curve that, again, I may explore it at some point. But there is an easier option to get into, kind of like a beginner incurses kind of option. It's not really incurses at all. This is called bash simple curses. I found this on GitHub a few days ago and I've been playing around a little bit with it. And all it is is some simple bash functions that it will draw windows like boxed windows inside a terminal and display your information inside like these display boxes. And it kind of makes it almost like a incurses program. Even though technically it's not an incurses program, this is running strictly bash. Bash simple curses is written under a free license. It is licensed under the BSD3 license. There is documentation, pretty easy documentation. You have a basic tutorial here. There's not a whole lot you can do with bash simple curses. It's not very deep. Anybody could use this thing, which is one of the reasons why I'm making today's video. I think a lot of people would find this useful. And then of course they have several example shell scripts that they've written using the bash simple curses functionality. So what I've done is I have cloned this repository from GitHub. And let me open a terminal and I'm going to zoom in just a little bit here. I'm not going to zoom in too much here because when I run these programs because they're boxed programs, if I zoom in it's going to distort them a little bit. So I don't want to zoom way in like I normally do on these videos. But I'm going to CD into that examples directory where we have all of the example scripts. Plus there's three or four of my own example scripts where I played a little bit with bash simple curses. And you want to make sure that all of these scripts are executable so you can play with them. Now I've already made these executable but if they weren't executable when you cloned the repository, then you need to make them executable. You need to use the chmod command. So change mod space plus x, x stands for executable is adding basically the x here. Those three x's means that the owner, the owner and the group and that anyone else all have execute permissions for this so anybody can run this script. And then of course you need to give it the path to the script that you want to make executable. In this case I'm going to make the bash bar script executable. It was already executable. I really didn't need to do that. But anyway then to run a script you need to do dot slash name of script. And this is the bash bar example script. I'm getting a little bit of the error down here. It says dmessage yada yada yada operation not permitted. There's a part of the script probably that that command probably needs sudo permissions. I'm not running this as sudo. So that's why that error is happening. It's probably trying to print something down here as part of the network interfaces. And you see the error message flashes every second. It looks like they've got this script timed to rerun every second or two. But it's a very basic script. It's just pulling out some very basic information. For example, the host name of this machine I believe is Arco Linux or they may have actually gotten the Linux distribution name from the lsb underscore release command part of the GNU Core Utils. And they're just running the date command, right? And they're getting our uptime, our users. They're getting memory, total memory, free memory. Then they're getting some of the top running processes on my system right now. What's taking up the most memory and CPU. And it's going to print some kernel messages. There's nothing to print. And then of course our network interface. This is my ethernet right here, E-N-P-S-0. Of course, it would be very easy to write a simple bash script that displays all of this information. But to display it all in a really neat boxed sort of way where you have boxes and line separators. And you notice that the heading of the boxes, you can specify colors. That's really, really neat. Let me show you the actual, the script itself. If I actually open this with vim. So let's open the bash bar script and actually see what's going on. And then let me zoom in a little bit now so you guys can read some of the script. So to use bash simple curses, the first thing you want to do is you want to import this shell script here, right? You're going to have to source this simple curses shell script, which contains some of the functions that you're going to use for bash simple curses. I'll actually go back to the GitHub here. I go down into the documentation. I believe it mentions, yeah. Typically, what you want to do is you want to do source and then the location of this file. And you could place this file anywhere here in this example. They place it in user local lib, which is typically where libraries are placed on a GNU slash Linux system. But you could place it anywhere, but you just need to source the location to that shell script. In my case here, since it's already in this clone to get repository, I'm just doing a period, dear name, dollar sign, zero, yada, yada, yada. Basically find this file here in this project that I'm currently working in. But if this was something that I wanted to package up and actually make it an installable program, I probably would place this in something like user local lib. And then actually writing your script is very easy. All you need to do is make sure you have a main function. Inside the main function, you're going to use these other functions that were created from the simple cursive shell script. So you have window. Window takes a couple of arguments. It takes the text, basically the header of the window. In this case, they were doing hostname. Remember ArcoLinux in the bash bar script? The very top was ArcoLinux. That is the hostname of my computer. And then red is the color of that. Let me open a new terminal and actually just rerun the bash bar script while we're looking at the text. So ArcoLinux and the color is red. So back to the script, we have window, hostname, red, and window means draw a box. And then at the top, have the hostname in red. And then the window function also adds a line, a little separator up under the header, you know, the title, the hostname. So that is how we've got the box, the header, and this first line. But then we have this next line here. This is actually a separator. And all you need to do is use this command here, add sep, and that just adds a line. And then other than that, you just add your information. Append this particular function. It just prints out some text or the output of a command. For example, inside the double quotes is where you would put text. But if inside the double quotes, you do the back text and then run the date command, right? You actually just print out the date or append here and append. You could keep appending things and they will appear centered inside the box one line after another. But sometimes you don't want that. Sometimes you want to run this command here, append underscore tabbed. And this is how you get tabbed information like upsense and then eight days. Users, one, load average, and then the load average, right? There are two columns instead of having everything kind of centered in the middle of the screen. Now you can actually have columns. And down here we have three different columns. And that is done with append tabbed. Now by default, append tabbed uses a colon to separate your columns of information. So you do append tab and then inside double quotes the text that you want to appear. But in this case again, you can also use shell commands. They output from standard GNU core utils like uptime, cut, said, et cetera. So first of all, it's going to print out this text users and then colon. Colon is the field separator. It is actually what breaks the columns. So if I go back to this script running, you have users and then colon, colon does not get printed. That is just letting us know that's a break. And then the rest of the information goes in the second column. How does it know there's only two columns of information? That's the next part that you give. You give two as the number of columns for this append tabbed command. You could also give it one other argument. If you didn't want to use colon as a separator, then you could give it one last argument to let it know. Use this other item as a field separator. For example, you notice append tabbed appear actually uses a pipe symbol as the column separator. Because now you have a pen tab and then the text that should appear. And then you have two for there's two columns and then tacked on here at the end. You have a new field separator instead of using the colon. They're using the pipe symbol for some reason in this command. And then you have this end when. So this is the end of the window. That's signifying that that's the end of this window block here. This very first one. And then you create a new window for memory usage. And you see window memory usage. Red again is the color. And then you do some information and then end wind. And then another window yada yada yada. And you end up with, you know, these four or five different windows or boxes here displayed. Displaying the various information with the formatting, the right number of columns, the right colors. And it's just, it's a really neat way to do this. Now for those of you not familiar with bash scripting, you have this main function here. But just because you define this main function doesn't actually make it run after you define your main function with all the windows yada yada yada at the very end. You actually want to run the main loop. You do main underscore loop. And then you need to give it a time. How often does it need to run? And it looks like this bash bar script is running every half second. So that is why you're seeing this blinking message here pretty regularly. It's because the script is actually constantly updating itself. Of course, depending on the nature of the script and the kind of information you're displaying, you may not need it to update so frequently. Of course, the more frequent that the shell script has to run itself. Of course, the more taxing that could be on the system, especially if you're crunching really big numbers or doing some heavy operations. So this was the bash bar example script. They have several other example scripts here. For example, here is bash bar two. Let's see if this differs. Now they're just doing the boxes in a little different order. Instead of having five boxes stacked one on top of each other, they're doing columns here with the boxes. If you want to see some of the code for it, let's quit out of this and open bash bar two shell script here. And you see how they're accomplishing this is now there's one other argument that the window command can take window takes the text. It's going to display host name again, the color red again, but this time they added this argument 50%, meaning only take up 50% of course of the width of the terminal. The reason is because the next window is going to take up the other 50%. So that is how they're getting these 50% kinds of windows here. Let me quit out of that and then do an LS, some of the other really interesting ones. They have one here called view meter. So this would be like a volume meter. So you can do kind of like these volume bars as well. There's an example of that. And I did one, actually I did a few here, but I played around a little bit here is one I did. Just as an example of some system information that I think I would find useful. This is DTOS system information. And I talk about the packages that are installed on my system. The packages installed from Pac-Man, Flatpak, Snap, updates that are available for me, my uptime, yada, yada, yada. Software versions, of course the most important software is the Linux kernel, but then I also printed out the various current versions of other important pieces of software for DTOS, yada, yada, yada. This is really, I could play with this all day. This is pretty neat. So let me show you some other ones as well. There was one here called WinTest that I believe was part of the example scripts of theirs. It looks like it's a little broken. It's trying to run some kind of command that just doesn't quite work right, but you can see they had a calendar, they had a tree file view. It looks like they've got some text boxes here. You could even make it almost like a note-taking application where it displays like a latest notes that's, you know, written to a certain note file that you always write to. So this is just a little introduction to Bash Simple Curses. This really neat program that I found. And I'm just really impressed with it because even for such a simple thing, it solves a real-world problem because a lot of people, they don't like command-line interface programs. They want something with a much more UI kind of experience, right? Something that you can actually draw boxes and place things exactly where you want on the screen. More kind of a GUI style program. And to do that in a terminal, it's complicated if you have to start getting into end-curses and learning the C programming language and stuff like that where with Bash Simple Curses, anybody can be up and running with this within a couple of minutes. And I think it's fantastic. Now, before I go, I need to thank a few special people. I need to thank the producers of this episode, Dustin Gabe James, Matt Maxim, Michael Mitchell, Paul West, Juan Yabal, and homie Alan Armadragon, Chuck Menderangri, Dio Kai, Dylan Marstrom, Erion, Alexander Peace, Archon Fedora, Polytech, Realities 4 Less, Red Private Steven, Tools Devler, and Willie These Guys. They're my highest tier patrons over on Patreon. Without these guys, this episode about Bash Simple Curses would not have been possible. The show is also brought to you by each and every one of these fine ladies and gentlemen. All these names you're seeing on the screen right now. These are all my supporters over on Patreon because I don't have any corporate sponsors. I'm sponsored by you guys, the community. If you like my work and want to see more videos about Linux, free and open source software, Bash Scripting, subscribe to DistroTube over on Patreon. All right, guys. Peace. And if you create something with Bash Simple Curses, share it in the comments below.