Episode: 2009 Title: HPR2009: Understanding the GNU/Screen Hardstatus line Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr2009/hpr2009.mp3 Transcribed: 2025-10-18 13:15:35 --- This is HPR episode 2009 titled, Understanding the GNU Sash Cream Hardtator Sign. It is posted by Curtis and Kins, C-Prompt, and in about 25 minutes long, the summer is. C-Prompt talks about how he configured his GNU Sash Cream to suite his needs. This episode of HPR is brought to you by AnanasThost.com. Get 15% discount on all shared hosting with the offer code HPR15, that's HPR15. Better web hosting that's honest and fair at AnanasThost.com. Hey, all right, this is C-Prompt and you'll care a lot for Hacker Public Radio. I would like to do a show today on the application GNU screen. It's something that is extremely important to every install that I ever do on Linux box. If it's going to be a Linux box that I'm going to use, I'm going to install screen, probably within the first 5-10 applications after a fresh install. What screen does or is, you can think of it as kind of a window manager for terminal applications or processes. So, once you're in a terminal, let's say you want to have VIM running and you want to have a bash shell and you want to have H top or something like that running. Instead of opening up a terminal for each individual instance, we can open up one terminal and then we just start screen and have screen run each one of these applications or processes individually for us. So, the way we do this, once we install screen that will create a configuration file in your home directory called, it's a .screen RC file, we'll need to edit this and add a section to it to tell what applications we want to start. So, after these applications start, you'll be given down at the bottom of your terminal session a listing of each one of the applications and we call the movement between each one of these applications, you can think of those as a window. So, window 0 will be VIM, window 1 will be your bash shell, window 2 will be H top, we'll just start there and move on. So, the way we do this is within the screen RC file, we need to simply add a section that simply says screen. And then tab dash t and then a tab and then whatever you want it to display at the bottom of your terminal session for the window, let's say it's a VIM, we'll just call it VIM and then a tab and then a 0 because this is our, it starts at 0 for the nomenclatures and we'll go 0, 1, 2, 3, 4, 5, whatever. So, window 0 and then a tab and then whatever the command is to start the application or process that you want in that certain window. So, in window 0 we want VIM, so our first section will say screen space dash t, space VIM, space 0, space VIM. So, the first VIM will determine what is displayed and then the second VIM is actually the command that we would want it to issue. So, just take, for instance, on my screen RC file, I have window 0's VIM, window 1 is bash, window 2 is H top. So, there's my first three windows that I have. So, every time that I open up the terminal and I type screen, those three processes start in that order. And I can access those within one terminal session. So, I don't have to have a terminal open for VIM, a terminal open for bash and a terminal open for H top. I have one terminal open and all three of this process is running within the same terminal that I can switch back and forth between very easily. Now, the main thing that I wanted to talk about is how to make it look a little bit prettier in my eyes. It's, I like terminal stuff, but I need it to look heavily decent as well. So, there are some things that you can do with it. And when I went to search on what you can't do with this section down at the bottom where the window section is, the online stuff that I found, it showed examples, but it didn't really explain what it was doing and it was a very confusing to me. So, what I did was as I went to the new page for this section and started just adding and removing stuff to see what happened within my screen. So, I kind of have a better idea of what's going on. I'll put in the show notes a copy of my line at the bottom of my screen session. It's called the hard status. I don't know why. It's just always at the bottom of the screen session. You can have it display certain things. Obviously, you want it to have the window number and the process that's in that window. But you can also do stuff like the host name and the time and date and stuff like that. You can also change colors of each one of these sections. So, that was what was really confusing to me. I didn't understand what all this stuff was meaning. But it uses, on this hard status for screen, it uses the string escapes. And that was the page for that on the new org site was a little confusing to me. So, like I said, I just started removing stuff and adding stuff and changing this and that here and there just to see what it did do it for display. And I came up with a pretty nice looking hard status line for my new screen. So, that's basically what I want to share mainly with you today. If you could, it's going to be really difficult if you can't see the hard status line to begin with. But hopefully, you can kind of follow along with what I'm saying. And I hate just reading out code and stuff like that on. But there's no other way to do it. So, if you can pop over to the show notes and see and I have a look at what my screen's hard status looks like. And I want to go through it here. So, the first thing I did for my hard status to find out what was doing what. I noticed that a lot of the attributes, whether I wanted to change the color or the style of being bold or not, that kind of thing, all of that was embraced in braces. And that's the curly braces. So, the first thing I did was I stripped out every bit of that stuff and saw what I was left with. And I started adding some stripes from that to get what I wanted. So, the first thing I wanted to do was to put the host name of the computer that I'm on to the far left. So, left justified host name and I wanted it to stick there. So, we can do that with the... So, everything that you do within, let me back up for just one second. For anything that you do within the hard status, the string escapes the attributes and whatever it is that you want displayed as the host name, the window name, the window number, the date, the time, anything has to be preceded by the percent sign. So, you'll see something like percent H, which is telling screen to display the host name. Then something like percent D, which will show the day name number or short name. It has to have that percent sign to tell it that what I'm getting ready to do next is going to determine what it's going to be shown. Alright, so, the first section is going to be the host name. So, that's the percent capital H and it will display whatever the host name is that you're currently on. In the next section, I wanted the window names to be in brackets and that's the square brackets. So, I wanted that in brackets so I could determine which window I was on at that time. So, it would run the different windows. Tell me that your own window 0, your own window 1. So, there was no confusion whether if I had two bash shells running, which one I was on at any given time. So, we put a brace and then the percent in for the window number and then a space and then a percent T, which would give the title so that would be the VAM, the bash, the H top, whatever we typed into our screen, our C file, and then an ending bracket. So, let's take a look at that right now of what some of this is doing up to this point. You'll see it at my actual hardstask line. It actually starts with the curly braces equal sign M curly braces. And like I said before, anytime that you want to determine what color to use or what style whether it's bold or regular or anything, all that has to be within curly braces. So, the equal sign starts out with the telling it that to apply this attribute from the beginning to when I tell you to stop and the attribute that I'm applying here is to change the color to magenta. So, if we look at the first section that I have, it begins with the escape character. Obviously, it's the percent sign and then a curly brace, an equal sign, a space, a lowercase M curly brace. And all that is saying is that from this point on, make all the fonts magenta. That's all that saying. And then after that, what I have is to display the host name, which is the percent H or capital H. Make sure it's a capital H to display the host name. The next section is simply a percent equal sign. Whenever the equal sign is not encapsulated by braces, that means we need to add space to it. Or that means it's going to add space after the preceding display. So, in this case, we have the host name and then a percent equal. So, this is going to put a space after host name. So, let's just go back along with this. So, we've got percent curly brace equals space M curly brace, percent H. All that's doing right there is saying, show me the host name in the color magenta. And then we have a percent equal. And so, we're just adding some space after the host name. Because remember, we want the host name to be on the left side. And now we'll put the windows, names, and numbers in the middle of the screen. So, that's what that equal sign is going to do right there for us. So, now we want to display the different windows that are set within the new screen config file. So, just as before, we start by setting the attribute that will be associated with the coming section. And we start that with the escape character percent. And then within the braces, we set the attribute to white. And so, that's what the percent curly brace equal. Because remember, if the equals inside of the braces, then we're just telling it to set the attribute that follows for everything that comes after it. So, we have percent curly brace equals space W curly brace. And what that is saying is that whatever is going to be coming after that last curly brace, we're going to set the color to white. So, what is following that? And this is where it's going to start getting a little bit tricky because the way that I like to have my windows displayed is that all of my window numbers and names are in just normal font white. Okay? So, whenever I change from say VIM to Bash to H top, whenever I change between those windows, what I wanted to do is to put a brace around it, change the color to red and make it bold. So, it is very clear as to what window I'm on at any given time. So, if you look at this section a little bit closer, it's going to make a little bit more sense now that I set it that way. So, we have a percent sign curly brace equals W curly brace. So, we're going to set everything to white. So, now we say percent minus W. Here, the W does not stand for white. It stands for window. Okay? And it gets confused because they use the same characters two different ways. And this is what really, really blew my mind for a while. So, the percent minus W is saying that all of the windows from this point on, okay, so the current one that I'm on and following, what are we going to do to it? We're going to set some more attributes to it. So, we're going to say percent curly brace. And now we're going to introduce the plus B attribute. And the plus B means we're going to change it to bold. And then we've got a space, capital R, and a curly brace. So, let me go ahead and say this all out right now. What we have is a percent curly brace equals space W curly brace, percent minus W, percent curly brace plus B space capital R curly brace. So, what this is saying is that we're going to make sure that all the windows are white. All the names and numbers are white. However, the one that we're currently on, which is the minus W, we're going to change its font to bold and change its color to red. Now, what are we going to do with it? That follows. And that's going to be in the brace, percent in a space, percent T bracket. Okay, so in the square brackets we have the number and the title. Okay. So, from here what we are showing is that we want to have the current window that we're on, and that's the plus B capital R, we want to have that in brackets, and we want to display the number and the title. So, 0, Vim, 1, Bash, 2, H, Top, 3, whatever. All right. So, the next section for the window part is that we are going to reset the colors. I know this is where all it kind of all over the place. So, we set everything to white. On the first window we set the font to bold and red, and we display the window number and the window title, and now we give it a percent curly brace minus curly brace. And this is going to reset everything back to what it was before the second attribute change. So, if remember we did it curly brace equals W, curly brace, and then later on we did a percent curly brace plus B capital R, curly brace. We gave the windows two different formats. So, first we made it white, and then also we changed it right to bold and red. So, the curly brace minus curly brace means to take away the bold and the red, and display the rest of the windows the way that it was at the beginning, which would be white. Sounds even more confusing whenever I say it out loud. All right. So, the next section in my hard line is just like I did before, after the host name, I want to put the date and date and time. I want to put it right justified. So, I put another percent equals in there with no curly braces to shove everything after that to the right side. And what we have over to the right side is the date, and that's the short date, the short day, which would be the M-O-N-T-U-E-S-W-E-D for Wednesday, SAT for Saturday, that kind of thing. It doesn't give out the number or the full name. Before that, what we do, what I do is I have, in this section, I have two colors. So, I have a capital K, and I have a lower C. Whenever you put two colors together in the same curly brace before an attribute, the first one changes the foreground, and the second one changes the background color. So, if we had a W there, then it would change the background to white, and the second color indication changes the foreground or the color of the font, or what text or whatever is being displayed. So, in this case, I have a capital K and a lower KC within curly braces, and following that, I have a percent capital D to show the short day display. So, this is going to make the background of this section a bright black, which is actually gray, so it makes it stand out a little bit better. And then we change the color, and after that, I have a section that shows the month-day year, that's the American, the US typical format. We put the month-day, then the year, in that order, and we separate it by slashes. And this is pretty typical format of how any programming language or just about anything does, that they do a percent M for the month, percent D for the day, and percent lowercase Y for the year. And so, you get like 040916 instead of 2016. And then the last section, after that, I have is just the time. And as you can see from my heart status, and as we said before, this is the curly brace G, curly brace, which is going to change the font to green. And then we have the percent capital C, which will show the time in a 12-hour format, and if you wanted that in the 24-hour format, you would just use a lowercase C. Since I use this in the 12-hour format, I need distinction between either 4am or 4pm, so that's why I have the percent A, lowercase A, to show that. So, it puts an AM or PM in lowercase for me at the bottom, right at the end of it, rather. So, it's a little confusing to say this without actually pointing it out and doing like a slideshow and stuff, but hopefully it makes sense. I'll put a link to the show notes, link in the show notes to my configuration file, as well as a webpage for the GNU.org manual on string escapes. And so, maybe there's something there that you can either add to yours or make yours look the way that you like it. But if you've never used screen before, I would highly encourage you to do so. It's a fantastic piece of software. It is very simple, it's very light. I don't think, after finding this piece of software, I don't think that I could actually do an installation of Linux and not have it within the first top 10 pieces of software that I installed prior to that. All right, so, that's all I have for today, and hope you've enjoyed and got something out of it. And if you would, please contribute a show to HBR. Thanks a lot, and have a great day, bye-bye. You've been listening to HackerPublicRadio at HackerPublicRadio.org. We are a community podcast network that releases shows every weekday Monday through Friday. Today's show, like all our shows, was contributed by an HBR listener like yourself. If you ever thought of recording a podcast, then click on our contribute link to find out how easy it really is. HackerPublicRadio was founded by the Digital Dog Pound and the Infonomicon Computer Club, and is part of the binary revolution at binref.com. If you have comments on today's show, please email the host directly, leave a comment on the website or record a follow-up episode yourself. Unless otherwise stated, today's show is released on where creative comments, attribution, share a like, 3.0 license. You've been listening to HackerPublicRadio at HackerPublicRadio.org. We are a community podcast network that releases shows every weekday Monday through Friday. Today's show, like all our shows, was contributed by an HBR listener like yourself. If you ever thought of recording a podcast, then click on our contribute link to find out how easy it really is. HackerPublicRadio was founded by the Digital Dog Pound and the Infonomicon Computer Club, and is part of the binary revolution at binref.com. If you have comments on today's show, please email the host directly, leave a comment on the website or record a follow-up episode yourself. Unless otherwise stated, today's show is released on where creative comments, attribution, share a like, 3.0 license.