Preview
At the end of this guide your terminal will be like this.
Index
- Installing Windows Terminal (Optional)
- Installing or Updating Powershell
- Installing OhMyZsh for Windows OhMyPosh
- Installing and Configuring Fonts
- Enabling Sudo Command
- Installing module for icons
- Some color personalization for Readline
Installing Windows Terminal
First of all, I recommend you install Windows terminal that could will allow you personalize your terminal even more. You can download it from the microsoft store.
Installing or Updating Powershell
(This is not strictly necessary but i recommend you install it if you can so you wouldnt have problems with any step)
Install the last version of powershell. You can download it from here. Remember that this version is going to replace the powershell 6 if you have installed it. (Does not affect powershell version 5)
Installing OhMyZsh for windows OhMyPosh
You need to use the PowerShell Gallery to install oh-my-posh. (Refered: https://github.com/JanDeDobbeleer/oh-my-posh) You can see the themes available there. But take into account that some themes dont have the same names that appear in the repository.
Install posh-git and oh-my-posh:
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
Enable the prompt:
# Start the default settings
Set-Prompt
# Alternatively set the desired theme:
Set-Theme Agnoster
In case you're running this on PS Core, make sure to also install version 2.0.0-beta1 of PSReadLine
Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
To enable the engine edit your PowerShell profile:
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE
In the file opened copy these lines so next times you open terminal it will load the modules and theme
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
Some Useful Commands:
To see what are your actual settings:
$ThemeSettings
If you want to open the file that define your profile in powershell.
$profile
It gives you the path of your configuration profile path. You can open it with the command notepad or code if you have visual studio code.
notepad $profile
To see what are the names of the available themes:
get-theme
If you want to test some themes temporaly you can use the command:
Set-Theme NameofTheTheme
To see what are the actual colors of your theme:
Show-ThemeColors
To see what are the colors available that you can use:
Show-Colors
Remember that when you choose a theme and want to see it every time you start powersheel you have to define it in your profile file using
notepad $profile
Set-Theme NameOfTheme
Installing and Configuring Fonts
If you dont install the fonts you probably will see something like this:
So, you should install a font that includes glyphs. Two of them are Cascadia Code PL or MeslolGS NF
MesloLGS NF Regular
You can install it with double click
Now, to set the fonts in terminal:
in that configuration file oyu have to add configuration for you default profile or specifically for your powershell 7
Also, If you have want to use that version of powershell and set that font in vscode to use it in the terminal you could do this.
- Pwshell as default shell
Select the version 7 of powershell
- add this lines in settings.json
"terminal.integrated.fontFamily": "MesloLGS NF"
Enabling Sudo Command (Optional)
Also if you want to have the sudo command like in linux you should download an executable and save it in a folder in your pc and then add that folder in your environment variables path. (You can save that file in c:/Windows folder too. Taking advantage that it is in the environmental variable path) Well, this is optional, you always can change properties of powershell to force it open as administrador always. But, this would be necessary for you if you want to execute something as administrator in ps6 when you are coding in vscode. (You can solve that just open it as administrator too. haha.)
Installing module for icons
(Referred: https://github.com/devblackops/Terminal-Icons)
To install the module from the PowerShell Gallery:
Install-Module -Name Terminal-Icons -Repository PSGallery
To use it modify your profile file adding this line:
Import-Module -Name Terminal-Icons
Note: Take into account that this module can make it take a bit longer to start powershell.
You can see your file with icons using:
Get-ChildItem | Format-List
Get-ChildItem | Format-Wide
Get-ChildItem | Format-Wide -Column 3
Aditionally, if you want to use ls and la commands in powershell so you can see your files with icons easily you could add these lines in your profile file
#ALIAS
Set-Alias -Name l -value Get-ChildItem
Set-Alias -Name ls -value lsformatwide
Set-Alias -Name lsl -value lsformatlist
#FUNCIONES
function lsformatwide {
Param(
[switch]$la
)
if ($la) {
Get-ChildItem $Args[0]. -Force | Format-Wide -Column 3
}
else {
Get-ChildItem $Args[0] | Format-Wide -Column 3
}
}
function lsformatlist {
Get-ChildItem | Format-List
}
Now you can use l,ls,lsl to get different views of your files. Also if you want to see hidden files you can use -la after ls
Some color personalization for Readline
Some color personalization for Readline
I have additional configuration for colorising the readline words adding these lines in my profile.ps1
Set-PSReadLineOption -Colors @{
Command = 'Magenta'
Number = 'DarkGray'
Member = 'DarkGray'
Operator = 'DarkMagenta'
Type = 'DarkCyan'
Variable = 'Green'
Parameter = 'DarkGreen'
ContinuationPrompt = 'DarkGray'
}
- *If you want to use the theme with the modifications i did you can download it from here: https://github.com/dialguiba/PowerShellConfiguration/blob/master/Powerlevel10k-Classic-Dialguiba.psm1 *
Top comments (12)
Powershell on my laptop and desktop PC point to the same .ps1 file on my OneDrive. I created two oh-my-posh themes, one for my desktop that does not display battery status and one for my laptop that does display battery status.
How do I load a theme depending on whether it's my laptop running PowerShell or my desktop if PowerShell on both my machines is pointing to the same .ps1 $profile in OneDrive? I suspect I need to have my laptop and desktop PowerShell $profile variable pointing to a file stored locally on the respective machine. How do I do this?
Hello, why dont you create a conditional in your profile that could load a different theme depending on information about the system?. I think that you can retrieve information about your system using get-computerInfo.
docs.microsoft.com/en-us/powershel...
Is everything ok with Sudo command link?
Hello! yes. I use it :)
There is no host in the URL...
I am sorry. I didn't notice that.
Here it is github.com/dialguiba/PowerShellCon...
Hey Diego. First off, thanks for using oh-my-posh. I just dropped in to let you know we’ve been working on V3, which supports every shell you’ll find on Windows and more. Check the website for more information. ohmyposh.dev/
Thank you so much. I am gonna see it. Amazing work!
How to remove this?
Hello, have you recently installed it? If i am not bad, the new version have an easier way to change the themes than before. In the theme's folder you can modify the json of your theme or you can create another. It contains what you want to show. Which theme are you using?
Hi,
Thanks for your reply. Yes, I installed it recently. I'm using "agnoste" theme. Where is the folder location of theme JSON?
At the end of this page. It explains you how to personalize a theme in powershell. ohmyposh.dev/docs/installation
And here you have some of the things that you can add to your theme.
ohmyposh.dev/docs/configure
I would like to test it but i dont have windows right now 😔
Hope it helps you