windows terminal
Table of Content
Terminal¶
This page covers items to setup my terminal on Windows.
The terminal I use is powershell running on windows terminal installed using winget.
I customize the terminal using oh-my-posh, and install font and theme.
$PROFILE¶
One thing I'd like to highlight before going any further is about $PROFILE
file. It's the powershell init config file like ~/.bashrc and ~/.zshrc. The file location can be confirmed by echo $PROFILE
.
C:\Users\{$env:username}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Here is what I have as of Feb 2024.
# utf-i
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding('utf-8')
# aws
$Env:AWS_PROFILE="xxx""
# alias
set-alias posh oh-my-posh
set-alias v nvim
set-alias grep select-string
set-alias vim nvim
set-alias less 'c:\program files\git\usr\bin\less.exe'
set-alias ll ls
set-alias which get-command
function git-status { git status }
set-alias -name gs -value git-status
function ls-simple { get-childitem | format-wide }
set-alias -name l -value ls-simple
# replace cd
rm Alias:cd
function cd
{
if ($args.Length -gt 0)
{
Set-Location $args[0]
}
else
{
Set-Location $HOME
}
}
# oh-my-posh
oh-my-posh init pwsh --config 'C:\Users\{username_here}\AppData\Local\Programs\oh-my-posh\themes\takuya.omp.json' | Invoke-Expression
# MOTD
echo ""
echo "See `$PROFILE file for the start-up script (run cat `$PROFILE)."
echo "Run winget list and winget upgrade (--all, --include-unknown) to manage packages using winget."
echo "Run scoop list and scoop update (-a) to manage packages using scoop."
echo "Run python -m pip list (-o to check outdated) and install -U to check and upgrade packages."
echo ""
$env:¶
And one more thing to highlight is about environment variable.
Run dir env:
to print available ones. See powershell document for more information.
To see USERNAME environment variable, run $env:username
.
Windows Terminal¶
[[Windows Terminal]]
The Windows Terminal is a modern, fast, efficient, powerful, and productive terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and WSL. Its main features include multiple tabs, panes, Unicode and UTF-8 character support, a GPU accelerated text rendering engine, and custom themes, styles, and configurations.
https://github.com/microsoft/terminal
https://apps.microsoft.com/detail/9N0DX20HK701
Winget¶
First get [[Winget]] to install windows terminal. Winget is the package manager for Windows, and is part of App Installer. Go ahead and install App Installer first.
https://learn.microsoft.com/en-us/windows/package-manager/winget/
Windows Package Manager winget command-line tool is available on Windows 11 and modern versions of Windows 10 as a part of the App Installer.
After the installation is complete, winget command is available on powershell terminal.
Basic usage:
winget search terminal
winget install Microsoft.WindowsTerminal
winget uninstall Microsoft.WindowsTerminal
winget list
winget upgrade
winget upgrade --all --include-unknown
winget --help
winget install Microsoft.WindowsTerminal
install windows terminal using winget¶
Launch powershell and run winget search terminal
to find the right package. winget install Microsoft.WindowsTerminal
to actually install one. Make sure the package source is labeled as "winget".
Run wt
to run. Windows-key + R, then wt will work, and typing wt
on powershell will also work.
customizing windows terminal¶
A good guide by Microsoft is available here.
- install theme engine
- install font
- install color scheme
oh-my-posh¶
Install oh-my-posh, a theme engine using winget.
A prompt theme engine for any shell.
# install
winget install JanDeDobbeleer.OhMyPosh -s Winget
# update
winget upgrade JanDeDobbeleer.OhMyPosh -s winget
# modify execution policy as needed
set-executionpolicy remotesigned
font¶
Install font using oh-my-posh command. This must run on admin powershell. Install Nerd Font.
Nerd Fonts patches developer targeted fonts with a high number of glyphs (icons). Specifically to add a high number of extra glyphs from popular ‘iconic fonts’ such as Font Awesome, Devicons, Octicons, and others.
Navigate to settings > powershell > appearance > font face, and select a font.
posh theme¶
# theme folder location
echo $env:POSH_THEMES_PATH
# theme showcase on powershell
# this command also shows instruction on how to apply the theme
get-poshthemes
Edit $PROFILE file to set oh-my-posh theme when launching terminal.
color scheme¶
https://windowsterminalthemes.dev/
Search for "Cattpuccin Frappe" and click "Get theme" to copy color scheme json to clipboard. Navigate to settings > color scheme, and find "open json file" button on bottom left, click open to edit the color scheme file. Add the copied json in schemes list, and the file should look something like this.
And once the file is updated, navigate to settings > powershell > appearance > color scheme, and select added color scheme.
scoop¶
A command-line installer for Windows
Quick installation commamnds:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
How to use scoop:
scoop --help
scoop list
scoop update
scoop update -a
I have things like 7zip, curl, jq, nodejs, neovim, gcc, and etc. installed using scoop before I setup WSL2.