![Customization Windows Terminal With Starship](/_astro/hero.CNTTb-zH_ZAlT8k.webp)
Customization Windows Terminal With Starship
- Mohammad Abu Mattar
- Windows , Terminal
- 21 Oct, 2022
- 05 Mins read
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:
- Open the Microsoft Store.
- Search for Windows Terminal.
- Click on the Get button.
Install Windows Terminal From GitHub
To install Windows Terminal from GitHub, you can follow the steps below:
- Open the GitHub repository.
- Click on the Releases tab.
- Click on the latest release.
- Click on the WindowsTerminal.exe file.
- Click on the Download button.
Install Windows Terminal With Chocolatey
To install Windows Terminal with Chocolatey, you can follow the steps below:
- Open the Chocolatey website.
- Click on the Packages.
- Search for Windows Terminal.
- Click on the command to install Windows Terminal.
- Run the command in CMD.
choco install microsoft-windows-terminal --pre -y
Install Windows Terminal With Winget
To install Windows Terminal with Winget, you can follow the steps below:
- Open the Winget website.
- Search for Windows Terminal.
- Click on the command to install Windows Terminal.
- Run the command in CMD.
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:
- Open the Microsoft Store.
- Search for PowerShell.
- Click on the Get button.
Install PowerShell From GitHub
To install PowerShell from GitHub, you can follow the steps below:
- Open the GitHub repository.
- Click on the Releases tab.
- Click on the latest release.
- Click on the PowerShell-7.2.0-win-x64.msi file.
- Click on the Download button.
Install PowerShell With Chocolatey
To install PowerShell with Chocolatey, you can follow the steps below:
- Open the Chocolatey website.
- Click on the Packages.
- Search for PowerShell.
- Click on the command to install PowerShell.
- Run the command in CMD.
choco install powershell -y
Install PowerShell With Winget
To install PowerShell with Winget, you can follow the steps below:
- Open the Winget website.
- Search for PowerShell.
- Click on the command to install PowerShell.
- Run the command in CMD.
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:
- Open the GitHub repository.
- Click on the Releases tab.
- Click on the latest release.
- Click on the starship-x86_64-pc-windows-msvc.zip file.
- Click on the Download button.
Install Starship With Chocolatey
To install Starship with Chocolatey, you can follow the steps below:
- Open the Chocolatey website.
- Click on the Packages.
- Search for Starship.
- Click on the command to install Starship.
- Run the command in CMD.
choco install starship -y
Install Starship With Winget
To install Starship with Winget, you can follow the steps below:
- Open the Winget website.
- Search for Starship.
- Click on the command to install Starship.
- Run the command in CMD.
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:
- Open the powershell.
- Run the command below to create the configuration file.
mkdir -p ~/.config && touch ~/.config/starship.toml
- Open the configuration file with your favorite text editor.
notepad ~/.config/starship.toml
- Copy the configuration below and paste it in the configuration file. GitHub | starship.toml
## .# .. .''# .,'..,. ..,;,'# ,;;;;,, .,,;;;# ,;;;;;' .',;;;# ,;;;;,'...,;;;,# ,;;;;;,,;;;;.# ,;;;;;;;;;# .,;;;;;;;# .,;;;;;;;'# .,;;;;;;;,'# .',;;;;;;;;;;,.# ..,;;;;;;;;;;;;;,.# .';;;;;. ';;;;;;,'# .,;;;;. ,; .;; .,# ',;;;. .# .,;;.# ,;### FIRST LINE/ROW: Info & Status# First param ─┌[username]format = " [╭─$user]($style)@"show_always = truestyle_root = "bold red"style_user = "bold red"
# Second param[hostname]disabled = falseformat = "[$hostname]($style) in "ssh_only = falsestyle = "bold dimmed red"trim_at = "-"
# Third param[directory]style = "purple"truncate_to_repo = truetruncation_length = 0truncation_symbol = "repo: "
# Fourth param[sudo]disabled = false
# Before all the version info (python, nodejs, php, etc.)[git_status]ahead = "⇡${count}"behind = "⇣${count}"deleted = "x"diverged = "⇕⇡${ahead_count}⇣${behind_count}"style = "white"
# Last param in the first line/row[cmd_duration]disabled = falseformat = "took [$duration]($style)"min_time = 1
## SECOND LINE/ROW: Prompt# Somethere at the beginning[battery]charging_symbol = ""disabled = truedischarging_symbol = ""full_symbol = ""
[[battery.display]] # "bold red" style when capacity is between 0% and 10%disabled = falsestyle = "bold red"threshold = 15
[[battery.display]] # "bold yellow" style when capacity is between 10% and 30%disabled = truestyle = "bold yellow"threshold = 50
[[battery.display]] # "bold green" style when capacity is between 10% and 30%disabled = truestyle = "bold green"threshold = 80
# Prompt: optional param 1[time]disabled = trueformat = " 🕙 $time($style)\n"style = "bright-white"time_format = "%T"
# Prompt: param 2[character]error_symbol = " [×](bold red)"success_symbol = " [╰─λ](bold red)"
# SYMBOLS[status]disabled = falseformat = '[\[$symbol$status_common_meaning$status_signal_name$status_maybe_int\]]($style)'map_symbol = truepipestatus = truesymbol = "🔴"
[aws]symbol = " "
[conda]symbol = " "
[dart]symbol = " "
[docker_context]symbol = " "
[elixir]symbol = " "
[elm]symbol = " "
[git_branch]symbol = " "
[golang]symbol = " "
[hg_branch]symbol = " "
[java]symbol = " "
[julia]symbol = " "
[nim]symbol = " "
[nix_shell]symbol = " "
[nodejs]symbol = " "
[package]symbol = " "
[perl]symbol = " "
[php]symbol = " "
[python]symbol = " "
[ruby]symbol = " "
[rust]symbol = " "
[swift]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:
- Open Windows Terminal.
- Run the following command to create a PowerShell profile.
New-Item -Path $PROFILE -ItemType File -Force
- Run the following command to
Set-Content
cmdlet to add the line to the profile.
$CONFIG_PROFILE = {function Invoke-Starship-TransientFunction { &starship module character}
Invoke-Expression (&starship init powershell)}
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:
- Open Windows Terminal.
- Click on
Ctrl + ,
to open the settings. - Click on
settings.json
to open the settings file. - Add the following lines to the
profiles
section.
{ "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "hidden": false, "name": "PowerShell", "source": "Windows.Terminal.PowershellCore"}
- Change the
hidden
property totrue
for theWindows PowerShell
profile.
{ "commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "hidden": true, "name": "Windows PowerShell"}
- Add
Dracula schemes
to theschemes
section.
{ "background": "#282A36", "black": "#21222C", "blue": "#BD93F9", "brightBlack": "#6272A4", "brightBlue": "#D6ACFF", "brightCyan": "#A4FFFF", "brightGreen": "#69FF94", "brightPurple": "#FF92DF", "brightRed": "#FF6E6E", "brightWhite": "#FFFFFF", "brightYellow": "#FFFFA5", "cursorColor": "#F8F8F2", "cyan": "#8BE9FD", "foreground": "#F8F8F2", "green": "#50FA7B", "name": "Dracula", "purple": "#FF79C6", "red": "#FF5555", "selectionBackground": "#44475A", "white": "#F8F8F2", "yellow": "#F1FA8C"}
- Save the file and close it.
- Back to Windows Terminal, click on
Ctrl + ,
to open the settings. - Go to Profiles >> Defaults >> Appearance >> Color scheme choose
Dracula
. - Go to Profiles >> Defaults >> Appearance >> Font face choose
Caskaydia Cove Nerd Font
.
Extra Configuration
- Open Windows Terminal.
- Run the command
# Allow scripts to runSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# Install PSReadLineInstall-Module PSReadLine -AllowPrerelease -Force
# Install Terminal-IconsInstall-Module Terminal-Icons -AllowPrerelease -Force
- Run the following command to
Set-Content
cmdlet to add the line to the profile.
$CONFIG_PROFILE = {function Invoke-Starship-TransientFunction { &starship module character}
Invoke-Expression (&starship init powershell)
# set PowerShell to UTF-8[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
Import-Module -Name Terminal-Icons
Set-PSReadLineOption -PredictionViewStyle ListViewSet-PSReadLineOption -PredictionViewStyle InlineView
Set-PSReadLineOption -EditMode WindowS
Set-PSReadLineKeyHandler -Chord Ctrl+B -ScriptBlock { [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() [Microsoft.PowerShell.PSConsoleReadLine]::Insert('build') [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()}
# This is an example of a macro that you might use to execute a command.# This will add the command to history.Set-PSReadLineKeyHandler -Key Ctrl+Shift+b ` -BriefDescription BuildCurrentDirectory ` -LongDescription "Build the current directory" ` -ScriptBlock { [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() [Microsoft.PowerShell.PSConsoleReadLine]::Insert("dotnet build") [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()}}
Set-Content -Path $PROFILE -Value $CONFIG_PROFILE