Type something to search...
Customization Windows Terminal With Starship

Customization Windows Terminal With Starship

Introduction

In this article, we will learn how to install PowerShell and Starship, how to configure the Windows Terminal, and how to customize the Windows Terminal with Starship.

What Is a Windows Terminal?

Windows Terminal is a new, modern, fast, efficient, powerful, and productive terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and WSL. It includes many features that make it a great tool for developers and system administrators. It is a great replacement for the default Windows Command Prompt and PowerShell.

What Is a Starship?

Starship is a cross-shell prompt for any shell. It shows information about the current directory, the active branch, the status of the repository, and much more. It is highly customizable and can be extended with custom modules. It is written in Rust and is blazingly fast.

Installation

Install Windows Terminal

To install Windows Terminal, you can download it from the Microsoft Store or from the GitHub repository, or you can use the Chocolatey package manager or Winget package manager.

Install Windows Terminal From Microsoft Store

To install Windows Terminal from the Microsoft Store, you can follow the steps below:

  1. Open the Microsoft Store.
  2. Search for Windows Terminal.
  3. Click on the Get button.

Install Windows Terminal From GitHub

To install Windows Terminal from GitHub, you can follow the steps below:

  1. Open the GitHub repository.
  2. Click on the Releases tab.
  3. Click on the latest release.
  4. Click on the WindowsTerminal.exe file.
  5. Click on the Download button.

Install Windows Terminal With Chocolatey

To install Windows Terminal with Chocolatey, you can follow the steps below:

  1. Open the Chocolatey website.
  2. Click on the Packages.
  3. Search for Windows Terminal.
  4. Click on the command to install Windows Terminal.
  5. Run the command in CMD.
Terminal window
1
choco install microsoft-windows-terminal --pre -y

Install Windows Terminal With Winget

To install Windows Terminal with Winget, you can follow the steps below:

  1. Open the Winget website.
  2. Search for Windows Terminal.
  3. Click on the command to install Windows Terminal.
  4. Run the command in CMD.
Terminal window
1
winget install --id=Microsoft.WindowsTerminal -e

Install PowerShell

To install PowerShell, you can download it from the Microsoft Store or from the GitHub repository, or you can use the Chocolatey package manager or Winget package manager.

Install PowerShell From Microsoft Store

To install PowerShell from the Microsoft Store, you can follow the steps below:

  1. Open the Microsoft Store.
  2. Search for PowerShell.
  3. Click on the Get button.

Install PowerShell From GitHub

To install PowerShell from GitHub, you can follow the steps below:

  1. Open the GitHub repository.
  2. Click on the Releases tab.
  3. Click on the latest release.
  4. Click on the PowerShell-7.2.0-win-x64.msi file.
  5. Click on the Download button.

Install PowerShell With Chocolatey

To install PowerShell with Chocolatey, you can follow the steps below:

  1. Open the Chocolatey website.
  2. Click on the Packages.
  3. Search for PowerShell.
  4. Click on the command to install PowerShell.
  5. Run the command in CMD.
Terminal window
1
choco install powershell -y

Install PowerShell With Winget

To install PowerShell with Winget, you can follow the steps below:

  1. Open the Winget website.
  2. Search for PowerShell.
  3. Click on the command to install PowerShell.
  4. Run the command in CMD.
Terminal window
1
winget install --id=Microsoft.PowerShell -e

Install Starship

To install Starship, you can download it from the GitHub repository, or you can use the Chocolatey package manager or Winget package manager.

Install Starship From GitHub

To install Starship from GitHub, you can follow the steps below:

  1. Open the GitHub repository.
  2. Click on the Releases tab.
  3. Click on the latest release.
  4. Click on the starship-x86_64-pc-windows-msvc.zip file.
  5. Click on the Download button.

Install Starship With Chocolatey

To install Starship with Chocolatey, you can follow the steps below:

  1. Open the Chocolatey website.
  2. Click on the Packages.
  3. Search for Starship.
  4. Click on the command to install Starship.
  5. Run the command in CMD.
Terminal window
1
choco install starship -y

Install Starship With Winget

To install Starship with Winget, you can follow the steps below:

  1. Open the Winget website.
  2. Search for Starship.
  3. Click on the command to install Starship.
  4. Run the command in CMD.
Terminal window
1
winget install --id=Starship.Starship -e

Install Nerd Font

Quick install a nerd font from the Nerd Fonts website. You can choose any font you like. I will use the Caskaydia Cove Nerd Font font.

Configuration

Configure Starship

To configure Starship, you can follow the steps below:

  1. Open the powershell.
  2. Run the command below to create the configuration file.
Terminal window
1
mkdir -p ~/.config && touch ~/.config/starship.toml
  1. Open the configuration file with your favorite text editor.
Terminal window
1
notepad ~/.config/starship.toml
  1. Copy the configuration below and paste it in the configuration file. GitHub | starship.toml
~/.config/starship.toml
1
#
2
# .
3
# .. .''
4
# .,'..,. ..,;,'
5
# ,;;;;,, .,,;;;
6
# ,;;;;;' .',;;;
7
# ,;;;;,'...,;;;,
8
# ,;;;;;,,;;;;.
9
# ,;;;;;;;;;
10
# .,;;;;;;;
11
# .,;;;;;;;'
12
# .,;;;;;;;,'
13
# .',;;;;;;;;;;,.
14
# ..,;;;;;;;;;;;;;,.
15
# .';;;;;. ';;;;;;,'
16
# .,;;;;. ,; .;; .,
17
# ',;;;. .
18
# .,;;.
19
# ,;
20
#
21
## FIRST LINE/ROW: Info & Status
22
# First param ─┌
23
[username]
24
format = " [╭─$user]($style)@"
25
show_always = true
26
style_root = "bold red"
27
style_user = "bold red"
28
29
# Second param
30
[hostname]
31
disabled = false
32
format = "[$hostname]($style) in "
33
ssh_only = false
34
style = "bold dimmed red"
35
trim_at = "-"
36
37
# Third param
38
[directory]
39
style = "purple"
40
truncate_to_repo = true
41
truncation_length = 0
42
truncation_symbol = "repo: "
43
44
# Fourth param
45
[sudo]
46
disabled = false
47
48
# Before all the version info (python, nodejs, php, etc.)
49
[git_status]
50
ahead = "⇡${count}"
51
behind = "⇣${count}"
52
deleted = "x"
53
diverged = "⇕⇡${ahead_count}⇣${behind_count}"
54
style = "white"
55
56
# Last param in the first line/row
57
[cmd_duration]
58
disabled = false
59
format = "took [$duration]($style)"
60
min_time = 1
61
62
63
## SECOND LINE/ROW: Prompt
64
# Somethere at the beginning
65
[battery]
66
charging_symbol = ""
67
disabled = true
68
discharging_symbol = ""
69
full_symbol = ""
70
71
[[battery.display]] # "bold red" style when capacity is between 0% and 10%
72
disabled = false
73
style = "bold red"
74
threshold = 15
75
76
[[battery.display]] # "bold yellow" style when capacity is between 10% and 30%
77
disabled = true
78
style = "bold yellow"
79
threshold = 50
80
81
[[battery.display]] # "bold green" style when capacity is between 10% and 30%
82
disabled = true
83
style = "bold green"
84
threshold = 80
85
86
# Prompt: optional param 1
87
[time]
88
disabled = true
89
format = " 🕙 $time($style)\n"
90
style = "bright-white"
91
time_format = "%T"
92
93
# Prompt: param 2
94
[character]
95
error_symbol = " [×](bold red)"
96
success_symbol = " [╰─λ](bold red)"
97
98
# SYMBOLS
99
[status]
100
disabled = false
101
format = '[\[$symbol$status_common_meaning$status_signal_name$status_maybe_int\]]($style)'
102
map_symbol = true
103
pipestatus = true
104
symbol = "🔴"
105
106
[aws]
107
symbol = ""
108
109
[conda]
110
symbol = ""
111
112
[dart]
113
symbol = ""
114
115
[docker_context]
116
symbol = ""
117
118
[elixir]
119
symbol = ""
120
121
[elm]
122
symbol = ""
123
124
[git_branch]
125
symbol = ""
126
127
[golang]
128
symbol = ""
129
130
[hg_branch]
131
symbol = ""
132
133
[java]
134
symbol = ""
135
136
[julia]
137
symbol = ""
138
139
[nim]
140
symbol = ""
141
142
[nix_shell]
143
symbol = ""
144
145
[nodejs]
146
symbol = ""
147
148
[package]
149
symbol = ""
150
151
[perl]
152
symbol = ""
153
154
[php]
155
symbol = ""
156
157
[python]
158
symbol = ""
159
160
[ruby]
161
symbol = ""
162
163
[rust]
164
symbol = ""
165
166
[swift]
167
symbol = ""

Configure Starship on PowerShell

Every time a PowerShell instance launches, we’ll need to instance starship, to achieve this, we’ll need to add the following line to our PowerShell profile.

To create a PowerShell profile, and add the starship instance, you can follow the steps below:

  1. Open Windows Terminal.
  2. Run the following command to create a PowerShell profile.
Terminal window
1
New-Item -Path $PROFILE -ItemType File -Force
  1. Run the following command to Set-Content cmdlet to add the line to the profile.
Terminal window
1
$CONFIG_PROFILE = {function Invoke-Starship-TransientFunction {
2
&starship module character
3
}
4
5
Invoke-Expression (&starship init powershell)}
6
7
Set-Content -Path $PROFILE -Value $CONFIG_PROFILE

Note: You can check the location of this file by querying the $PROFILE variable in PowerShell. The path is often ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1.

Configure PowerShell on Windows Terminal

To configure PowerShell on Windows Terminal, you can follow the steps below:

  1. Open Windows Terminal.
  2. Click on Ctrl + , to open the settings.
  3. Click on settings.json to open the settings file.
  4. Add the following lines to the profiles section.
1
{
2
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
3
"hidden": false,
4
"name": "PowerShell",
5
"source": "Windows.Terminal.PowershellCore"
6
}
  1. Change the hidden property to true for the Windows PowerShell profile.
1
{
2
"commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
3
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
4
"hidden": true,
5
"name": "Windows PowerShell"
6
}
  1. Add Dracula schemes to the schemes section.
1
{
2
"background": "#282A36",
3
"black": "#21222C",
4
"blue": "#BD93F9",
5
"brightBlack": "#6272A4",
6
"brightBlue": "#D6ACFF",
7
"brightCyan": "#A4FFFF",
8
"brightGreen": "#69FF94",
9
"brightPurple": "#FF92DF",
10
"brightRed": "#FF6E6E",
11
"brightWhite": "#FFFFFF",
12
"brightYellow": "#FFFFA5",
13
"cursorColor": "#F8F8F2",
14
"cyan": "#8BE9FD",
15
"foreground": "#F8F8F2",
16
"green": "#50FA7B",
17
"name": "Dracula",
18
"purple": "#FF79C6",
19
"red": "#FF5555",
20
"selectionBackground": "#44475A",
21
"white": "#F8F8F2",
22
"yellow": "#F1FA8C"
23
}
  1. Save the file and close it.
  2. Back to Windows Terminal, click on Ctrl + , to open the settings.
  3. Go to Profiles >> Defaults >> Appearance >> Color scheme choose Dracula.
  4. Go to Profiles >> Defaults >> Appearance >> Font face choose Caskaydia Cove Nerd Font.

Settings

Extra Configuration

  1. Open Windows Terminal.
  2. Run the command
Terminal window
1
# Allow scripts to run
2
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
3
4
# Install PSReadLine
5
Install-Module PSReadLine -AllowPrerelease -Force
6
7
# Install Terminal-Icons
8
Install-Module Terminal-Icons -AllowPrerelease -Force
  1. Run the following command to Set-Content cmdlet to add the line to the profile.
Terminal window
1
$CONFIG_PROFILE = {function Invoke-Starship-TransientFunction {
2
&starship module character
3
}
4
5
Invoke-Expression (&starship init powershell)
6
7
# set PowerShell to UTF-8
8
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
9
10
Import-Module -Name Terminal-Icons
11
12
Set-PSReadLineOption -PredictionViewStyle ListView
13
Set-PSReadLineOption -PredictionViewStyle InlineView
14
15
Set-PSReadLineOption -EditMode WindowS
16
17
Set-PSReadLineKeyHandler -Chord Ctrl+B -ScriptBlock {
18
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
19
[Microsoft.PowerShell.PSConsoleReadLine]::Insert('build')
20
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
21
}
22
23
24
# This is an example of a macro that you might use to execute a command.
25
# This will add the command to history.
26
Set-PSReadLineKeyHandler -Key Ctrl+Shift+b `
27
-BriefDescription BuildCurrentDirectory `
28
-LongDescription "Build the current directory" `
29
-ScriptBlock {
30
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
31
[Microsoft.PowerShell.PSConsoleReadLine]::Insert("dotnet build")
32
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
33
}}
34
35
Set-Content -Path $PROFILE -Value $CONFIG_PROFILE

Settings

References

Related Posts

Check out some of our other posts

Git SSH Keys for GitHub, GitLab, and Bitbucket on Windows

Git SSH Keys for GitHub, GitLab, and Bitbucket on Windows

Introduction Git connects to remotes by default via HTTPS, which requires you to enter your login and password every time you run a command like Git pull or git push, using the SSH protocol. You

read more
How To Create A Custom VPC Using AWS CLI

How To Create A Custom VPC Using AWS CLI

Introduction In the sample that follows, an IPv4 CIDR block, a public subnet, and a private subnet are all created using AWS CLI instructions. You can run an instance in the public subnet and con

read more
Introduction to Linux CLI

Introduction to Linux CLI

Introduction The Linux operating system family is a group of free and open-source Unix systems. They consist of Red Hat, Arch Linux, Ubuntu, Debian, openSUSE, and Fedora. You must utilize a shell

read more
How To Connect A EBS Volume To An Windows EC2 Instance Using Powershell/GUI

How To Connect A EBS Volume To An Windows EC2 Instance Using Powershell/GUI

Introduction In this post, we will learn how to connect a EBS volume to an Windows EC2 instance using Powershell/GUI and also how to mount the EBS volume to the EC2 instance. Prerequisites

read more