How to set up perfect command-line environment on Windows

Windows Terminal

First of all, you should install Windows Terminal. It is a modern terminal emulator for users of command-tools and shells, including PowerShell, bash within WSL, SSH, Command Prompt, and any other command-line app.

Why install Windows Terminal? Here are some of the most important reasons I can think of:

tabs
panes – split panes, multiple shells at same time
search
keybindings / shortcuts
command palette (like the one in VS Code)
zooming
better and more customizable themes
dynamic changes – while you change and save JSON settings you can see changes reflecting in your shells

It has easily configurable and dynamic profiles (you can see changes in real-time while changing JSON settings), color schemes, it has GUI for settings, it has command palette, and many other features.

You can get Windows Terminal in 3 different easy ways

Microsoft Store
GitHub releases page

Via chocolatey if you have it installed

 

Visual Studio Code

I also like to install Visual Studio Code to help me quickly navigate and edit any kind of configuration or code files. It’s also an amazing tool to work on JavaScript and TypeScript projects. It can be used for various other programming languages as well.

How to install: Official website or Chocolatey package

If you install via official website, you should have VS Code added to the file context menu (right click) for both files and directories.

 

PowerShell

After that, you should decide which shell you want to use. I use PowerShell 7, also known as PowerShell Core, it is an open-source, cross-platform version of PowerShell.

You can install PowerShell 7 in two easy ways:

Download from GitHub releases page

Install Via chocolatey

Once you are done installing PowerShell you should install few PowerShell modules (extensions):

posh-git
oh-my-posh
PSReadLine

 

If you already don’t have it, I would advise you to install PowerShellGet. It is a module that lets you install other modules for PowerShell. You can check the PowerShell Gallery website for more information.

How to install PowerShellGet – Installing PowerShellGet

Posh Git

posh-git is a PowerShell module that integrates Git and PowerShell by providing Git status summary information that can be displayed in the PowerShell prompt, e.g.:

Installation:

Via PowerShellGet —  / PowerShell Gallery

PowerShellGetInstall-Module poshgit Scope CurrentUser AllowPrerelease Force

Via chocolatey: choco install poshgit

oh-my-posh

Oh My Posh is a prompt theme for any engine, including PowerShell 7. It was inspired by oh-my-zsh (for all of you unix users). You can use a lot of already available themes or create your own or customize one of the existing ones, as I did. 

Adding and modifying pieces of oh-my-posh through JSON configuration is quite easy. 

Installation is quite simple. You can check official docs – Installation

To do it via PowerShell execute following command

Install-Module oh-my-posh -Scope CurrentUser -AllowPrerelease

If you want to set a specific theme for oh-my-posh do the following:

Set-PoshPrompt -Theme jandedobbeleer

 

PSReadLine

Another module – PSReadLine offers better line editing experience for the PowerShell Console

Easiest way to install PSReadLine is through PowerShell and PowerShellGet:

Install-Module PSReadLine AllowPrerelease Force

 

Setting up PowerShell profile

To create a new profile or access existing one from your PowerShell or Windows Terminal type:

code $PROFILE

Paste the following in your VS Code editor:

View the code on Gist.

Save and reload your PowerShell / windows terminal.

 

Getting a good font for your windows terminal

I recomend Cascadia Code – You can download it from Microsoft’s GitHub page — microsoft/cascadia-code: This is a fun, new monospaced font that includes programming ligatures and is designed to enhance the modern look and feel of the Windows Terminal. (github.com)

Once you download and install the font, you should set Font face property for your profile to: Cascadia Code PL

 

Or from Nerd Fonts homepage — Nerd Fonts – Iconic font aggregator, glyphs/icons collection, & fonts patcher

If you download the one from Nerd Fonts, and installed Caskaydia Cove Nerd Font Complete Windows Compatible in your windows terminal profile settings you need to use following value for font: CaskaydiaCove NF

 

 

This is how your windows terminal should look like now in a git repository:

The post How to set up perfect command-line environment on Windows appeared first on CodingBlast.

Flatlogic Admin Templates banner

Leave a Reply

Your email address will not be published. Required fields are marked *