PowerShell Profile

PowerShell is a bit awkward to begin with. See my YouTube video on how to start learning PowerShell. It walks through the most important commands to know about, hopefully allowing you to kick start your PowerShell career. See below for my simple PowerShell profile and why you should consider yours.

PowerShell Profile

The profile file allows you to customize the behavior of PowerShell upon boot, similar to Linux’s .profile file or .bashrc. Nevertheless, this is about PowerShell, a scripting utility I’ve been trying to learn for the past couple of years.

This file is stored in C:\Users\UserName\Documents\WindowsPowerShell in a file called Profile.ps1. Edit this file and you can make PowerShell automatically run commands when you boot PowerShell. My PowerShell profile is simple, as explained below:

Set-PSReadlineKeyHandler -Key Tab -Function Complete

This command allows the PowerShell terminal tab-completion feature to be very similar to what Linux offers. When I press <tab> or <tab> <tab>, the Windows PowerShell terminal now shows me options, instead of a rotating list of items:

Function Get-History-Full {Get-Content (Get-PSReadlineOption).HistorySavePath}
Set-Alias -name hist -value get-history-full -Option AllScope

With these two commands I get a Linux type history feature. Any time I type the hist command, as created with the set-alias command, I am returned with all my previous commands I have run in PowerShell, not just the last 10 items. I regularly use this when looking for a previous command, e.g. I type “hist | sls ssh” and it shows my all my previous commands pertaining ssh.

Windows Terminal

The Microsoft Store contains a better and improved version of the Windows terminal. This improved terminal allows easy access to a multiple different presets and in general makes life easier. Go download it, experiment with the settings, and sure enough, you will see your Windows command line usage become easier and much more convenient.

It supports tabs, starting up WSL2 instances like a Linux bash shell and much more. Let me know if you want to have a video or blog post on how I have configured my Windows Terminal. It has significantly improved my quality of life while using Windows!


Posted

in

by

Looking to get in touch?