 Hello! Today we're going to talk about aliases. I'm sure a lot of you know what aliases are and hopefully you use them a lot. I do. I use aliases all the time. I even alias my aliases sometimes. So let's have a quick look at some aliases, some examples. I actually have set up on my machine, but I mean I have a lot of aliases. And what is an alias? An alias is just like an abbreviation for a command. So let's say you have a command that W get. Let's say you just want it to be W. You can alias W get and then you can just type W instead of W get. I mean that's kind of a short example. But you can also alias out longer commands with strings and arguments and whatnot in there. But let's have a quick look. Now if you were to type in aliases or just alias and hit enter, it's going to list all the aliases you currently have set up on your machine. Okay? I'm not going to do that because some of mine are private. I have one right here that I grep for pension. We'll get to that in a moment. But right now, let's go ahead and just grep for dental insurance, right? I got three aliases here. I have the long one. It's called dental insurance. It's actually using the open command to open a website. What is the open command? Well, I actually have an alias for XDG open. So what is XDG open? So XDG open is a command that on Linux systems running Xorg, which is most desktop laptop Linux distributions, you run that and give it a file or a URL or a folder and we'll open it up with whatever the default program for that file type is. It's nice. So instead of going, oh, I'm going to open it with this web browser or that web browser, it knows what your default web browser is if you give it a URL. If you want to open up images, you don't have to go, oh, what is default image viewer on this machine, especially if you're going to share the script with other people, maybe they don't use the same image viewer as you. And this will open it up in whatever the default image viewer that user has set. Well, I shorten it down to open for two reasons. One, it's shorter. So for example, I can type in this directory, well, I can type in open and the name of my website, and it's going to use my default web browser and open up my web page. If I was to type open and do dot, which means the current directory, it's going to open it up in my default file browser. If I was to say open and give it one of these files that's in this directory, it will open it up with whatever my default image viewer is. If I change my default image viewer, it will open it up with that instead. So it's nice to just be able to type open in that, but I could also just type XZG open and the same thing, which is fine. But the problem is, what if you go to a system that isn't running Xorg? For example, your phone. I run Turmux on my phone. I can do almost everything I do on my desktop on my phone because Android uses the Linux kernel, but I don't run Xorg. You can run Xorg on Android. You don't need to root for it. You can run a full Xorg desktop. I just feel like that's overkill. So what do I do? Well, Turmux that I use, the terminal that I use for my, well, it's more than a terminal, but the terminal I use for my shell and interaction on my Android device has a command called Turmux dash open. I'm pretty sure it is what it is. Well, if I alias on my machine, on my phone, just in my configuration, my ZShell RC, I can type in open equals Turmux dash open, then all my scripts that I have on my desktop that I use the open command will now run on my phone and open up whatever file it is with whatever the default program on my Android devices, which is very useful. So let's go back to that last example, the first example. So I said, if I grep through my aliases for dental insurance, I have one called dental underscore insurance, and I have this where it opens up a URL. Well, then I also alias that alias three other times. So I have dental insurance. I have dental. I have assurance and I have sunlight because I don't look up my dental insurance information very often. But when I do, I need to log into their website. I can never remember what their website is because my insurance is assurance, but that's through sunlight. And then I have to find the right login place. So I could type in any of these. I can type in sunlight and it opens up that URL. I can type in just dental, which is probably what I normally type in. If I'm looking up for this information and it goes to the same website, or I can type in assurance and it will open up that website. So for me, aliasing an alias not only makes things shorter, but it allows me to quickly remember. I'll make aliases of anything I think I might type when I'm trying to do that. So I'm using it kind of like bookmarks in my shell because most time I'm at the shell. I'm at the shell or in a web browser. So most time at the shell, if I want to open up a website that I go to normally, I just have an alias for it. Let's look at another example. If I was to, well, let's grep for the word light. And that's going to give you a few examples here. So I have a highlight option. If I do a, just going to highlight stuff. Then I have light lighthouse and then LLL. Okay. So lighthouse, my kid's pediatrician lighthouse pediatrics. If I need to log into their portal, I'm at the shell. I just type lighthouse and it brings me to the portal and I can check on their information. But I also have this light, which does a W get command, which actually just talks to an ESP in the other room. What does that do? Well, it's specifically, well that the ESP chip controls a lot of the lights in my house, but I set up the light command to send the code specifically for the light in my office here. Now, most of the lights coming in the window right now, I do have my ceiling light on. But if I was hit light and hit enter, I think you could probably see that I'm turning the light on and off, but I don't want to type light every time. I can just go LLL and hit enter and it will turn the light on and off. So there's that. Let's look at another example. Oh, if you're going to SSH, if you have multiple servers, I don't SSH my username at the IP or domain. And if there's a different port number, the port number, no, my server in the next room, which is my next cloud server, I just type in octo and it brings me to the prompt to log in and give them my passphrase. And I actually have it set up so that it will detect whether I'm at home or away. So if I'm at home, it's going to connect across the network. If I'm out, it's going to grab my IP from home and connect through the router, because it'll be different IP address if I'm remote. Same with my little ESP chip over here, ESP chip over here, a little Raspberry Pi over here, which is my secondary backup that backs up. I back everything up to, it actually has two hard drives to it. I back stuff up to it, but then it also syncs with the next cloud server occasionally. I call it Rook. If I press enter, type Rook and press enter, it brings me to that. I don't need to remember the IP address. I don't need to know whether I'm home or not if it's using a different port. Let's look at another example. A great little tool I just found out about the other day. I've actually written scripts similar to myself, but not as good. Movie.clt. Look it up on GitHub. If I was to run this, it asked me to search for a movie. I can search for a movie like this, and it's going to go and fetch a token, blah, blah, blah, and give me a list of movies that I can choose from. If I wanted to run the same thing, but for TV shows, I do the dash T option, right? So now I can type in a TV show and it will search through those and give me the seasons and whatnot. Well, I don't want to type that. I mean, not that this is a lot to type or hard to type, but I haven't set up. So I can just type movie. Oops. Yes, I want to convert that to movies, movies, and it runs it. And if I just type TV, it runs it with the dash T option. So I alias those two that way so that I can just type movies or movies or TV, and it will run that search for me. Back to what you probably saw when I first started this, I'm going to alias pensions. So I'm a firefighter. I have a pension. I like to keep up to date on the investments it in, how much I have saved up and stored. Well, my pension is a 175 pension. So I have pension. There's two different websites because I have my pension, but then I also have other investments for my retirement. Things I can't touch on until retirement. One's through nationwide and the other ones through a pension benefit website. I don't need to remember those two websites. If I just type in pension, it will open up those websites. Or as I said, it's a 175. I can just type in 175 and it brings up those two websites. It's run same thing because I've alias the alias or I can type retirement. Most time I'm probably going to type just 175. It's the quickest and easiest. But if I don't do this for two or three months, I'm going to be like, oh, what was that command? What was that website? No, I just go, oh, pension or 175. Whatever I think might come to mind, I will alias it different ways. So anyway, I hope and this gives you a new look on aliases and to realize that you don't just have to alias things once. And so basically like, like this one here, let's go ahead and clear the screen, run this again. So I have this, this pension open and then again, the next one, I alias pension, this one, I alias pension. And that way if I, those websites change, I only have to change the one. So I, you could put the same command into each one of these aliases, but it's a lot easier as long as you alias it in your RC file. Here it's listing in alphabetical order. That's not the order they are in my RC file. I would want to have this one first and then somewhere in the file probably right after it since they go together, but somewhere further down the file, I will have these two aliases. So alias, whatever and whatever. So yeah, I don't know how much use aliases for and really I don't use the bookmarks in the web browser very often. There's a few things I have a shortcut in the, in my web browser. For most part, things are in my history. I can just start typing within three characters, jump to my page, but let's say I'm already at the shell and it's just easier instead of going, okay, go to the web browser, you know, usually I'll hit control L to go up to the address bar and then start typing. I can just type again, 175 and it brings me to the two pages that I can log into to get my retirement information. Anyway, thanks for watching filmsbychrist.com. Actually, I'm probably going to do a video pretty soon if I get the chance on the differences between writing a script, writing a function or writing aliases and when you might want to use one over the other, because there are instances where definitely one is better than the other. And like, I use scripts and aliases a lot. I don't use functions too much, but I'll talk about that in another video. I thank you for watching. If you enjoy my videos and you want to support, you can get my videos early. If you become a Patreon member, a Patreon member, become a patron on Patreon, patreon.com.com slash metal x 1000. And also you can support me through PayPal or Libre pay links on my website under the support section. I thank you for watching. Visit filmsbychrist.com. Chris with a K. I hope that you have a great day.