DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,503 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Setting up Windows 10/11 as a developer environment (for beginners)
Abhigyan Madhukalya
Abhigyan Madhukalya

Posted on • Updated on

Setting up Windows 10/11 as a developer environment (for beginners)

This is the start of a series of posts detailing how to setup Windows as a proper developer environment. This post is meant to help beginners like me.


Ingredients:


Installing Windows Terminal and Winget

  • To get started install Microsoft Terminal from the Microsoft Store.

  • If you're on Windows 10, install App Installer from the Microsoft Store or follow the instructions on the Winget-cli github repo.

GitHub logo microsoft / winget-cli

Windows Package Manager CLI (aka winget)

Windows Package Manager Client

This repository contains the source code for the Windows Package Manager Client.

winget install wingetcreate

If you are new to the Windows Package Manager, you might want to Explore the Windows Package Manager tool. The packages available to the client are in the Windows Package Manager Community Repository.

Installing The Client

The client requires Windows 10 1809 (build 17763) or later at this time. Windows Server 2019 is not supported as the Microsoft Store is not available nor are updated dependencies. It may be possible to install on Windows Server 2022, this should be considered experimental (not supported), and requires dependencies to be manually installed as well.

Microsoft Store [Recommended]

The client is distributed within the App Installer package.

Development Releases

There are two methods to get development releases:

Install Patched Nerd Font

  • Go to the Nerd Fonts website and download the patched font you like. Extract the zip file and install the fonts.

Configure Windows Terminal

  • Open Windows Terminal and go to Settings from the dropdown menu.

settings-dropdown

  • In settings, go to the Defaults profile and click the Appearance option in the Additional Settings.

  • In Appearance, change the color scheme to One Half Dark as it looks the cleanest and the font to the patched nerd font you just installed. I will use Hack NF.

final-result-appearance

  • Scroll down and enable Acrylic Material and Transparency if you desire a pretty looking terminal.

acrylic-material

Install Powershell

  • Microsoft released a new version of Powershell in the Microsoft Store and on their GitHub repo which is miles better than what we have right now.

  • To install the new and improved Powershell, enter the following lines in a new terminal tab.

winget install Microsoft.PowerShell
Enter fullscreen mode Exit fullscreen mode

Change default shell

  • Go back to the settings tab in Windows Terminal.

  • In the startup tab on the left side, change the default profile to Powershell (not Windows Powershell)

default-profile

  • Reload Windows Terminal to confirm the changes.

Install Scoop (command-line package installer)

  • To install Scoop, type the following lines taken from the Scoop website.
iwr -useb get.scoop.sh | iex
Enter fullscreen mode Exit fullscreen mode
  • To check if Scoop is properly installed, we will install a few packages
  1. sudo - elevating commands without opening terminal with administrator privileges
  2. jq - command-line json processor
  3. curl - command-line tool for transferring data
  • To install them type,
scoop install sudo jq curl
Enter fullscreen mode Exit fullscreen mode
  • If the packages are installed correctly, then congratulations. If not, then refer to their documentation to fix the issue.

Install Git for Windows

  • Git is free and open source software for distributed version control: tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development.

  • To install Git, type the following lines

winget install -e --id Git.Git
Enter fullscreen mode Exit fullscreen mode

Install Neovim

  • This tutorial is going to use Neovim to edit configuration files of different packages and programs. You can use something else if you like.

  • To install Neovim, type the following lines,

scoop install neovim
Enter fullscreen mode Exit fullscreen mode

Configure Powershell

  • To configure Powershell, we will create a .ps1 file where we will save our settings.

  • Use the following commands to make a .ps1 file

# Change working directory to home directory
cd $home

# Make .config directory
mkdir .config

# Create a config file
echo "" > .config/Microsoft_profile.ps1

# In this tutorial, I will name the config file
# Microsoft_profile.ps1 but you can name it anything
# you want
Enter fullscreen mode Exit fullscreen mode
  • Open neovim and add the following to the config file
nvim .config/powershell/Microsoft_profile.ps1
Enter fullscreen mode Exit fullscreen mode

Inside the file, add the following lines

# Set Encoding to UTF-8
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding

# Aliases (add more according to your preference)
Set-Alias -Name vim -Value nvim
Set-Alias ll dir
Set-Alias g git
Set-Alias grep findstr
Enter fullscreen mode Exit fullscreen mode
  • Update $PROFILE for Current User
nvim $PROFILE.CurrentUserHost
Enter fullscreen mode Exit fullscreen mode

Inside the file, add the following lines

$env:USERPROFILE\.config\powershell\Microsoft_profile.ps1
Enter fullscreen mode Exit fullscreen mode
  • Open a new Powershell to confirm the changes

Install Oh My Posh (prompt engine for Powershell)

  • To install Oh My Posh, enter the following lines
sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
sudo chmod +x /usr/local/bin/oh-my-posh
Enter fullscreen mode Exit fullscreen mode
  • Make new file for Oh My Posh theme
# You can name the theme file anything you want
echo "" > .config/powershell/theme1.omp.json
Enter fullscreen mode Exit fullscreen mode
  • Add the following code to the file,
{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "background": "#0077c2",
          "foreground": "#ffffff",
          "leading_diamond": "\u256d\u2500\ue0b6",
          "style": "diamond",
          "template": " {{ .Name }} ",
          "type": "shell"
        },
        {
          "background": "#ef5350",
          "foreground": "#FFFB38",
          "properties": {
            "root_icon": "\uf292"
          },
          "style": "diamond",
          "template": "<parentBackground>\ue0b0</> \uf0e7 ",
          "type": "root"
        },
        {
          "background": "#444444",
          "foreground": "#E4E4E4",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "style": "full"
          },
          "style": "powerline",
          "template": " {{ .Path }} ",
          "type": "path"
        },
        {
          "background": "#FFFB38",
          "background_templates": [
            "{{ if or (.Working.Changed) (.Staging.Changed) }}#ffeb95{{ end }}",
            "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#c5e478{{ end }}",
            "{{ if gt .Ahead 0 }}#C792EA{{ end }}",
            "{{ if gt .Behind 0 }}#C792EA{{ end }}"
          ],
          "foreground": "#011627",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "branch_icon": "\ue725 ",
            "fetch_status": true,
            "fetch_upstream_icon": true
          },
          "style": "powerline",
          "template": " {{ .HEAD }} {{ if .Working.Changed }}{{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}<#ef5350> \uf046 {{ .Staging.String }}</>{{ end }} ",
          "type": "git"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "right",
      "segments": [
        {
          "background": "#303030",
          "foreground": "#3C873A",
          "leading_diamond": " \ue0b6",
          "properties": {
            "fetch_package_manager": true,
            "npm_icon": " <#cc3a3a>\ue5fa</> ",
            "yarn_icon": " <#348cba>\uf61a</>"
          },
          "style": "diamond",
          "template": "\ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }}",
          "trailing_diamond": "\ue0b4",
          "type": "node"
        },
        {
          "background": "#40c4ff",
          "foreground": "#ffffff",
          "invert_powerline": true,
          "leading_diamond": " \ue0b6",
          "style": "diamond",
          "template": " \uf5ef {{ .CurrentDate | date .Format }} ",
          "trailing_diamond": "\ue0b4",
          "type": "time"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "#21c7c7",
          "style": "plain",
          "template": "\u2570\u2500",
          "type": "text"
        },
        {
          "foreground": "#e0f8ff",
          "foreground_templates": [
            "{{ if gt .Code 0 }}#ef5350{{ end }}"
          ],
          "properties": {
            "always_enabled": true
          },
          "style": "plain",
          "template": "\u276f ",
          "type": "exit"
        }
      ],
      "type": "prompt"
    }
  ],
  "version": 2
}
Enter fullscreen mode Exit fullscreen mode
  • This will create the theme file with the following theme,

theme1

  • To load the theme, add the following to .config/powershell/Microsoft_profile.ps1
Import-Module post-git
$omp_config = Join-Path $PSScriptRoot ".\theme1.omp.json"
oh-my-posh --init --shell pwsh --config $omp_config | Invoke-Expression
Enter fullscreen mode Exit fullscreen mode
  • Install NodeJS to check if right bubbles are working
# Install Node Version Manager (NVM)
scoop install nvm

# Install LTS Version of NodeJS
nvm install 14.16.10

# Use LTS Version of NodeJS
nvm use 14.16.10

# Make temporary folder for testing
mkdir example && cd example

# Initialize npm for checking right bubbles
npm init -y
Enter fullscreen mode Exit fullscreen mode
  • Following the above commands, the right bubbles should be working for you.

Terminal Icons, zoxide, PSReadLine, PSFzf - Powershell Modules

  • Enter the following commands to install module for Terminal Icons (make ll command a little prettier), zoxide (directory jumping), PSReadLine (autocomplete)
Install-Module -Name Terminal-Icons -Repository PSGallery -Force
Install-Module -Name z -Force
Install-Module -Name PSReadLine -AllowPreRelease -Scope CurrentUser -Force -SkipPublisherCheck
Install-Module -Name PSFzf -Scope CurrentUser -Force

# Requirement for PSFzf Module
scoop install fzf 
Enter fullscreen mode Exit fullscreen mode
  • Restart Terminal

  • Add the following lines to powershell config to import the modules

# Terminal Icons
Import-Module -Name Terminal-Icons

# PSReadLine
Set-PSReadLineOption -EditMode Emacs                                                                                 
Set-PSReadLineOption -BellStyle None
Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar
Set-PSReadLineOption -PredictionSource History

# PSFzf
Import-Module -Name PSFzf
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+f' -PSReadlineChordReverseHistory 'Ctrl+r'

# Add utility command 'which'
function which ($command) {
  Get-Command -Name $command -ErrorAction SilentlyContinue
    Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}
Enter fullscreen mode Exit fullscreen mode

Thus, we have configured Powershell and Windows Terminal to make Windows a proper developer environment. In the next part of the series we will configure Windows Subsystem for Linux (WSL) and make it our main developer environment and use Powershell to interact with Windows whenever necessary.

Top comments (2)

Collapse
 
jandedobbeleer profile image
Jan De Dobbeleer

@abhimadhukalya the installation method for oh-my-posh isn't correct. Have a look at this guide.

Collapse
 
abhimadhukalya profile image
Abhigyan Madhukalya Author

I have fixed it using the guide you've sent me. Thank you!

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›