What do you think if I tell you that your PowerShell can look like this? It's pretty right? 😍 🤩
After reading this post, you'll get this beautiful console that you'll love to work with. And not only on PowerShell, but on WSL and Azure Cloud Shell too!! 🥳 🤟
Terminal alternatives
There are more options than the Windows Command Line (CMD) or Windows PowerShell. While they are mostly emulators that run on the terminal, they add good features and look better than the default consoles.
Alternatives over there:
- CMDer
- ConEmu
- Windows Terminal
- Hyper
- Alacritty
- Terminator (running over WSL)
- Fluent Terminal I just found it and looks great
I like to keep my dev environment simple so my choice is the new Windows Terminal using PowerShell Core.
Why Windows Terminal? Microsoft listened to the community and created a totally brand new terminal which is really easy to use, have a lot of cool features like tabs, panes and it can run PowerShell, CMD, Git bash, Linux bash, Azure Cloud Shell as well as any other.
The Windows terminal is relatively new. Previously I worked for many years with ConEmu and I can say that it is a very good option too
I encourage you to test all these alternatives and find which one fit best with you.
This article is based on Windows Terminal, but the configuration can be applied to the other tools as well.
Installation
Let's see what we need to install to convert our boring terminal to an awesome one.
- Posh-Git (git extension)
- Oh-My-Posh (themes)
- Get-ChildItemColor (colorized sub-commands)
- Power Fonts (techie fonts)
Many of these should be installed using PowerShell with admin rights.
Well, let's start 💪 💻
Changing the ExecutionPolicy
NOTE: this steps should be executed on PowerShell and PowerShell Core if you want to have the same theme on both.
So, we open the PowerShell as Admin and change the ExecutionPolicy
to RemoteSigned
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
When you are done, you can go back to the previous configuration by updating the ExecutionPolicy
with scope Process
.
Installing what we need
PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force
Install-Module oh-my-posh -Scope CurrentUser
Install-Module -AllowClobber Get-ChildItemColor
If you are using PowerShell Core you have to install PSReadLine
.
Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck
To allow Power Fonts on our system we should clone the Github repository and run.
.\install.ps1
Tip: the repo has a lot of fonts, so in my case I deleted all of them except the one called
Meslo Dotted
.
Allowing all this stuff
In order to have all the modules installed every time we open the terminal, first we need to update our profile file.
code $profile
And add these lines to it
# Modules import
Import-Module posh-git
Import-Module oh-my-posh
Import-Module Get-ChildItemColor
# Theme to use
Set-Theme Agnoster
Now, we need to tell Windows Terminal to use our selected font. To do so, open the Settings file
We search for the "profile" property and update it with the following.
…..
"profiles": {
"defaults": {
"fontFace": "Meslo LG M DZ for Powerline",
"fontSize": 8,
"colorScheme" : "One Half Dark"
},
"list": [
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
}
.....
If you are using ConEmu o CMDER go to the Settings Fonts
and select the Font previously installed.
NOTE: This changes will be reflected on the Visual Studio Code Terminal too 😉
Extending this to WSL
The magic of WSL is that we can use many flavours of Linux directly on Windows, removing any need of double-boot or VMs. Even so, its bash is still boring! so let's see how we can have the same here.
The natural option is to install PowerShell Core on the distro and set it as default bash, in order to follow the same steps as previously.
But, we are on Linux, where there are many alternatives and a good one is ZSH.
Installation
First we'll update our Linux version
sudo apt-get update
sudo apt-get upgrade
Now we can install everything we need
sudo apt-get install git
sudo apt-get install zsh
We make ZSH our default
chsh -s /bin/zsh
Update the .bashrc
file by adding this at the beginning of it.
if test -t 1; then
exec zsh
Fi
Install Oh-My-Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
We select the theme from the ./zshrc
file.
code $HOME/.zshrc
Search for “ZSH_THEME” property and change it for one you like
ZSH_THEME="norm"
The last step is to install the plugin zsh-dircolors-solarized by cloning the repo
git clone --recursive git://github.com/joel-porquet/zsh-dircolors-solarized $ZSH_CUSTOM/plugins/zsh-dircolors-solarized
Then go back to the .zshrc
file and grant permissions to the pluging
plugins=(zsh-dircolors-solarized)
Finally select the theme for the plugin
setupsolarized dircolors.ansi-dark
The result…
Extending this to Azure Cloud Shell
I didn't try to set up all these things on Azure Cloud Shell, but it's based on Linux - so you can install ZSH and set it up as we did! Here it's explained (https://www.danielstechblog.io/setting-up-zsh-with-oh-my-zsh-in-azure-cloud-shell/)[https://www.danielstechblog.io/setting-up-zsh-with-oh-my-zsh-in-azure-cloud-shell/]
🧉 + 🥐🥐 = Happy coder 💻
Top comments (5)
"And not only on PowerShell, but on WSL and Azure Cloud Shell too!!"
Is there any way to do this for cmd(the classic <3 Command Prompt) as well?
I love using cmd over ps just because.
Hi Samarth
No for the classic CMD there is no way to use something like this.
In windows 11 Microsoft will replace the default CMD by the Windows Terminal with Powershell... maybe is time to update the tool 😉
Well thanks anyways!
Just an update: clink can do this with a direct lua integration with oh my sh.
cmd ( > ps) ain't going nowhere!
I guess it's windows 11 thing: There is no plain json settings when you open settings at terminal.
You can find at: $env:LocalAppData\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json