PowerShell
This page covers installing PowerShell 7 and related tools, configuring completion, the prompt, aliases and functions in $PROFILE, and fixing scp failures caused by the profile.
Installation#
Install the following tools with winget.
Install PowerShell 7:
Install Starship:
Install gsudo:
Configuration#
All of the following goes in $PROFILE.
Set up completion and the prompt#
Add Tab menu completion and the Starship prompt to $PROFILE:
Define aliases as functions#
PowerShell aliases cannot take arguments, so la, the git shortcuts and the nr shortcuts are all functions. Built-in aliases take precedence over functions, so remove la, gp (Get-ItemProperty), gl (Get-Location) and ni (New-Item) first, or the functions of the same name are never reached:
-Force also lists hidden and system files.
Add the git and nr functions to $PROFILE:
Functions#
Define the i function in $PROFILE to jump to a directory under $HOME\i:
Runtimes#
Activate mise in $PROFILE:
Troubleshooting#
Profile output breaks scp#
When PowerShell is the OpenSSH DefaultShell, scp and sftp fail with:
The profile is writing to stdout. Check the profile for echo, Write-Output and commands that print warnings, and remove or change them. For example, loading mise completions before activate prints usage CLI not found.
References#
- Guany PowerShell profile: Guany's PowerShell profile repository.