This guide covers installing essential PowerShell modules and configuring your PowerShell environment for an enhanced command-line experience.
Set Execution Policy
PowerShell’s execution policy must be set to allow script execution. This is required for running your profile and modules.
Check current execution policy
Get-ExecutionPolicy -Scope CurrentUser
Set execution policy to RemoteSigned
This allows local scripts to run while requiring signed remote scripts:Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Verify the change
Get-ExecutionPolicy -Scope CurrentUser
Should output: RemoteSigned
The RemoteSigned policy allows you to run scripts you’ve written locally while protecting against unsigned scripts from the internet.
Install PowerShell Modules
Install PSReadLine
PSReadLine provides enhanced command-line editing with features like syntax highlighting and history search.Install-Module -Name PSReadLine -Force -SkipPublisherCheck
PSReadLine is usually pre-installed, but updating to the latest version ensures you have all recent features.
Install PSFzf
PSFzf integrates the fzf fuzzy finder with PowerShell for interactive history and file search.Install-Module -Name PSFzf -Force
See the PSFzf GitHub repository for more details. Install Terminal-Icons
Terminal-Icons adds file and folder icons to your terminal directory listings.Install-Module -Name Terminal-Icons -Force
See the Terminal-Icons installation guide for more information.
Verify Module Installation
Check that all modules are installed correctly:
# List installed modules
$modules = @('PSReadLine', 'PSFzf', 'Terminal-Icons')
foreach ($module in $modules) {
if (Get-Module -ListAvailable -Name $module) {
Write-Host "[OK] $module" -ForegroundColor Green
} else {
Write-Host "[MISSING] $module" -ForegroundColor Red
}
}
Create PowerShell configuration directory
New-Item -ItemType Directory -Path "$HOME\.config\powershell\conf.d" -Force
New-Item -ItemType Directory -Path "$HOME\.config\powershell\functions" -Force
Set up PowerShell profile path
Create or edit your PowerShell profile to load custom configurations:# Create profile if it doesn't exist
New-Item -Path $PROFILE -ItemType File -Force
Open the profile for editing: Add profile configuration loader
Add the following to your $PROFILE file:# Load user configuration from .config/powershell
. $env:USERPROFILE\.config\powershell\user_profile.ps1
This approach keeps your configuration modular and organized in the .config directory, similar to Unix-like systems.
PSReadLine enhances your command-line editing experience with history search and predictive IntelliSense.
Create a configuration file at $HOME\.config\powershell\conf.d\00-init.ps1:
# PSReadLine Configuration
if (Get-Module -ListAvailable -Name PSReadLine) {
Import-Module PSReadLine
# History search with arrow keys
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
# Predictive IntelliSense
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Set-PSReadLineOption -PredictionViewStyle ListView
# Better history
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -MaximumHistoryCount 10000
# Colors for predictions
Set-PSReadLineOption -Colors @{
Prediction = '#505050'
InlinePrediction = '#505050'
}
}
With these settings, you can start typing a command and use the Up/Down arrows to search through your history for matching commands.
Enable Terminal-Icons in your configuration:
# Terminal Icons Configuration
if (Get-Module -ListAvailable -Name Terminal-Icons) {
Import-Module Terminal-Icons
}
Add this to your $HOME\.config\powershell\conf.d\00-init.ps1 file.
Set up PSFzf for fuzzy finding integration:
Create or add to $HOME\.config\powershell\conf.d\30-tools.ps1:
# PSFzf Integration
if (Get-Module -ListAvailable -Name PSFzf) {
Import-Module PSFzf
# Set keybindings
# Ctrl+T: File picker
# Ctrl+R: History search
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'
# Enable Alt+C for directory navigation
Set-PSReadLineKeyHandler -Key Alt+c -ScriptBlock {
$result = fd --type d --hidden --follow --exclude .git | fzf
if ($result) {
Set-Location $result
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
}
}
}
PSFzf provides keyboard shortcuts:
Ctrl+R: Search command history
Ctrl+T: Search files in current directory
Alt+C: Change to a directory using fuzzy search
Test Your Configuration
Reload your PowerShell profile
Or simply restart PowerShell. Test PSReadLine history search
Type a partial command and press the Up arrow. You should see matching commands from your history.
Test PSFzf keybindings
- Press
Ctrl+R to open fuzzy history search
- Press
Ctrl+T to open fuzzy file finder
- Press
Alt+C to open fuzzy directory navigator
Test Terminal-Icons
# List files - you should see icons next to file names
Get-ChildItem
Verify Complete Installation
Run a comprehensive verification:
# Check execution policy
Write-Host "Execution Policy: " -NoNewline
Get-ExecutionPolicy -Scope CurrentUser
# Check modules
Write-Host "`nPowerShell Modules:" -ForegroundColor Cyan
$modules = @('PSReadLine', 'PSFzf', 'Terminal-Icons')
foreach ($module in $modules) {
$version = (Get-Module -ListAvailable -Name $module | Select-Object -First 1).Version
if ($version) {
Write-Host " [OK] $module (v$version)" -ForegroundColor Green
} else {
Write-Host " [MISSING] $module" -ForegroundColor Red
}
}
# Check profile exists
Write-Host "`nProfile Configuration:" -ForegroundColor Cyan
if (Test-Path $PROFILE) {
Write-Host " [OK] Profile exists at: $PROFILE" -ForegroundColor Green
} else {
Write-Host " [WARNING] Profile not found" -ForegroundColor Yellow
}
Troubleshooting
PSFzf Not Working
If PSFzf keybindings don’t work:
# Ensure fzf and fd are installed
Get-Command fzf, fd
# Reinstall PSFzf
Install-Module PSFzf -Force
# Restart PowerShell
Icons Not Displaying
If Terminal-Icons aren’t showing:
- Ensure you’re using a Nerd Font in your terminal
- Configure your terminal (WezTerm, Windows Terminal, etc.) to use JetBrainsMono Nerd Font
- Restart your terminal after changing fonts
Scripts Not Running
If you see “running scripts is disabled” errors:
# Check execution policy
Get-ExecutionPolicy -List
# Set for current user (doesn't require admin)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Next Steps
Your PowerShell environment is now configured with enhanced editing, history search, and visual improvements: