install

On windows11, windows terminal has installed as default. If not, Please install windows terminal from Microsoft Store.

update PowerShell

Get PowerShell Version:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14

 $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22621.2506
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.2506
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

update PowerShell:

1
winget install --id Microsoft.Powershell --source winget

Check PowerShell Version:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Set ExecutionPolicy

1
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

more details

Configure proxy

Open PROFILE with notepad:

1
notepad $PROFILE

Add the following content to the PROFILE file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function Enable-Proxy {
    $proxy_host = '127.0.0.1'
    $proxy_port = <port>
    $proxy_url = "http://${proxy_host}:$proxy_port"

    # Set proxy-related environment variables that are widely used by applications
    $env:HTTP_PROXY = $proxy_url
    $env:HTTPS_PROXY = $proxy_url
    $env:ALL_PROXY = $proxy_url

    # Set web proxy for .NET applications
    # The second argument `$true` means bypass local addresses
    [System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy($proxy_url, $true)
    [System.Net.Http.HttpClient]::DefaultProxy = New-Object System.Net.WebProxy($proxy_url, $true)
}
New-Alias -Name proxy -Value Enable-Proxy

function Reset-Proxy {
    # Unset proxy-related environment variables
    $env:HTTP_PROXY = ''
    $env:HTTPS_PROXY = ''
    $env:ALL_PROXY = ''

    # Unset web proxy for .NET applications
    [System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy($null)
    [System.Net.Http.HttpClient]::DefaultProxy = New-Object System.Net.WebProxy($null)
}
New-Alias -Name unproxy -Value Reset-Proxy

Usage:

  1. use proxy to turn on proxy

  2. use unproxy to turn off proxy

starship

1
scoop install starship

Add the following to the end of your PowerShell configuration (find it by running $PROFILE):

1
2

Invoke-Expression (&starship init powershell)

tips

exa

1
exa -l --all -l --all --group-directories-first
1
exa --tree --level=1

duf

1
duf --hide-fs tmpfs --width 70
1
2
duf --hide-fs tmpfs --width 60 --json