Something you have to face every day, and if it doesn't look good, it can affect your mood 🐶. (Finally going to finish the overdue blog posts, the diarrhea-style updates are ending.)
This post was translated from my Chinese blog post with the aid of ChatGpt.
Many of the methods I found were outdated, so in the end, I simply followedthe official documentation of Oh My Poshto configure it.
First, use the
$PSVersionTable command to check the PowerShell version. The system comes with version 5.1, while the latest version is 7.2. These two versions are independent and can be installed simultaneously. Here, I installed the new version.
After installing, open
Windows Terminal and go to
Settings. Change the
default profile to
PowerShell (the system’s built-in version is called Windows PowerShell).
When selecting a font, choose one that includes
Nerd fonts, otherwise, some icons may appear as gibberish. I used the font
sarasa-mono-sc-nerd-font, which is the
Simplified Chinese mono-spaced Sarasa Gothic font with additional Nerd font characters. Here is the download link, and I downloaded the
Nerd Fonts is a project that addresses the issue of programmers lacking suitable fonts during development by using a plethora of font icons. It can incorporate a wide range of external fonts from popular font icon libraries into the project at hand. The supported font icon libraries include Font Awesome, Devicons, Octicons, and more.
"Sarasa Mono SC Nerd Font" is a free and open-source font that combines elements from Iosevka and Source Han Sans. It's designed for optimal usage within terminal environments.
After downloading, extract and install the required font. The meanings of font suffixes are as follows:
unhinted- Unhinted font
ttf- TrueType font file format
ttc- TrueType font collection file format (Sarasa Mono SC categorizes fonts by weight, merging similar ttf font files)
gothic- Full-width quotation marks
ui- Narrow-width quotation marks
mono- Full-width dashes
term- Half-width dashes
fixed- Non-ligature and half-width dashes
cl- Classical Chinese character form
sc- Simplified Chinese character form
tc- Traditional Chinese character form
j- Japanese character form
k- Korean character form
hc- Hong Kong character form
slab- Extra bold stroke character form
regular- Regular font
italic- Italic font
extralight- Extra light font
light- Light font
semibold- Semi-bold font
bold- Bold font
extralightitalic- Extra light italic font
lightitalic- Light italic font
semibolditalic- Semi-bold italic font
bolditalic- Bold italic font
nerd- Additional Nerd fonts
Then, in Windows Terminal, navigate to
Font, and set the font to
Sarasa-mono SC Nerd Font.
winget to install the beautification module
Oh My Posh:
winget install JanDeDobbeleer.OhMyPosh -s winget
Then, restart Windows Terminal and open the PowerShell configuration file using the following command:
If it prompts that the configuration file doesn’t exist, use this command to create it:
New-Item –Path $Profile –Type File –Force
Paste and save the following line:
oh-my-posh init pwsh | Invoke-Expression
Execute the following command to reload the configuration file or restart Windows Terminal to see the changes:
Oh My Posh offers many themes. You can use the following command to see available themes or visit the official website for a theme preview:
Once you find a suitable theme, copy the command below for that theme and paste it into your PowerShell configuration file. Replace
"Theme" with the actual theme name:
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/Theme.omp.json" | Invoke-Expression
For example, if you chose the theme
takuya, the command would be:
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/takuya.omp.json" | Invoke-Expression
If you want to modify the theme colors, first export the current theme configuration:
oh-my-posh config export --output ~/.pwshtheme.omp.json
Please change the path yourself, the path I exported here is
C:\Users\Username\.pwshtheme.omp.json, and the theme file is in
C:\Users\Username\AppData\Local\Programs\oh-my-posh\themes.Then, open the exported file and adjust the colors.
If you want to modify more content please refer to the official documentation instructions
After making the modifications, use
notepad $PROFILE to open the configuration file for PowerShell. Replace the original theme configuration with the new one, and pay attention to the file path.
+ oh-my-posh init pwsh --config "~/.pwshtheme.omp.json" | Invoke-Expression
Scoop is a Windows package manager. Use the following command to install Scoop:
Invoke-WebRequest get.scoop.sh | Invoke-Expression
aria2 can enable multi-threaded downloads for Scoop.
scoop install aria2
You can add additional buckets to Scoop. Bucket is a software repository. After installing Scoop, you’ll have the Main bucket, but its inclusion criteria are quite strict. Therefore, it’s advisable to install an “extras bucket,” which can provide more software options, including Steam. However, it’s not recommended to add too many buckets.
The installation command is as follows:
scoop bucket add extras
scoop update—— Update Scoop and the list of software packages.
scoop install -k <app>—— Install a package non-globally (and disable package caching).
scoop install -gk <app>—— Install a package globally (and disable package caching).
scoop uninstall -p <app>—— Uninstall a non-global package (and delete configuration files).
scoop uninstall -gp <app>—— Uninstall a global package (and delete configuration files).
scoop update -k *—— Update all non-global packages (and disable package caching).
scoop update -gk *—— Update all packages (and disable package caching).
scoop cleanup -k *—— Remove all old versions of non-global packages (and delete package caches).
scoop cleanup -gk *—— Remove all old versions of packages (and delete package caches).
scoop cache rm *—— Clear the package cache.
scoop bucket list—— View all buckets.
First, check the script execution policy settings. There are four policy options:
Restricted—— Default setting, doesn’t allow any script to run.
AllSigned—— Only runs scripts that have been digitally signed with a certificate.
RemoteSigned—— Runs local scripts without requiring digital signatures, but scripts downloaded from the internet must be signed.
Unrestricted—— Allows all scripts to run.
If the policy is not
Unrestricted, execute the following command to modify the policy. Otherwise, some modules might not install properly:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
posh-git is a PowerShell module that integrates Git with PowerShell, allowing you to display summarized Git status information in the PowerShell prompt. It also provides
Tab completion for common Git commands, branch names, paths, and more.
PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force
Next, execute the following command to integrate the module:
Alternatively, you can add the following line to your PowerShell configuration file:
Afterward, reload your configuration file or restart Windows Terminal. When you type
git fe and press
Tab, if it automatically completes to
git fetch, then the integration was successful.
PSReadLine 2.1 provides a powerful command-line editing experience for the PowerShell console. It offers the following features:
- Syntax coloring of the command line
- Intuitive indication of syntax errors
- Improved multiline experience for editing and history
- Customizable key bindings
- Cmd and Emacs modes
- Numerous configuration options
- Bash-style completion in Cmd mode (optional, with Emacs mode as the default)
- Emacs yank/kill cycle
- Token-based “word” movement and deletion based on PowerShell tokens
- Predictive IntelliSense
PSReadLine 2.1.0 comes bundled with PowerShell 7.2 and is supported in all the versions of PowerShell that are currently supported. Therefore, there’s no need for additional installation.
First, open the configuration file:
Copy and paste the following content:
Set-PSReadLineOption -PredictionSource History # Set prediction source to history
After saving, either reload the configuration file or restart Windows Terminal.
→—— Autocomplete suggestions
→—— Incremental completion of suggestions
↓—— Search through command history
ZLocation is a variation of Jump-Location that tracks your most frequently used directories based on the number of times you’ve navigated to them. After a short learning phase,
z will take you to the most popular directories that match all regular expressions given on the command line. You can use Tab-Completion/Intellisense to pick a non-preferred directory.
Use the following command to install and configure ZLocation:
Install-Module ZLocation -Scope CurrentUser; Import-Module ZLocation; Add-Content -Value "`r`n`r`nImport-Module ZLocation`r`n" -Encoding utf8 -Path $PROFILE.CurrentUserAllHosts
z—— Display known folders and their weights
z c:—— Jump to the C drive
z zlo—— Jump to the ZLocation folder (abbreviation)
z -l foo—— List all locations that match “foo”
z -—— Jump to the previous or initial folder that was navigated to
The Fuck is a fun tool that allows you to correct the previous erroneous command by typing
Before installing The Fuck, you need to have
python-dev installed. The installation command is as follows:
pip install thefuck
Open the PowerShell configuration file:
Paste the following content:
Save the file, then reload the configuration file or restart Windows Terminal.
After entering an incorrect command, type
fuck and press
Enter to confirm.
pip3 install thefuck --upgrade
Neofetch is a command-line system information tool written in Bash 3.2+.
Neofetch can display information about your PC’s operating system, software, and hardware.
scoop install neofetch
Afterwards, simply type
neofetch and press Enter to view your system information.
gsudo is a Windows alternative to
sudo that offers a user experience similar to the original Unix-like
sudo. It allows you to run commands with elevated privileges in the current console window, a new window, or elevate the current shell’s permissions. This eliminates the need to repeatedly run PowerShell as an administrator and avoids losing the command history when restarting.
You can install gsudo using the traditional method with
winget install gsudo
To minimize UAC prompts and achieve multiple gsudo elevations with only one UAC prompt, you can enable credential caching. Use the following command:
gsudo config CacheMode auto
The following settings can be applied specifically to PowerShell or adjusted as default settings for all shells by going to
Settings - Profiles - Defaults.
You’ve adjusted the theme for PowerShell, but the font colors for input and output are still the original ones, controlled by Windows Terminal’s
Color Scheme. There are 8 default color schemes, though they might not be the most pleasing to the eye. Fortunately, you can create your own color scheme.
Open Windows Terminal’s
Settings, navigate to
Color Scheme, click on Add a new color scheme on the right, create your own color scheme, and then adjust the colors one by one. Once done, click
Then go to the PowerShell configuration file below, find
Appearance - Color Scheme, and set it to the color scheme you just created.
In Windows Terminal’s Settings, find
Show acrylic in tab row (requires relaunch) and enable it. After restarting Windows Terminal, you’ll see the tab row with the acrylic effect enabled.
Then go to the PowerShell configuration file below, find
Appearance - Transparency - Enable acrylic and enable it. This will apply the acrylic effect to the window background. You can fine-tune the transparency according to your preference; I set it to 85%.
Still in the PowerShell configuration file, find
Appearance - Background image - Background image path. Choose a background image and adjust the
Background image opacity.
After all these configurations, your PowerShell in Windows Terminal should look much better and more functional.