 Hello! Today we're going to be looking at another script I wrote. Again, I'm going to just go over this script. I'm not going to go into detail. Everything in this script I've gone over in the last two weeks or so, the different commands and techniques to do these things. So I'm not going to go into detail on them, but if you watch my previous videos, you'll find all more detailed information there. This script is my tiny URL script. It is a script I run that will take whatever is in my current selection clipboard and pass it to tiny URL and hopefully get a tiny URL back. So it's very simple for me to highlight a URL and run this script and get a tiny URL. So we're going to scroll down here. I have my main function, which if we go to the bottom of the script you can see is called at the bottom there. But going back up in here, the first thing we're going to do is check dependencies. This is something I do sometimes. I didn't do it in my last video. And this is just because it's a script, so I'm not packaging it like a DEB package or some other RPM for Red Hat and stuff like that. So what I'm doing here is I'm going to check for dependencies. So the dependencies, check dependencies function, what it's going to do is it creates an array of programs I need. So these are programs the script is going to use that probably aren't installed by default. QRN code and X clip. And so here we're looking, does this file exist? Well, actually here we're putting these file names in there and then we're creating another variable with the package names. So next we're going to loop through each one of these. So when the script runs it's going to go, hey, does this file exist? Hey, does this file exist? If either of them don't, then it's going to attempt to install. So here we're checking if those files exist. It's going to attempt to install those dependencies. It's going to list the dependencies. I just put them in arrays there just to keep things short, keep my code clean. And then I'm going to pseudo apt-get. I usually use apt, but in script I like to use apt-get because it's older systems might not have apt on there. It also might be a bad habit to put pseudo in a script, but I do it sometimes. So what it's going to do is it's going to run pseudo apt-get install and it's going to try to install both these packages. Now, if it's successful, it will break out of this loop and continue into the script. If both those files exist, it won't even do any of this. But if it fails, it's going to echo you, install dependencies failed, which it will tell you what dependencies are here. So if for some reason you don't type in your pseudo password, which you shouldn't, if you haven't looked at a script, if a script or program asks for you to type in your pseudo password, make sure you trust it. So here you can see what's going on. So if that fails, or if you don't have apt-get, because you're running on a non-debian-based system or for some reason apt-get is solved, or if the packages might be called something else and aren't in your repositories, for any of those it will fail. But you'll know what those packages are and you can manually install them. We also exit with one so we know that the script failed. So that's just checking to make sure that these programs exist, because especially XClip is dependent on that. I didn't really check for NotifySend, because most systems, if you didn't start with a very streamlined system, if you're running with Debian, Debian Mint, Debian Mint, or I'm sorry, if you're running Ubuntu, is what I meant, said Ubuntu or Linux Mint, or one of those pretty much all of the major distros out there that you aren't building up from a minimal install, are going to have NotifySend installed. But QRN code and XClip are not. So basically, again, it's just checking to see if these programs exist. If not, it tries to install them. If it fails, it's going to tell you that it failed, and you can manually try to install them. It's going back up here, though, to our main function. Everything else is done in our main function, because it's fairly straightforward, line by line. So, if it's happy, if we have XClip and QRN code, what we're going to do is we're going to check what's inside your clipboard. But on any clipboard, it's whatever you have selected with the mouse, so you have to select it with the mouse. So basically, you've highlighted a URL. And just to head up and say later, if you are in a web browser, here example, let's say I'm here and I click on this and that's highlighted all of a sudden, you haven't selected that. You actually have to select it with the mouse. So again, just clicking in the URL there, it looks like it highlighted it, but it hasn't. You have to highlight it like that. But once that is done, it's in this clipboard and we're now putting that URL into our URL variable. Then it's going to echo out, this is the URL you started with. Then we're going to use curl dash s means silence. We don't get all that process bar and other junk in our output. And it's going to pass that URL that's in our clipboard to tiny URL. Tiny URL will return some text with your tiny URL in it. We're going to grep and find that text. We're looking at the following URL. We're going to look three lines after that. And then we're going to grab the last line. Then we're going to trim that up with awk instead. There might be a cleaner way to do this, but that's how I did it. And that should get us what tiny URL has created, our new tiny URL, and it's all put into this variable tiny URL. At that point, we're going to check, did we actually get something or is it blank? Reasons it might be blank. You highlighted something that was not a URL. Also, URL, tiny URL does not like when you try to submit a URL that you've already submitted. Well, if that happens, we're going to echo out an error-getting URL and there an exit one with, exit with one because an error script failed. That's just an if-then statement that was short, so I put it all on one line. Well, if we didn't exit, if that was successful, we have a URL in this variable now. We're going to continue and we're going to put that URL into both our clipboards, both our selection clipboard and our standard clipboard, our primary and secondary clipboard. Next, we're going to echo out that it was put into our clipboard. This is the URL that was put in our clipboard. So now we can go and we can paste that. We can either center-click or control-v or control-shift-v if you're in a shell or edit-paste or right-click-and-paste. That URL is in there. Next, we're going to go ahead and, you know, the last script I showed, you know, I, you've passed arguments. This program is taking arguments. You just run it and it looks at what's in your clipboard and tries to run. So it's going to give us a QR code output to our shell using Unicode. We can verify and display a dialogue box on our screen for five seconds. This is also very useful if you're not actually in the shell-runless script, which we'll talk about, because in reality, again, on my system, I have put that in my local bin folder. So now, anywhere on my system, since that's in my path directory, path variable, if the directory is in my path variable, I can just type tiny URL. And if I enter here, we're getting URL. That's because I haven't highlighted a URL. So let's go ahead and go here. I will highlight this URL. I will run tiny URL. And there we go. I got the message up here for five seconds. I got the QR code up here. Let's make this full screen. And it also outputted to the screen. You have this. And it's in my clipboard, so I can paste it. I just highlighted that. So that would be a bad example, to paste the URL here. That's great, but that's a little bit easier than actually going to the tiny URL site and pasting in the URL. So how can this be more convenient? Well, now that you have this script and since you don't have to pass arguments to it, it just looks at your clipboard, you can create shortcut keys on your system to just run the script when you hit the shortcut key. And I'm not going to show how to do that. I'm using I3, so I just put it in my config file. What keys I want. And I have it set as my modifier key as my windows key, if you want to call it that. The key with the windows logo on it. If I hit that in T, it will take whatever is in my clipboard and run this script. And since I don't have a shell open, I won't see any of this stuff. And that's why the notification box is useful. But as soon as I run that, I know that that's in my clipboard if it ran successfully. So let's give it another example. Let's go here. And let me go ahead and highlight this. And I will hit windows T. And there you go. I have the tiny URL. It says it's there. It's in my clipboard. And now I can go over here and I can center click and there's that URL. Or I can control V. And there's that URL. So that is super, super useful. So anytime I want. If I wanted to go to linux.com. I come here. I go like this. I just highlight that. Windows T. And it's in my clipboard, the tiny URL. Obviously it's not a shorter than this. If I had a long URL, I just hit windows T. And in a couple seconds, I have a shortened tiny URL in my clipboard that I can now paste into a text or an email or a chat box. Very, very useful. Now, how do you get this script? Go to filmsbychrist.com. That's Chris Decay. There's a link in the description. There, click on software. You can do notes. And I'll try to put a link to the script in the description of this video, but I forget to do that sometimes. But if you come in here, just type in tiny URL. And you should see one that says create tiny URL link for clipboard and shell. Click that. And here is the script. I wrote it. It's under a GPL3 license. So now you can copy and paste that and put it on your own system. Then whatever desktop environment you use, create a shortcut key, whatever you want it to be. It can be Control, Alt, Delete, 7A, B, C, whatever. Suggest something simple. Like for me, it's Windows T for tiny URL. Very useful. I think I use it all the time. And I hope you do too. Visit my website. Also, while you're there, go to the support section. Support me through PayPal or Patreon. If you support through Patreon, you can get early access and downloadable videos. And as you can see by date, I create these early. Then in a week or two, I'll probably organize them and then I'll upload them. Patreon users get them in bulk early and then over time, I post them out to YouTube. But if you want them all together early, Patreon supporters get that. So check that out. I do appreciate all support. Be sure to like, share, subscribe, comment. And as always, I hope that you have a great day.