On this publish i’ll stroll by means of the method of how i setup my PowerShell growth environement on a Home windows PC. This information has been made on a Home windows 11 PC, so in case you are operating Home windows 10, you may expertise that a number of the utility or instruments, should be put in a unique means.
On this tutorial i’ll present how one can setup the 2 package deal managers Scoop and Chocolatey, I’ll present you to make use of the package deal managers to put in instruments like: vscode, git and neovim. I will even present how one can setup WSL2, Docker Desktop and neovim for enhancing PowerShell scripts within the Terminal.
Stipulations
- Home windows 11 PC
- Connection to the web
Putting in the Chocolatey and Scoop package deal Managers
I attempt to set up as many instruments and purposes as attainable by means of one of many two package deal managers. The explanation for this, is that with the package deal supervisor you could have quick access for updating your purposes, and this can be very straightforward in comparison with exit to completely different web sites, discovering the right model, downloading and putting in by means of a GUI.
Putting in Chocolatey
For putting in chocolatey it’s as straightforward as operating a easy PowerShell command.
-
Open a PowerShell terminal as Administrator
-
Run the next command:
|
|
- You now have Chocolatey put in. To confirm this you may run the next command:
output:
Essential factor to know is that everytime you need to set up a package deal with chocolatey you have to to open the PowerShell terminal as Administrator.
Putting in Scoop
For putting in Scoop it’s simply so simple as putting in Chocolatey, and will be carried out with a single command
-
Open a PowerShell terminal as Administrator
-
Run the next command:
|
|
- You now have Scoop put in. To confirm this you may run the next command:
output:
|
|
Essential to know is that in case you are putting in packages with scoop, you could typically want to make use of a PowerShell terminal in Administrator context, and typically in Consumer context. I often begin by making an attempt with a non-administrator PowerShell terminal.
Now you may want so as to add Scoop to your Surroundings Variable Path, earlier than you may actualy use the package deal supervisor.
Updating the Home windows Terminal
Relying on which construct you might be on, you may have to replace your Home windows Terminal utility to a more recent model, to get some newer options. In my case i wanted to replace the appliance.
Now you may both fully uninstall the appliance after which set up it by means of Chocolatey by operating the command:
|
|
You too can simply replace the appliance by means of the Microsoft Retailer. You do that by opening the Retailer, seek for “Home windows Terminal” and click on on “Replace”.
Putting in Home windows Subsystem for Linux
I exploit Home windows Subsystem for Linux quiet a bit, for growing PowerShell 7 scripts for Linux or completely different purposes resembling Python.
To put in WSL2 open a PowerShell terminal as administrator and enter the command:
The putting in will take a few minutes and as soon as carried out, you have to to restart the pc.
Now as default WSL2 will set up Ubuntu on you system. So as soon as your laptop has restarted you can be prompted to finish the setup of you Ubuntu occasion.
To finish the ubuntu setup you have to to pick out a Username and Password for the person.
I all the time run a whole replace of the Ubuntu occasion with the command:
|
|
Putting in Packages
I all the time set up the next packages:
Package deal | Description | Package deal Supervisor |
---|---|---|
VSCode | IDE for writing code | Chocolatey |
git | Supply Management utility | Chocolatey |
Docker Desktop | Container runtime, and administration utility | Chocolatey |
Picpick | Screenshot instrument | Chocolatey |
Neovim | Terminal textual content editor | Scoop |
Fuzzy | Terminal Search instrument | Scoop |
Curl | Terminal http instrument | Scoop |
Sudo | Terminal instrument for administrator elevation | Scoop |
Jq | Terminal json parsing instrument | Scoop |
Putting in the Chocolatey Packages:
|
|
Putting in the Scoop Packages:
|
|
Putting in PowerShell 7
You possibly can set up PowerShell 7 in two alternative ways. You possibly can both set up it by means of the MSI supplied by Microsoft on their web site, or you may set up it by means of Chocolatey
Putting in by means of Chocolatey:
|
|
Putting in by means of Microsoft supplied MSI:
Hyperlink to Microsoft Docs – Putting in PowerShell 7
Each methods present PowerShell 7 model 7.2.3 on the time of penning this publish. However should you needed to run with PowerShell preview you can set up it by means of Chocolatey by operating the command:
|
|
Now i might often check out a preview model in a Docker container, after which operating a secure model on my system.
Putting in a Nerd Font
To have the ability to use oh-my-posh and Terminal-Icons within the terminal, which I’ll present within the subsequent step, you have to to put in a Nerd Font and set it up in Home windows Terminal. The explanation for that is {that a} Nerd Font is ready to show icons within the terminal, which an everyday font just isn’t.
First you have to to obtain a Font, and also you do that by going to Nerd Fonts downloads web page after which deciding on a font you want. I often go together with Hack Nerd Font.
As soon as the fonts are downloaded, you have to to extract the content material. Then within the extracted folde, choose all of the recordsdata. Proper click on after which choose ‘Set up’. This may set up the font to your system.
All you’ll want to do now’s to pick out the font as default in your Home windows terminal. You do that by opening Settings, and below “Profiles” choose “Defaults”. Then below “Extra settings” choose “Look”, and below “Font face” now you can choose the font you downloaded.
Organising my PowerShell Terminal
I’ve my PowerShell terminal setup with some particular instruments which helps me when working in git repositories, and with some instruments for straightforward navigation within the terminal.
First i might want to set up a instrument named oh-my-posh. This instrument is used for displaying completely different data in terminal, resembling which listing you might be in, and standing of your git repository.
To put in oh-my-posh run the command:
|
|
Then I’ll set up the next PowerShell modules:
- ‘Terminal-Icons’ – (used for displaying icons within the terminal resembling directories and recordsdata)
- ‘Z’ – (This module is a listing navigation instrument)
- ‘PSFzf’ – (Listing Navigation and file looking instrument for the terminal)
- ‘PSReadLine’ – (Instrument for offering autosuggestion and completion within the terminal primarily based on historical past)
Set up the modules by operating the instructions:
|
|
The very last thing i’ll do is to configure my PowerShell profile. I solely run some easy factor within the profile, resembling importing modules, initializing oh-my-post and setting som aliases.
to create a PowerShell profile run the command:
Then add the next to the .ps1 script
|
|
Save the file, and in your powershell terminal you have to to re-initialize the PowerShell profile
Configuring VSCode
I’ve a really fundamental setup for my vscode. I solely set up a handfull of extensions after which i set some customized hotkeys, for switching between the editor and the terminal.
Putting in vscode extension
For putting in the extensions i’ve created a quite simple script which runs by means of an array of extensions and installs them. You possibly can edit the array as you want, after which simply run the script.
|
|
Configuring vscode hotkeys
To configure the hotkeys, open vscode, pres ctrl+shift+p to open the command pallet. Then seek for ‘Shortcuts’ and open the ‘Preferences: Open Keyboard Shortcuts (JSON)’.
Then add the next traces between ‘[]’
|
|
These hotkeys can help you change between the editor and the terminal with the hotkeys: ‘alt+proper’ and ‘alt+left’
Configuring Neovim
I exploit Neovim queit usually, since i’m utilizing the terminal for just about every little thing which need to do with navigation in Home windows, and sometimes i might want to edit a single line in a script of config file. As an alternative of getting to open a vscode editor it’s often simpler and faster to only open til file inside Neovim.
Neovim comes fairly commonplace which could not be the best approach to edit PowerShell scripts with.
First you have to to creat the init.vim config file. This file is the place all of the configs for the editor is positioned.
Create the next recordsdata:
|
|
Then run the next command to put in vimplug:
|
|
Then open the file: init.vim in vscode and add the next settings:
|
|
Now you have to to put in the completely different plugins for PowerShell syntax highlighting and code completion. To do that open Neovim by coming into ‘vim’ within the terminal.
Then press ‘:’ and write PlugInstall
This may set up all of the wanted plugins.
The one factor left to do is to create a brand new file for disabling the built-in terminal in Neovim.
open a brand new vim editor and write
:CocConfig
Then add the next to the file:
|
|
It’s best to now have a working Neovim setup for enhancing and writing Powershell code
On this ending part i’ll simply shortly stroll over how one can use a number of the instruments or how one can look
The Oh-My-Posh module and the Terminal Icons Instrument
Utilizing the PSReadLine
The configs for the PSReadline is ready to make use of the PowerShell command historical past to autosuggest attainable instructions:
Utilizing the Module Z
The Module Z is a fast listing Navigation instrument.
Use the next command to see attainable directoris:
The go to a listing by including a phrase from one of many directories after a ‘z’:
Utilizing Fuzzy Finder
Use ‘Ctrl+r’ to navigate by means of your powershell historical past. In the event you kind one thing the listing will slender to the particular textual content.
Use ‘Ctrl+f’ to look by means of your present listing