How to set up an awesome prompt with your Git Branch, Windows Terminal, PowerShell, + Cascadia Code!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I've been doing a number of YouTube videos on git and I plan on doing more but a few people have commented on my prompt I've got a prompt that looks like this in my powershell on windows it's kind of cool it's using a thing called power line fonts along with posh git and oh my posh these are all things that will make your PowerShell feel very comfortable and nice especially if you are a get user because you'll get nice things like this no pun intended but folks have been saying that they've been challenged in getting that stuff set up so I thought I would take a moment and we'll do it from scratch that way that you don't get lost now the TLDR is go out there and Google for Hanselman pretty prompt I've got a blog post that sets you up on that you can also look at the documentation there is one called setting up power line in Windows terminal you can find that at the Microsoft Doc's so what we're gonna do is we're going to follow those but we're going to talk about the issues that you might have and the things that you might bump into while you do that now I'm gonna be using PowerShell but you could also use PowerShell core now if you go and go to the Start menu and just run PowerShell you might get something that looks like this I'm using ctrl scroll I'm holding down the control button and scrolling to make the fonts bigger but I would recommend that you get the windows terminal you can get the windows terminal by searching for terminal in the Windows Store or you can go and Google for Windows terminal and you will get either a blog post about the Windows terminal or you can find the github on the Microsoft Windows terminal and there will include a releases page there's lots of different ways for you to get the terminal but I would encourage you to use it and get it from the windows the Microsoft Windows Store because it gets automatically updated all the time ok so step one get the windows terminal that will be different than PowerShell that's important to point that out if I run the Windows terminal it looks like this terminal is not a shell I have lots of shells including the original command prompt in Windows I have PowerShell core I'm using Windows PowerShell as well as Ubuntu and other things that we'll talk about in other videos but I'm just pointing out that the terminal gives you the tabs gives you copy/paste it gives you new fonts it doesn't have anything to do with PowerShell PowerShell is one of the shells you can use within the terminal so step one get the Windows terminal step two we're using PowerShell this is the default PowerShell prompt you can see it shows my path it's not really interesting or fun nothing interesting going on there so what you want to do is get a power line compatible font okay and in order to do that you're gonna want to go and get I recommend Cascadia code Cascadia code can be downloaded also parts of it come with the windows terminal but we want a very specific version of it I'm going to open up this zip file here and inside the zip file are gonna be a couple of different kinds of fonts the ones we care about are the PL fonts there's Cascadia code PL and Cascadia mono PL Cascadia mono will not by its fault by default include the power line fonts that we want so what you're going to want to do then is go to your windows and type c colon windows and the folder is called fonts and what you can do is you can take out the fonts that you want out of that zip file you might need to unzip that first so I'm going to unzip it by right dragging and using the right mouse mouse button and I'm going to say extract gonna drop that right into this location here show extracted files when complete here they are alright I'm gonna grab some fonts Cascadia mono you can also right-click on them and say install I'm getting a prompt here it's installing those fonts okay and now they're there and you can confirm that the fonts you want are there if you see them and they say pl they've got to say PL otherwise you won't have the glyphs the power line glyphs that you want so step one get the Windows terminal step to get the power line get a power line font now if I click here in the Windows terminal and go to settings I can change my font I'm gonna leave it like this for a second because I'm gonna cause a bug that I want you to see and then we'll fix that bug by changing the font following the instructions the next thing we're gonna do is install two modules one called posh get that helps you with your get prompt and one called oh my posh that sets up your prompt very nicely so then if we try to run these we'll see if we get any errors I'm gonna install this module posh get you're going to want to say yes to any prompts that happen here you're seeing you're installing from an untrusted repository you're gonna as long as it's the PS gallery it's probably okay I'm gonna say yes or yes to all okay installing those modules puts them on your machine but they don't set things up in actual PowerShell to be used they are not imported they're simply installed now if you're using PowerShell core there's one additional line now it says in your PowerShell profile add these lines to the end of the file okay what I typically recommend people do is they type notepad dollar sign profile that can be a little confusing I'm just gonna point out if you say echo profile it's gonna give you a path that path is where your PowerShell profile either is or should be so what I'm gonna do is I'm going to use my mouse I'm gonna select the path right up to here then I can either right-click or I can hit control C I'm going to type start pasted enter okay and now I'm in that location there's a profile here you may not have one okay so if I said notepad profile you may see something or you may not it may be empty you may get a warning and says this doesn't exist you need to make that file or let notepad make that file if it doesn't already exist then we're just gonna copy these three lines into our notepad and hit save all right I'm going to close that that is now in this file now I'm going to open up another tab here and you notice I'm getting an error the error is I can't run this script the script cannot be loaded because running scripts is disabled that's a big scary error what you can do is you can go and run PowerShell or run the Windows terminal as administrator so that would mean going here typing PowerShell and then clicking run as administrator or right-clicking and saying run as administrator you get that prompt and then you can say set - execution policy and then there's some choices here signed means digitally signed unfortunately the easiest thing to do to get past this is to say unrestricted when you're doing that though you're basically saying that it's okay for you to run any kind of scripts at all if your IT department doesn't allow you to do that you can then to switch it to signed and then go off and Google how to run signed powershell scripts but we're basically saying it's okay to run ps1 files or powershell scripts that will allow us to run the profile that we just wrote now when I run the prompt look at that I'm getting stuff I'm getting this little prompt you know you got it right if you get this prompt now notice I'm a little surprised actually that this is showing correctly because I thought the font would be wrong it looks like if I say settings on my machine I had set this is the settings for your terminal I had set under defaults font face Cascadia code PL I'm going to change that to just Cascadia code look what happens right here if you see these squares that means you're using a font that doesn't have the power line glyphs okay so let's see what that looks like again I'm going to close vias code I click here I click settings I'm now inside Visual Studio code or notepad or whatever it doesn't matter and this is your settings Jason for your terminal the best way to get things working for everyone for everything is to make a section after profiles called defaults it should look like this okay and I'm just going to change Cascadia co2 Cascadia code PL for power line this is the section that you need I'm going to hit save now if you want you can go and find PowerShell down in here and manually add the font here so for example I've said it to Cascadia ma no just for PowerShell and you see that the squares look they are there if I get rid of that line and hit save we're back to the correct glyphs because the default uses power line and you don't have to use Cusco dia code you can use any power line font if it makes you happy but that's the easiest one and it's also included with terminal and it's always updated so you can go get a fresh one up on github now I'll go into a git folder to see if it actually works and it does that is that relationship between posh git and oh my posh again if I go back to notepad and look at this we have a couple things going on here posh get giving us functions in order to ask questions of our current get all my pause setting up this lovely prompt here and then set theme paradox that's an interesting one well we can actually go and dig in if we want to and download different themes in fact if we search for oh my posh themes this prompt theming engine that we're using has lots of other themes that you can use so you can go through this and try other ones if they make you happy it doesn't have to look like mine now if I get a complaint here where it says this prompt doesn't exist it's telling me the path that it should be so I can go and copy that into the clipboard hit start paste it in and then look I can see the choices there we go I've got a number of themes here maybe I spelled that one wrong that bunch of choices for themes looks like that one's not working well so I learned something there myself because I tried a theme and I didn't get what I wanted but of course I can change those things the ones that I like to use is called paradox and all right now I've got that theme these things are all changeable okay so that's how you get a cool prompt let's go ahead and review I'll just make a little notepad here so we can talk about that get the windows terminal from the store get a power line font I like Cascadia code PL make sure it's installed then edit your settings dot Jason in the terminal set a default section let's look at what that looks like okay looks nice and then set a theme I like paradox there's lots of themes that are included with oh my gosh alright and then add these lines to your profile and you saw that your profile exists in a certain place and your profile has to [Music] exist notepad profile some people might get an error if your profile doesn't exist that's okay make one put some lines in it set the theme to whatever makes you happy all right again all of these instructions are on my blog and they have now been added to the Microsoft documentation so hopefully that'll get you started on making a cool prompt in in Windows please do subscribe to my channel I'm working very hard to make fun things for you to watch and learn with and if you have any ideas for other videos that I can make please let me know in the comments thanks a lot
Info
Channel: Scott Hanselman
Views: 85,959
Rating: undefined out of 5
Keywords:
Id: lu__oGZVT98
Channel Id: undefined
Length: 15min 22sec (922 seconds)
Published: Sun Jul 05 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.