 So I put in a lot of work here in the last few weeks working on DTOS, which is my arch post installation script. It installs a bunch of programs and config files. So you guys can get my Xmoned desktop environment essentially. And one of the things I've been getting, of course, a lot of support requests about DTOS and I wanted to have some kind of help information, some kind of help program installed along with DTOS. So you guys can quickly search for some of these help topics. And I think the easiest way to do this is I've made more than a thousand videos at this point. I've made a lot of videos about things like Xmoned and Dume Max and the fish shield and various command line utilities. And why don't I just make that the help program is what I'm going to do is I'm going to create a D menu script that will list out various videos I've made about these programs. And you guys of course can search through the D menu script for whatever information you're looking for. For example, if you're looking for videos about Xmoned, just type Xmoned, you'll get some search results return. And then you click on the video that you want to play and it should open it in your browser and creating a simple shell script to do all of this for me. This is not going to be a difficult task. I know a lot of people, if you're new to Linux or you're new to the Linux command line, a lot of people have this misconception that, you know, shell scripting is really difficult to learn and is really difficult to, to understand. It's actually quite easy to understand. If I actually switch over to my desktop and I will show you what I've done here. Now this is not a shell script. This is me going to YouTube and I found a bunch of videos that I thought would make good help information for DTOS. So what I did is I copied the titles of my videos followed by space and the URL. So this very first line here, you know, I've got the title and then space and then after it, the URL. And I did that for, I don't know, 50, 60 videos here. So what I'm going to do is let's turn this into a proper shell script. So I'm going to make this a bash script. The first thing I'm going to do here inside do me max is zoom in. So you guys can see exactly what I'm about to do and we'll go ahead and zoom in way in. Okay. The very first line, of course, needs to be the shebang, which is going to be crunch bang slash user slash share, not share slash user slash bin slash in the space bash. All right. I'm so used to typing slash user slash share at the command line because I edit so many files on that particular directory. I was about to give a bad shebang there, but that is the shebang user bin env space bash. And I think what I want to do since this list is title followed by URL, I think I'm going to use what is called an associative array inside bash. And I do notice I misspelled that word there. I put two G's and only one in in beginners. So rookie mistake there. So what is an associative array? Well, that would be where I do declare space dash capital A space. And then the name of the associative array. I'm going to call it DT vids because I mean, that's what they are DT's vids. And then the next line should be the listing of the values. And I could almost use this list because typically for an associative array, you'd do something like associative array. And then inside brackets one for the value here or the key and then equals. And then the value, which would be whatever value you wanted. Now, what I'm going to do in my associative array is I'm going to do associative array. And then the key is actually going to be the title of the video. And then the value will be the URL of the video. So I'm just going to have, you know, 50 lines here of this associative array and the values. I'm just going to have to plug in the values here. But thankfully through the magic of Vim or in this case, evil mode inside Emacs, which is of course, emulating Vim, I can actually very quickly put these lines here that I copied earlier into this format for the associative array. So since we declared that the associative array that the name of it is DT vids, every value would have to be DT vids here. So I want to make that point right away. So let me go ahead and use command mode here to actually add DT vids at the beginning of each line here. So I'm going to do shift V to get into visual line mode here inside evil mode, but you can think of this as Vim because this works in Vim as well. And I'm going to select all of those lines I created, which is just the titles of my videos followed by a URL. And now what I'm going to do is I'm going to do a colon to get into command mode and you see the single quote, then the angle bracket to the left, comma, and then single quote, angle bracket to the right. That means do this on every line that we've selected. Then I'm going to do space norm for normal mode space capital I, meaning insert at the beginning of the line. And then what do I want to insert at the beginning of the line? Well, I want to insert DT vids and then a bracket, just the opening bracket, not the closing bracket, the closing bracket we'll deal with later. And if I did that correctly, you see, we have DT vids and then the opening bracket and then the title. So that takes care of part of the form that this needs to be in. Now, the next thing we need to take care of is the closing bracket, which needs to go at the end of the title, you know, and then before the URL. So the easiest way to do this would just be to do a quick substitution. So I'm going to do colon and then I'm going to do percent sign. Yes. So I want you to do this on the entire document. I want you to search for HTTPS. Actually, I think I want you to search for space HTTPS. Yeah. And then what I want you to do is replace that with the ending bracket, space HTTPS and then slash G and that should do that globally. And if that worked, yeah. And now we are really close. If I zoom back out so you guys can see the only thing we're missing is we needed an equal sign. So actually should have added an equals to the HTTPS. So that was my mistake. I could actually just undo so you on the keyboard and Vim to undo. And then I could try to run that command that I just ran. So I just did colon to get back into command mode up arrow to get my last command, except this time, instead of that space, what I'm going to do is ending bracket equals HTTPS and then run that. All right. So we've almost created our associative array. The only thing is we need the URLs. I think they're going to have to be wrapped in double quotes. I'm pretty sure that's important. So I'm actually going to undo you to undo again colon to get back into command mode and this time what I'm going to do is I'm just going to rerun that last substitution. Except this time I'm going to turn that space into a closing bracket equals double quote HTTPS. All right. And now the only thing we need to do is add the ending double quote to the end of every line. Typically how I handle this is I just do a macro. So I'm going to do Q2 on the keyboard. Q means assign a macro, pick any key on the keyboard. I picked the number two. It didn't matter what I picked. And now it's actually recording the keystrokes I'm about to do. So I'm going to do J to go down a line. Then I'm going to do a to append a line, meaning go to the end and get me into insert mode and then do a double quote and then escape. And then I'm going to hit Q on the keyboard again. Now that macro was recorded. I just need to run it. There were 52 lines, so I need to run it 51 more times. I'm going to do 51 at two. And you say it just did that 51 more times for me. So that is it. That is the array I can get rid of the example array. And that is the DT vids associative array. So that was actually very easy. The only time consuming part was going to get the titles of the videos of the URLs of the videos. But creating that associative array was actually really easy. Thanks to the power of VIM macros. And then what I'm going to do is I'm going to go down below the associative array and I'm going to do title equals. This is just a variable. I can name it anything. I'm going to call it title because I want a list in deep menu of video titles. I want all of these video titles, which is the key, which is the part in the brackets for each value of that array. So I'm going to do title equals dollar sign. And then I'm going to do parentheses. Let me zoom back in here so you guys can see how zoom. I had to zoom out so you guys could see the whole lines here. But I'm going to zoom back in just a little bit. So title equals dollar sign parentheses. Now that signifies we're running a command. What command are we going to run? I'm going to run print f space. And then I'm going to do single quotes here and I'm going to do percent s. And that is the placeholder value. So whatever value print f is printing, I want it to backslash in so that is a line feed. So basically, I want everything on its own line. Now we need to tell print f what it needs to print. So what I'm going to do is, of course, I'm going to print everything in the dt vids array. So I'm going to do inside double quotes, dollar sign. And then I'm going to do the curly braces. And then I'm going to do dt vids and then the square brackets and then the at sign. So I want you to print everything in the dt vids array. Now remember the associative array, each line has two values, right? We have the key, which is the title of the video that I put in the brackets. And then we have the part equals and then inside double quotes, a URL. So which is going to get printed here? Well, dt vids, that variable there is going to print the URL. That's the value. If you want the actual key, which in my case is going to be the video titles, what I have to do is instead of doing dt vids, I need to do exclamation dt vids. And that will return the titles rather than the URLs. And just to verify that that actually is the case, what I'm going to do is I'm create a new line and let's just echo title here. And I'm going to write that and then I'm going to open a terminal. Let me zoom in on the terminal here and I'm going to run this script. I named it dtos-help.sh. And if I run that, it actually does echo in the terminal here. You guys can see it's all names, right? It's titles of videos. There's no URLs. You can see there's no HTTPS anywhere in that output. So that actually did do what we wanted it to do. But of course, I don't want that to echo all that information in a terminal. What I want to do is I want to take the printf command and let me get rid of that ending parentheses. Because what I'm going to do is I want to printf the key values. And then I want to pipe that, of course, into dmenu. And I'll give dmenu the following flags, dash L for lines, 20 lines, and then dash P for a prompt. I'll call the prompt dtos-help. Space, I'll add a space behind it just in case we need some extra spacing. And then finally, of course, I want to add back that ending parentheses that we deleted earlier. And I'll write that and then let me get back into the terminal. And I'm going to rerun the script and you see dtos-help colon and then a list of video titles. Now, I could click on one, select one, but nothing's going to happen. Because, of course, we haven't told the script yet what to do once we actually select something from the dmenu list. So I think what I'm going to do for this, you could do this a bunch of different ways. I'm just going to do it if statement. So I'm going to do if and then opening brackets here. And then inside double quotes, I'm going to do title. So if title, meaning if I selected something from the title variable here, so the dmenu, right, if we select something out of that dmenu, then I want you to run the following command. The command I want you to run is I want you to run my browser and my browser is brave at the moment, but it could be cute browser. I have cute browser installed cute browser is the default browser inside dtos. So I want you to run a cute browser and then cute browser URL. So I want you to grab the URL from the associative array. But of course, we need to define what the URL is. So what I'm going to do is I'm going to do URL equals. And then once again, we're going to do dollar sign parentheses for a command. And I want the URL to equal print F. And then once again, inside single quotes, percent sign is backslash in. And then what do we want it to print? Well, kind of similar to what we did here, except instead of getting the key value, which was the title, I want to grab the URL. So this year, do a Y to yank and then go down here and paste that. Yeah, forgot one of the double quotes. There we go. And then this time, instead of that exclamation point, I'll just get rid of that. And now that should grab the URL. So URL equals print F and then dt vids and then inside a bracket, the at sign. Now, the at sign is not going to work for us because at signifies print out everything in the array. So it's actually going to print out all the URLs. Well, I don't want Kube browser to open 50 something URLs, right? That's going to be a lot of instances of Kube browser that open. So I actually want to specify a specific value here. What value? Well, I want the title. So what I'm going to do is inside the brackets here. I'm going to do a double quotes again and then dollar sign and then the braces and title. So you guys see how that's going to work. I'm going to get a D menu. It's going to give me all the titles of my videos. I'm going to select one. And then when I select a title, it's going to use that title as the key value to find in the array. And when it finds that title, that key value in the array, it will set that as the URL to be opened inside Kube browser. Now, we need to finish this if statement because we did if then run this command. We also need else because it's always a good idea to add else, even though there's really nothing else I wanted to do. Just in case for some reason somebody quits out of the D menu or doesn't select anything or for some reason the script fills, I want you to echo program terminated and and exit zero. So it's just going to quit out the program and finally FI, which is if in reverse, that's how you end an if statement. So you begin it with if you end it with FI. Now, let me zoom back out here so you guys can kind of see the finished script. Right. This is not very difficult. This was not a lot of lines of codes. And of course, I took my time a little bit explaining it, but this is not complicated at all. So if I rerun the DTOS help shell script here, I get a list of video titles. One thing I don't like is they're not in alphabetical order. So let me escape out of that. And this is very easy to fix. What I could do is where I take the titles of the videos and pipe them into D menu before I pipe them into D menu. I'm going to pipe them into sort. And then after they get piped into sort, and so they're sorted alphabetically, then pipe everything into D menu. I'm going to write that. And now let's rerun the script. And now everything is nice and neat in alphabetical order. If I wanted to watch my video, do me max for noobs. I could click enter and that should launch. Cue browser. It does. On that video, of course, we're going to get a ad playing. So again, really simple script, these kinds of scripts, these simple shell scripts. I mean, that solved a real world problem that I had and that took all of just a few minutes and I will eventually package that up in a nicer format. There's some other things I probably need to add to the script before I put it out there publicly, but eventually here in the next few days, you guys that are running DTOS will have a package available so you can install that particular D menu script. And that way you have an easy way to quickly get help information if you need it. And before I go, I need to thank a few special people. I need to thank the producers of this episode. Devin Gabe James, Matt Mitchell, Paul Scott, Wes Akami, Alan Schuch, Commander, angry Kurt Diokai, David Dillon, Gregory Hike, Oli Maxim, Michael Mike, Nitrix, Erion Alexander, Peace Orch and Fedora, Polytech, River, Red Prophet, Stephen and Willie. These guys, they're my high steered patrons over on Patreon without these guys. This quick episode of me doing some rather basic shell scripting would not have been possible. The show is also brought to you by each and every one of these ladies and gentlemen as well. 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. It's just me and you guys, the community. If you like these kinds of videos and want to support my work, please subscribe to DistroTube over on Patreon. All right, guys, peace. And it doesn't have to be YouTube. You could create a list of videos from Odyssey, PeerTube or even The Hub.