Enable Bash-Style History Search and Suggestions in PowerShell

Enable Bash-Style History Search and Suggestions in PowerShell

PowerShell can behave just like Bash with prefix-based history search and inline suggestions. This guide shows how to enable those features in a few simple steps.

St…


This content originally appeared on DEV Community and was authored by John Ajera

Enable Bash-Style History Search and Suggestions in PowerShell

PowerShell can behave just like Bash with prefix-based history search and inline suggestions. This guide shows how to enable those features in a few simple steps.

Step 1: Check Your PowerShell Version

Run:

$PSVersionTable.PSVersion
  • Version 7+ → PSReadLine is already included.
  • Version 5.1 → install PSReadLine in Step 2.

Step 2: Install PSReadLine (Only for 5.1)

Run PowerShell as Administrator:

Install-Module PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

This installs or updates PSReadLine for your user.

Step 3: Open Your Profile File

Create or edit your profile file:

# Show profile path
$PROFILE

# Create profile if missing
if (!(Test-Path $PROFILE)) { New-Item -Path $PROFILE -ItemType File -Force }

# Open profile in Notepad
notepad $PROFILE

Step 4: Add History Search and Suggestions

Paste these lines into your profile:

Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle InlineView
Set-PSReadLineKeyHandler -Key UpArrow   -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

Save and close Notepad.

Step 5: Restart PowerShell

Close and reopen your PowerShell (or VS Code terminal) to apply changes.

Step 6: Test the Functionality

  1. Run some commands, e.g. echo test
  2. Type ec then press → only commands starting with ec will appear.
  3. Inline suggestions will show in gray — accept with or End.

Optional Tweaks

  • Enable list-style suggestions:
Set-PSReadLineOption -PredictionViewStyle ListView
  • Increase history size:
Set-PSReadLineOption -MaximumHistoryCount 10000

Add these lines to your $PROFILE for persistence.

Troubleshooting

Check module and options:

Get-Module PSReadLine
Get-PSReadLineOption

Ensure PredictionSource is set to History. Restart PowerShell if changes don’t take effect.

Conclusion

With these settings, PowerShell behaves much like Bash, letting you quickly recall previous commands using ↑/↓ and see inline suggestions


This content originally appeared on DEV Community and was authored by John Ajera


Print Share Comment Cite Upload Translate Updates
APA

John Ajera | Sciencx (2025-09-21T08:39:51+00:00) Enable Bash-Style History Search and Suggestions in PowerShell. Retrieved from https://www.scien.cx/2025/09/21/enable-bash-style-history-search-and-suggestions-in-powershell/

MLA
" » Enable Bash-Style History Search and Suggestions in PowerShell." John Ajera | Sciencx - Sunday September 21, 2025, https://www.scien.cx/2025/09/21/enable-bash-style-history-search-and-suggestions-in-powershell/
HARVARD
John Ajera | Sciencx Sunday September 21, 2025 » Enable Bash-Style History Search and Suggestions in PowerShell., viewed ,<https://www.scien.cx/2025/09/21/enable-bash-style-history-search-and-suggestions-in-powershell/>
VANCOUVER
John Ajera | Sciencx - » Enable Bash-Style History Search and Suggestions in PowerShell. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/09/21/enable-bash-style-history-search-and-suggestions-in-powershell/
CHICAGO
" » Enable Bash-Style History Search and Suggestions in PowerShell." John Ajera | Sciencx - Accessed . https://www.scien.cx/2025/09/21/enable-bash-style-history-search-and-suggestions-in-powershell/
IEEE
" » Enable Bash-Style History Search and Suggestions in PowerShell." John Ajera | Sciencx [Online]. Available: https://www.scien.cx/2025/09/21/enable-bash-style-history-search-and-suggestions-in-powershell/. [Accessed: ]
rf:citation
» Enable Bash-Style History Search and Suggestions in PowerShell | John Ajera | Sciencx | https://www.scien.cx/2025/09/21/enable-bash-style-history-search-and-suggestions-in-powershell/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.