Windows Privacy & Customizing the PowerShell Terminal#
In this article, we’ll explore the steps necessary to customize your PowerShell terminal on Windows. We’ll install various tools and modules to enhance the user experience, including winget
, Windows Terminal, the latest version of PowerShell, oh-my-posh, and some additional modules. Additionally, we’ll integrate Nilesoft Shell and explore possible optimizations using PowerToys.
Here are some screenshots of the final result:
(If you like the wallpaper, you can find it here)
Installing winget and Windows Terminal#
If winget
is not already present on your system, you can install it by following the instructions available on the official Microsoft site. Once winget
is installed, you can install Windows Terminal if you don’t have it by running the following command in PowerShell:
winget install --id Microsoft.WindowsTerminal -e
Installing the Latest Version of PowerShell#
To take advantage of the latest features in PowerShell, we will install the most recent version. Use the following command with winget
:
winget install --id Microsoft.Powershell --source winget
After installation, go to settings and set the default profile to this new version we just installed (a Terminal restart may be necessary):
Don’t forget to save before closing this window.
Installing oh-my-posh and a Compatible Font#
oh-my-posh
is a great tool for customizing your PowerShell prompt. To install it, use winget
:
winget install JanDeDobbeleer.OhMyPosh -s winget
Next, install a compatible font like Hack Nerd
:
oh-my-posh font install
Then choose the one that suits you best (personally I use the “Hack” font).
Configuring the Terminal#
To configure Windows Terminal to use the latest version of PowerShell by default, follow these steps:
To use the downloaded font, go to “Profiles” > “PowerShell” (the one with the dark blue background) > “Appearance” > “Font face” and select Hack Nerd Font Mono
as the font.
Also, I use a custom theme that mixes “mojada” and “blueish” (which you can find here: Github | Oh-my-posh theme), but you can choose any theme you want from Themes | Oh My Posh, or use the command Get-PoshThemes
to test different themes directly from your terminal!
To configure oh-my-posh
with your theme, add the following line to your $profile
file (replace mojada.omp.json
with your theme file name):
oh-my-posh --init --shell pwsh --config "C:\Users\$env:USERNAME\AppData\Local\Programs\oh-my-posh\themes\mojada.omp.json" | Invoke-Expression
If you encounter an error or do not currently have a $profile
file, create a new one with this command:
New-Item -Path $PROFILE -Type File -Force
Bonus - VS Code Terminal Configuration#
Now, we have a terminal configured with style, allowing for good working conditions. However, what about the integrated terminal in VS Code?
Okay, it’s not catastrophic, but not all characters are displayed correctly. To fix this, in the VS Code interface, press Ctrl + Shift + P, then type Preferences JSON
.
Choose Preferences: Open User Settings (JSON)
from the list.
If you don’t have a font explicitly indicated, you need to add these two lines at the end of the JSON file: (Of course, replace the fonts below with the ones you are using!)
"editor.fontFamily": "Consolas, 'Courier New', monospace",
"terminal.integrated.fontFamily": "Hack Nerd Font Mono"
Don’t forget to save, and now the integrated terminal in VS Code no longer has any display issues.
Bonus - WSL & Oh-My-Posh configuration#
I know that Oh-My-Posh is not the best terminal prompt for Linux (when I work on Linux, I personally use ohmyzsh whenever possible), but for better harmonization of my workspace, I use the Linux version of Oh-My-Posh in my WSL. Here is the installation documentation.
If you haven’t used WSL on your PC before or if you have just reinstalled it, I recommend starting by updating it:
wsl --update
Once the update is complete, to list and select a distribution, run:
wsl --list --online
I personally chose to use Debian, which I install with the command:
wsl --install -d Debian
At the first launch, you will be asked to define a username and a root password. Once defined, I recommend running sudo apt update && sudo apt -y upgrade && sudo apt -y full-upgrade
to ensure that our WSL has the latest updates. (The installation of sudo
might be necessary; I also recommend installing wget
, curl
, and unzip
, which can be useful later, as well as ZSH if desired).
Here is what our WSL should look like for now:
So, for installing Oh-My-Posh, I personally prefer the “manual” method:
curl -s https://ohmyposh.dev/install.sh | bash -s
It is also necessary to go into the Terminal application’s settings to specify the font to use for Debian.
To do this, as with PowerShell, go to Settings -> In the left menu, select the name of your WSL (here Debian
), then in Appearance -> modify Font face so that your work environment uses a font compatible with Oh-My-Posh, and then save.
We will create the folder where we will store our theme:
mkdir ~/.poshthemes
Then we will paste our theme JSON into the custom.omp.json
file in this folder using nano, vim, or whatever you like (I will personally reuse the same theme that I use on Windows).
Next, we will use this command to have Oh-My-Posh load our theme:
eval "$(oh-my-posh init bash --config ~/.poshthemes/custom.omp.json)"
If oh-my-posh
is not recognized as a command, restart your terminal, which will refresh the environment variables.
Here is what our terminal now looks like under WSL:
Our theme works well; however, if we relaunch our terminal, we will have to retype this command: eval "$(oh-my-posh init bash --config ~/.poshthemes/custom.omp.json)"
.
To solve this problem, we will modify the configuration of our shell:
For bash:
sudo nano ~/.bashrc
For zsh:
sudo nano ~/.zshrc
and add this line to the end of your file: eval "$(oh-my-posh init bash --config ~/.poshthemes/custom.omp.json)"
, then save and restart your terminal.
Installing Additional Modules#
To enhance the terminal experience, we will install the following modules:
Terminal-Icons
for icons in the terminal.PSReadLine
for a better command line editing experience, including suggestions based on your previous commands.Microsoft.WinGet.CommandNotFound
for command suggestions when an error occurs.
Here is what Terminal look likes before Terminal-Icons installation:
And after installation :
And here is what the Microsoft.WinGet.CommandNotFound module provides:
To install these module, execute the following commands:
Install-Module -Name Terminal-Icons -Repository PSGallery -Force
Install-Module -Name PSReadLine -Repository PSGallery -Force
Install-Module -Name Microsoft.WinGet.CommandNotFound -Repository PSGallery -Force
To make the last one work, you need to enable these features:
Enable-ExperimentalFeature PSFeedbackProvider
Enable-ExperimentalFeature PSCommandNotFoundSuggestion
And to make them work every time you open your terminal, you need to add this to the $profile file:
Import-Module -Name Terminal-Icons
Import-Module -Name PSReadLine
Import-Module Microsoft.WinGet.CommandNotFound
Finally, to configure PSReadLine to get suggestions based on your past commands, add the following configuration to the $profile:
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
For more information on these modules:
Summary of my $profile file :
oh-my-posh --init --shell pwsh --config "C:\Users\$env:USERNAME\AppData\Local\Programs\oh-my-posh\themes\mojada.omp.json" | Invoke-Expression
Import-Module -Name Terminal-Icons
Import-Module -Name PSReadLine
Import-Module Microsoft.WinGet.CommandNotFound
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
You can also find my latest version here : Github | Microsoft.PowerShell_profile.ps1.
Nilesoft Shell Integration#
Nilesoft Shell provides a powerful shell environment that can be integrated with PowerShell for an even more enhanced terminal experience. To install and integrate Nilesoft Shell:
Install Nilesoft Shell with winget:
winget install --id Nilesoft.Shell --source winget
Administrator rights will be requested twice:
- The first time for the installation.
- The second time for registering Nilesoft Shell in Explorer (to make it work with it).
If you right-click on your desktop, you should see something like this:
To change the default theme, shift + right-click on the taskbar, go to Shell, then to Directory.
Ensure that in shell.nss, the theme.nss file is imported. If not, add this line to the file and save it:
import 'imports/theme.nss'
To customize your theme, you can consult the documentation here Nilesoft Documentation. I personally used this video along with ChatGPT to create my custom theme.
Once your theme is complete, you can rename the theme.nss
file in the imports
folder to theme.nss.back
to keep a backup in case of any malfunction. Then, you can create a new blank theme.nss
file and insert your theme into it.
To test your theme, ctrl + right-click on your desktop to refresh the theme used by Nilesoft Shell.
In case of an incompatible theme or modifications, Nilesoft Shell may “deactivate.” To reactivate it, launch Nilesoft Shell as an administrator from the Start menu and click “Register.”
Get your Windows more privacy respectful#
Privacy.sexy is a website that offers several hundred scripts (currently 799) to protect your privacy by disabling intrusive or unnecessary Windows features. (Privacy.sexy has recently launched scripts for Linux and macOS, but that’s not the subject of this article.)
The scripts are categorized as follows:
- Privacy Cleanup
- Disable OS Data Collection
- Configure Programs
- Security Improvements
- Block Tracking Hosts
- Privacy Over Security
- UI For Privacy
- Remove Bloatware
- Advanced Settings
I recommend reviewing the different categories and carefully choosing the features you want to disable to avoid any unpleasant surprises later on. Note that “packs” of scripts can also be pre-selected:
The “standard” preselect can be a good option if you don’t want to spend too much time, provided you are able to address any potential issues that might arise from executing the scripts.
Once the scripts are selected, you can download and execute them as an administrator. However, Windows Defender might prevent you from running the file (as Microsoft doesn’t want us to make too many modifications to its system!). To “patch” this issue, Privacy.sexy recently offered a version to install directly on your PC, providing the same options as the online version Github | Privacy.sexy.
Additionally, I know that many tools of this type exist. I’m not saying that Privacy.sexy is the best, and you are free to use others if you find them more usefull! I also recommend another tool that I occasionally use, O&O ShutUp10++.
I advise re-running the scripts after major Windows updates (e.g., from 23H2 to 24H2) to ensure that certain settings haven’t been reactivated!
Conclusion#
In this article, we’ve explored customization possibilities, covering the “new” Windows Terminal with PowerShell, WSL, VS Code, and also the Windows Explorer UI with Nilesoft Shell. To ensure a more privacy-respectful Windows system, we introduced Privacy.sexy and its scripts to disable intrusive features and recommended regular updates to maintain these settings.
You can find all the themes I used in this article on my Github.