Améliorez l’apparence et les fonctionnalités de votre terminal PowerShell sous Windows avec une police adaptée, Oh My Posh pour le prompt, et PSReadLine pour un historique beaucoup plus efficace.

Police de caractères
Microsoft Cascadia Code sous Windows, notamment dans VS Code et le Terminal.
- Installer la police
https://github.com/microsoft/cascadia-code/releases
- Variants: Cascadia Code (ligatures), Cascadia Mono (sans ligatures), Cascadia Code PL (glyphes Powerline).
- VS Code (éditeur)
- Fichier > Préférences > Paramètres > “Font Family” = Cascadia Code
- Activer “Font Ligatures”
- Ou via settings.json:
{
// ...existing code...
"editor.fontFamily": "Cascadia Code, Consolas, 'Courier New', monospace",
"editor.fontLigatures": true
// ...existing code...
}
- VS Code (terminal intégré)
- Paramètre:
{
// ...existing code...
"terminal.integrated.fontFamily": "Cascadia Code PL"
// ...existing code...
}
- Windows Terminal
- Paramètres > Profiles > Defaults > Appearance > Font face: “Cascadia Code PL” (ou “Cascadia Code”/“Cascadia Mono” selon besoin).
- Visual Studio
- Tools > Options > Environment > Fonts and Colors > Text Editor > Font: “Cascadia Code NF”.
Note: relancer les applications après l’installation de la police.
Terminal avec Oh My Posh
- Installer
- Oh My Posh:
winget install JanDeDobbeleer.OhMyPosh -s winget
- Police Nerd Font (pour les icônes). Recommandé: CaskaydiaCove (Cascadia patchée):
winget install NerdFonts.CaskaydiaCove
- Définir la police dans vos terminaux
- VS Code (terminal intégré) dans settings.json:
{
// ...existing code...
"terminal.integrated.fontFamily": "CaskaydiaCove Nerd Font"
// ...existing code...
}
- Windows Terminal: Paramètres > Profiles > Defaults > Appearance > Font face = “CaskaydiaCove Nerd Font”.
- Initialiser dans PowerShell
- Créer/ouvrir le profil:
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
notepad $PROFILE
- Ajouter cette ligne puis enregistrer:
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression
- Tester et changer de thème
- Lister les thèmes:
Get-ChildItem $env:POSH_THEMES_PATH
5. Mise à jour
```powershell
winget upgrade JanDeDobbeleer.OhMyPosh
Historique du terminal avec PSReadLine
Après l’apparence du terminal, PSReadLine permet d’améliorer fortement le confort d’utilisation : édition de ligne, autocomplétion, prédictions et recherche d’historique.
- Installer ou mettre à jour (PowerShell 5+ ou 7+)
Install-Module PSReadLine -Scope CurrentUser -Force
- Raccourcis utiles au quotidien
- Tab : menu de complétion.
- Flèche droite : accepter la prédiction.
- Alt+F : accepter le prochain mot suggéré.
- Taper un préfixe puis ↑/↓ : recherche d’historique par préfixe.
- Ctrl+R : recherche incrémentale dans l’historique.
- Configuration conseillée dans
$PROFILE
Ouvrir/éditer le profil :
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
notepad $PROFILE
Puis ajouter (et redémarrer le terminal) :
Import-Module PSReadLine
Set-PSReadLineOption -EditMode Windows
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -BellStyle None
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key RightArrow -Function AcceptSuggestion
Set-PSReadLineKeyHandler -Key "Alt+f" -Function AcceptNextSuggestionWord
- Optionnel : prédicteur Azure
Install-Module Az.Tools.Predictor -Scope CurrentUser
Import-Module Az.Tools.Predictor
Enable-AzPredictor -AllSession
- Diagnostic rapide
Get-PSReadLineOption
Get-PSReadLineKeyHandler | Out-Host -Paging
En combinant une police adaptée, Oh My Posh pour un prompt riche et PSReadLine pour l’édition et l’historique, votre terminal PowerShell devient un véritable outil de travail confortable et efficace.
- Diagnostic
Get-PSReadLineOption
Get-PSReadLineKeyHandler | Out-Host -Paging