Pretty Powershell

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
when I'm in Windows I'm in Powershell using it because it gives me so much power but man I gotta tell you Powershell looks really ugly and it needs to be fixed but more than that Powershell commands are extremely convoluted and it's almost like the Microsoft devs were on drugs when they wrote it but you go to like Mac or Linux and you start using their terminal to do things and it's just intuitive and smart but it's not to say Powershell can't be like that and that's what I made a Powershell profile project for that let's get on the desktop I want to show you one it makes Powershell look good but two it actually adds a whole bunch of aliases so instead of doing like an invoke Dash web request Dash uh the URI and all this other business that Powershell has going on you could just do like a w get as you should do like Microsoft why is this why am I the one to create what you should be doing but I digress let's get on the desktop and look at it okay this is my power show and Powershell has some really cool features to basically make it not suck because by stock defaults Powershell is pretty awful even with the new like Windows terminal but if we go to profile just like this just type in this variable it'll actually show you the profile for your Powershell now in typical Microsoft fashion they do try to confuse you because if you're using a Powershell five which was the standard in Windows 10. this profile is actually going to be under uh I think it's just regular Powershell documents Powershell and then if you're using Powershell 7 it's going to be under Windows Powershell they forget the path they use or can't be bothered to look it up between versions but it it it's it's here and you just have to use this variable and it always remembers the proper path name that's why you always want to get in the habit of using this variable is Microsoft apparently doesn't even know this variable exists even though they're the ones that created it ah Microsoft You Stay classy all right sorry not this is not going to be a Microsoft bash session although if they would just use bash it would be so much better but regardless we can open up this Command right here well let's just Vim into it and we're going to grab all of that file we'll post that over and let's take a look at what we have here it's a bunch of template profiles obviously I took this uh from online there's a GitHub gist from Tim that I based this off of Tim made a bunch of linux-esque commands and made aliases for them so we can have some sanity in our Powershell so getting down into the variables this script does uh let's start with dirs this is a really nice function and we're just going to go dirs and you can see what this does is it runs a dir recursively so as we're going through this it says here here's a listing of everything in this directory and all the corresponding directories so directories plural pretty pretty simplistic moving back here's admin this should elevate your current prompt into an administrator prompt another Alias we have is Su and sudo these basically just relaunch into uh run the admin command or the admin function up here that relaunches Powershell as admin edit profile this actually just grabs and edits the actual profile command this is this file that we're actually looking at and then we get into some fun variables now I've been using a lot of them and or actually I've been using neovim a lot lately so I always have been typing vim and I just made an alias to switch that to neovim when I type them I did a function LL now in Linux Nix systems this usually means long listing there is no real long listing command in Windows because everything's a long list by default so when we're in over here and we do LS that's a long listing there's no such thing as a short listing but if we do an LL you'll notice it's basically excluding all the folders so I still have this command mainly because I love LL from from Linux I'm so used to typing it I wanted to Alias it to something and aliasing it to just show files is a way to utilize that already existing really shorthand that a lot of times I'm just like hey what are the files here I need to grab these files and I don't want to show all the directories LL can be nice for that that's why I made that Alias but otherwise just LS is what you want to do or a dir just to show that and we've already done dris which does it uh recursively and then we have some more personal preference these are things you want to change if you're going to use this profile G basically just CDs over into home GitHub so anytime I type G it'll go ahead and throw it over to my GitHub directory and then I have some really basic commands most people will also want to change these as these are just basic commits and also commits and pushes in GitHub if you if you're into using GitHub from the command line which most people are we have get public ID IP this just grabs our external IP uptime also very good reload profile is nice for just reloading profiles I A lot of times I'll be making changes in my Powershell profile and you probably will too uh a Reload Dash profile makes it so I don't have to quit out relaunch and all that business find file this is nice because the find file feature in Windows is there and you can actually see it right here which is a basic LS we're doing a recursive so it's grabbing everything that's in the current directory and any subdirectory it's filtering it by the name from the find file and then it just silent continues so you don't get a bunch of error messages in there and then it places it all here and Echoes it out so it makes it very easy to search for something uh let's go ahead and just show you an example so let's say I wanted to find everything that was Edge in here so let's go find file Edge and then it would spit out oh okay we have edge.bat in our root directory here we have Edge underscore removal you notice it's not case sensitive by by default because most people sometimes I don't know if it's case sensitive just give me everything and then you can see it's also in the win util directory that's local to this one as well so you can see all these files it makes fine finding files in Powershell much more useful a lot faster than using like let's say windows search from Windows Explorer that does this long spooling and hits Windows indexer this doesn't do any of that it's it's very very quick unzip I actually changed this Alias up from what was here I like to just unzip whatever it was in the current directory so it wouldn't even prompt you for anything it just says hey grab that zip file unpack it directly in the directory it's in so as long as you understand that syntax you're just going unzip this ZIP and it'll just spit out whatever is in that zip directly in the directory you're in I grabbed is used a lot so this one it still requires two variables what that looks like is you would grab a command and then only spit out let's say save files in the current uh LS so let's say just send save files here so let's grab save and then dot for the current directory and then it reps saved games which is kind of nice it actually read some kind of save right here inside of a file as well so pretty powerful stuff I love grep it's a little bit different than find file because it's actually reading inside files as well touch this is a good way to just plus a blank file somewhere let's say you need a blank file in a directory you would just touch it same thing from Linux DF this is disk free in the Linux realm it's using git volume in Windows said this is a finder to replace export this actually just sets a variable uh P kill P kill is actually a really good one that you will use if you're in in here let's say you wanted to kill this Brave process you could go P kill Brave and you see Brave is no longer running it's a very very easy way to kill a bunch of processes and it does it very quickly much much better than trying to use like so say task manager in pgrep this sees if that uh process is running so pre P graph Brave okay well there's no Brave process but let's open it up again uh yeah whatever block and then let's run Peak oh look at that we see it is running quite a few processes now but if we do a p kill you'll see down here in the bottom right bottom left bam it's just gone again and now if you pre-grip it you'll see it's gone so use those commands in Junction with each other much better than you know trying to find something in Powershell or if you have a stuck command to make everything look pretty on our Powershell prompt I'm using oh my Posh which is like oh my zsh from the Linux realm or or macro uh oh my Posh basically themes out are entire prompt so this makes things so much better so much easier let's load up our Powershell profile from GitHub there's a setup.ps1 right here and what I'm doing is grabbing the profile from this repository I encourage you to Fork it make it your own uh but basically we're just outputting this profile into our current profile this what this setup script does but there's only one extra thing you need to do and it's this Cove font this nerd font now you can do this All manually by going through the web I encourage you just use the script because well it's Powershell it's CLI it's going to make your life a little easier once you understand all these things and if you hit downloads I'm using the Cove script which is actually right here Cascadia Cove I butchered that I'm sure but basically we're downloading and installing those fonts so when we go into our Powershell prompt let's come over into GitHub and we'll just go in Powershell profile because I've cloned this entire GitHub repository uh let's see what listing you can see we already downloaded this cove.exe and extracted all these ttf files those are all font files but let's say we wanted to remove star.ttf and we want to remove cove.zip let's do a listing again you can see we only have these files so if we run setup.ps1 it's installing oh my posh grabbing that co-font putting it all here and if we do a listing now you can see the Cove uh zip files there so we could just do unzip Cove and then do a listing again and now we have all those fonts there and we could install them directly uh easiest way to get to your current directory Explorer which is the file explorer we're using and then dot which means the current directory and then you could do it manually from Explorer and just go install so this kind of uses uh a combination of the two by leveraging the command line with the graphic user interface in Windows you can really do a lot more stuff with your system and you're less trapped so when something's missing from the GUI you can jump to the the CLI or if you're more comfortable with the CLI you can make things a lot better because you're just moving directly into where you need to be running all those commands and then getting out so use them in tandem it's very important to understand Powershell I think if you're a Windows user and you want to get the most from your computer uh using a lot of these Powershell commands learning Powershell and getting comfortable with it is vital and making it first not look like crap is another thing so if you're interested in a little more of an explainer I also made a web article go check it out on Chris titus.com and with that I'll see you in the next one
Info
Channel: Chris Titus Tech
Views: 118,703
Rating: undefined out of 5
Keywords: chris titus tech
Id: LuAipOW8BNQ
Channel Id: undefined
Length: 13min 13sec (793 seconds)
Published: Mon Oct 31 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.