 Today, I'm going to show you guys how you can go about configuring your fish shield, adding a bunch of extra functionality to it, and really making it look good, look sexy. And we're not going to use Oh My Fish. Now, this is something a little different, because most people that use the fish shield probably do use the Oh My Fish framework to install plug-ins, and you get some of this extensibility added to the fish shield. But you don't really have to, because Oh My Fish just adds a little bit of bloat to the system, because you end up with all these extra files all over the system. And really, all you need is one config file, kind of like with the bash shield. All you need is a bash RC or CSH. All you need is a CSH RC with fish. All you need is one file, config.fish, and you can put everything in that one file and manage it yourself. You don't need Oh My Fish to manage it for you. So let me switch over to the desktop here, and I'm going to go ahead and launch Doom Emacs here and search for my config.fish. And let's open that up and I will zoom in a little bit here so you guys can see a little bit of what's going on. And basically, all I did is I found all the stuff that I wanted to add through Oh My Fish, and instead of installing it through Oh My Fish, I just found the little snippets of fish script from those plugins and put it in my config.fish. You know, it was total script kitty, what I did. But it did work. Now, before we get into some of that, though, one of the things with fish is by default, when you launch a terminal with the fish shield, it usually has a welcome message like welcome to fish, the friendly interactive shield. I think that's the actual message if I remember correctly. And it's annoying because you always have that welcome message every time you first launch fish. So you need to add this line here, set fish underscore greeting, and that suppresses fish is introduction message. Meaning you'll never see that message again. So that's very important. Now, when I was using Oh My Fish before, one of the things I really loved was the sashimi prompt that you could install from Oh My Fish. There was a whole bunch of different prompt themes you could install. And I installed one called sashimi and it just looks gorgeous. I can actually show you guys, let me open a terminal. This is basically the sashimi prompt here you're seeing in fish. And I wanted that. And I was like, well, can I get that without using the Oh My Fish framework? And of course you can. You know, all I did was I went to GitHub and I found the GitHub for the sashimi fish prompt, and it's just 74 lines of fish script. So all I needed to do was just take that copy those 74 lines. And then here inside Emacs, what I did was I made myself a note prompt. This was the sashimi prompt of Oh My Fish. And then I pasted those 74 lines. And I left my self a note where the prompt ends. And that gets me that sashimi prompt that I really liked. I made some minor edits to these 74 lines as far as colors that I preferred rather than some of the default colors. But it's basically the sashimi prompt. The next thing I did in my config.fish is I've got this section here where I set either Emacs mode bindings or VI mode bindings. And typically in my shills for a long time, I've been a VI mode user in the shill. But for purposes of this video, I switched over to the default key bindings, the Emacs style key bindings rather than the VI key bindings. And I did that for a reason because I'm going to demonstrate some added functionality to fish that you can add. But what I'm going to demonstrate will not work with the VI key bindings. So I went ahead and changed this to the Emacs style key bindings for now. The next section I have labeled spark and what spark is is another custom function that you could install through something like the oh my fish framework. But what I did is I just went and grabbed the code for spark, the fish script code for spark. And I pasted it here kind of like what I did for the prompt. And let me show you guys what spark is. I go to GitHub again and I look for spark dot fish. What this does, it gives you these visual representations like a bar graph for things. You can do commands and you can pipe it through this fish function called spark. And you get this bar graph output. And if you pipe that through something like law cat, L-O-L cat, you know, you can get colored bar graphs and it's pretty cool. The spark dot fish script here is only 51 lines. So it's actually less lines of code than the sashimi prompt that I had copied earlier. Anyway, I added the spark code here, those 51 lines. And then I needed to add some functions for spark because spark really doesn't do anything by itself. So just to show you guys exactly what spark could do. I created some just test functions here. And the very first one function letters. So I created a function called letters. And what this does is it runs this command, the cat command. And then it takes an argument. So cat and then I give it an argument, say my bash RC. So I kept my bash RC and then it pipes it through oak, which takes these flags and does some various substitutions and prints it out. And then whatever it prints out, it sorts it alphabetically. And then it runs the cut command on it because we're going to cut out some information and then it's going to run it through spark to visually change all of this stuff into a bar graph and then it's going to pipe it through lol cat to give us some colors. And then I'm also going to do a second line. I want you to print the alphabet A through Z and also pipe that through lol cat. Now, some of that probably doesn't make any sense yet, but let me open up a terminal and I'm going to zoom in here and let me clear the screen. And of course, this is spark here. I'm going to show you exactly what just happened there, but let's run the letters command and I will run letters dot bash RC. So it's going to run that custom function letters on my bash RC. And what this is going to do is it's going to cat out my bash RC and then pipe it through all and it's going to find every letter A through Z and get a count of them. And then the bar graph from spark is going to be the representation of how many times that letter appears in my bash RC. And so there you go. And you can see that's why I created the second line that has A through Z is because it would be kind of hard to tell what letter is what without having the alphabet up underneath it as well. You can see A by far is the most common letter in my bash RC. Then I also created a second test function for spark. Just to show you guys a little bit of what you can do with spark. I created function commits and it runs a get log with the flag dash dash author equals and then it takes an argument and the argument needs to be the author here for a get repository. So let me show you guys this in action. What this is going to do is it's going to run commits and then whatever argument I give it in this my main repository here, my dot files repository on my main production machine. There's only one get author and he is named Derek Taylor. And what this does is it creates a graph and the number of commits that this particular author and me in this case has made again, it really serves no purpose. This is just an example, you know, an example of a function and something you could do with something like spark. If I go toward the end of my config dot fish, I went ahead and added an alias for the clear command and what the clear command is going to do is going to clear the screen. And then it's going to run this command here. Sequence one T put columns and then sort spark lol cat echo echo. What this is going to do, if you guys want to see it in action, just clear the screen and it creates this random bar graph that says, why does your terminal and I of course pipe it through the lol cat colors. So, you know, it'll be something different every time and it's kind of cool. And that's for you typing the word clear. If you do the key bindings for clear, such as a control L, you get the bar graph, but the lol cat colors don't work when you do the key binding. But clear always gives you that nice rainbow. Now, getting back into the functions that I were creating, I mentioned the other day that the fish shell out of the box does not support the bang bang functionality, the bang bang expansion, where you type two exclamation points and it expands to the last command from your history. That's not something that's built into fish. But that doesn't mean you couldn't add that functionality by simply creating a function for it. And that's exactly what I've done here. I actually found this on the internet there are a dozen different ways you could achieve this in fish by writing a custom function. And there were several different ones I could have chosen from. But I found this plug in here from oh, my fish called plug in dash bang dash bang. So plug in bang bang and then key bindings dot fish and then functions here. Now, the functions are two very short functions, one for history, previous command and one for history, previous command arguments. I took those and then I also took the bindings. So really only about 15 lines of code from those three files altogether. And I pasted those right here. So here are the functions. Here's the history, previous command function. And here is the history, previous command arguments function. And then at the bottom here, you see the two bindings. It binds the exclamation and it binds the dollar symbol. And what this does is now you get the bang bang command working. You also get bang dollar sign working the way it would work in something like bash. So if I did an LS command and let's say I did an LS command on my wallpapers directory and now say I do bang bang. You see how that immediately expanded to LS wallpapers. So it immediately figured out, hey, bang bang means the last command. I'm just going to go ahead and expand out to it. And that's fantastic. Now, what if you only wanted the argument from your last command? You don't want the command plus the argument. You just want the argument. Well, now you do bang dollar symbol and I just get wallpapers. For example, I did LS wallpapers when really what I wanted to do with CD wallpapers so I could do CD space and then bang dollar symbol. And I get that last argument without the command. The last thing I want to show you guys is just a bunch of custom functions. I added several just to show you guys a little bit of what is possible with functions. And I found them all over the internet. One of the best places I found was this guy's repository here, fish dash functions from Razzias. And he has several, you know, like a couple dozen, maybe 30 or so custom fish functions that he wrote and uses. And I just ripped off several of them from him. And some of them I made some minor changes to. But let me show you some of these in action. For example, function, C-O-L-N for column number. And what this does is you give it a command that's going to return some stuff in columns and then you pipe it through call number and then you give it a number and it prints that specific column number and the columns, you know, are separated by spaces is how that's going to determine what a column is. So in the shell here, if I echo one space to space three, you have three columns because one, two and three are all separate columns. And if I pipe that through C-O-L-N space and then three, for example, I want the third column, it's going to return just the three. And typically when you're trying to just grab one specific column of information or one specific column of text, that's typically done with the alt command and that's what this guy was doing. He just says piping that through alt and printing whatever column we give as an argument. He also created a very similar function for grabbing a specific row of information, so row in for row number. And this is typically done using the said command. That's what he's doing here. So if I do something that's going to output lines here, for example, sequence, if I do sequence five, you know, I'm going to get one and then a new line two, then a new line three, you know, so forth until five. But if I run that and pipe that through row in and I want specifically row three, all I'm going to get is the three. I'm not going to get one, two or four or five. Now these are very simple functions. I mean, most people probably already know the basic alt command to grab a specific column of information. The same thing with said grabbing a row. Do you really need to create a custom function for that? Maybe, maybe not. But to be honest, I think it's kind of handy to have these functions available. Some of the other ones that I grabbed from that particular GitHub, the Razzius Fish Functions GitHub, is he had a function where you could cat something out and then grab certain lines. For example, he had this function that he called skip lines. I'm just going to call it skip and you're going to give it an argument for the number of lines you want it to skip and then it's going to give you the output minus the number of lines you told it to skip. For example, if I cat my bash RC again and then I pipe that through skip and let's skip the first five lines. And of course, that's a ton of output because my bash RC is long. But let me scroll back up here just to show you guys it did skip the first five lines because the first five lines are the word DT with my GitLab information and it ignored all of that. It skipped those first five lines and then printed the rest of the document. I also took this function here called take, which is the opposite of skip. So if you take the first five lines, it's going to print out the first five lines and then not do the rest. So let's see, take an action. So cat bash RC and then pipe that through take five actually returns the first five and that's just a little bit of what I've done with my config.fish. And of course, I added all of my aliases. This is just all the aliases I was already using in bash and CSH. I just want to add and add to this very large alias section to the config. But overall, I'm pretty happy with my config.fish as is. I'm really enjoying playing with the fish shell. And I think that is one of the best things about fish is that it makes the shell fun. It makes it fun to play at the command line. It makes it fun scripting, you know, playing with those functions. And I'm also really glad I got away from oh, my fish, because I version control everything and it just makes it a lot easier now that I have the one file config.fish that I have everything in. You know, I just put that on my GitLab. And then every time I reinstall or install on another machine and I want my fish prompt, my fish shell, I just grab the one file. I don't have to worry about installing oh, my fish and then installing the various plugins. And what if I edit those plugins? You know, what if I go into the oh, my fish plugins? I don't like the defaults and I start changing them. And then I got a version control my own plugins for oh, my fish. And I just going to throw it all in one file and be done with it. And in a lot of ways, it kind of debloats the fish shell a little bit. Now, before I go, I want to thank a few special people. I want to thank the producers of the show, Michael, Gabe, Corbinion, Mitchell, Devon, Fran, Arch, 5530, account me, Chuck, Claudio, Donnie, Dylan, George, Gregory, Caleb, Devils, Louis, Paul, Scott and Willie. These guys, they are my highest tier patrons over on Patreon. Without these guys, this episode about configuring the fish shell would not have been possible. The show is also brought to you by each and every one of these ladies and gentlemen, all these fine ladies and gentlemen help support my work over on Patreon because this channel is supported by you guys, the community. If you'd like to support my work, consider doing so. Look for DistroTube over on Patreon. All right, guys. Peace.