[PowerShell] Windows Terminal๊ณผ oh my posh๋ก Powershell์ ๋ ์ด์๊ฒ ์ฌ์ฉํ๊ธฐ
๊ฐ์ธ์ ์ผ๋ก Windows๋ฅผ ์ธ ์ผ์ด๋ผ๊ณค ๋ง์ด ์์์ต๋๋ค. ๊ฐ๋ฐ์ ๋๋ถ๋ถ Linux ํน์ OS X์์ ์งํํ๊ณ , Windows๋ ๊ฒ์ ๋จธ์ ์ด๋ Windows binary ๊ฐ๋ฐ ์ธ์๋ ๊ฑฐ์ ์ธ ์ผ์ด ์์์ผ๋๊น์.
๊ทธ๋ฐ๋ฐ, ์ต๊ทผ Windows Terminal์ ๋ณด๊ณ ์ด์ Powershell๋ ๊พธ๋ฏธ๋ ์๋๊ฐ ์๋ค๋ ๊ฒ์ ๋๋ผ๋ฉฐ ์ฌ์ฉ๊ธฐ์ ํจ๊ป ์ด๋ป์ง Windows Terminal์ ์๊ฐํ๊ณ ์ ํฉ๋๋ค.
๋ฑ๋ฑํ๋ค ๋ชปํด ์น์ํ์ง ์์ Powershell๊ณผ CMD
Windows ๋ช ๋ น ํ๋กฌํฌํธ๋ ๊ทธ์ผ๋ง๋ก ๋ ๊ฑฐ์๋ฅผ ์์งํ๋ ํ๋ก๊ทธ๋จ์ ๋๋ค.
๊ทธ๋ฅผ ๋์ฒดํ๊ธฐ ์ํด Windows Server 2008๊ณผ Windows Vista์์๋ถํฐ Powershell์ ๋์ ํ์ง๋ง ์คํฌ๋ฆฝํธ๋ ํ๋ถํ๊ฒ ์ง์ํ๋๋ผ๋ ์น์ํ์ง ์์ UI ๋ฑ์ ์ ์๊ฒ ๋ ์ด์ง๊ฐ์ด์์ต๋๋ค ใ ใ
Windows Terminal
Microsoft Store์์ Windows Terminal์ ๊ฒ์ํ๋ฉด ์๋์ ๊ฐ์ด Windows Terminal์ ๋ค์ด๋ก๋ ๋ฐ์ ์ ์์ต๋๋ค.
Windows Terminal์ ๊ณผ๊ฑฐ Microsoft์ ์ ์ฑ ๊ณผ ๋ฌ๋ฆฌ ์คํ ์์ค ์ํํธ์จ์ด์ด๋ฉฐ ์์ง์ Windows OS ์ธ์๋ ์ง์ํ์ง ์์ต๋๋ค.
https://github.com/microsoft/terminal
GitHub - microsoft/terminal: The new Windows Terminal and the original Windows console host, all in the same place!
The new Windows Terminal and the original Windows console host, all in the same place! - GitHub - microsoft/terminal: The new Windows Terminal and the original Windows console host, all in the same...
github.com
Windows Terminal์ ์คํ์์ผ๋ณด๋ฉด ๊ธฐ์กด Powershell, ๋ช ๋ น ํ๋กฌํฌํธ๋ณด๋ค ๊น๋ํ ํฐํธ๋ฅผ ์ฌ์ฉํ ์ ์๊ณ , ๊ฑฐ๊ธฐ์ ํญ๊น์ง ์ง์ํ๋ ๋ชจ์ต์ ๋๋ค. ํ์ง๋ง ์ด๊ฑธ๋ก๋ ์์ง Windows Terminal์ด ๋งค๋ ฅ์ ์ด์ง ์์ต๋๋ค.
Oh my posh
Linux ํน์ Mac OS X๋ฅผ ์ฐ์๋ ๋ถ๋ค์ด๋ผ๋ฉด bash ํน์ zsh๋ฅผ ์ฐ์ค ๊ฒ์ ๋๋ค. ํนํ zsh๋ฅผ ์ฐ์๋ ๋ถ๋ค ์ค ์กฐ๊ธ ๊ฐ์ฑ์ ์ด๋ผ๋ฉด oh my zsh๋ฅผ ์ฌ์ฉํ์๋ ๋ถ๋ค์ด ์์ต๋๋ค.
Windows์์๋ Powershell์ด ๊ทธ๊ฒ์ ๋์ฒดํฉ๋๋ค. ๊ทธ๋์ ์ด๋ฆ์ Oh my posh(Powershell)์ด๋ผ๊ณ ํ๋ฉฐ Oh my zsh์ ์ ์ฌํ ์คํ์ผ์ ์ง๋๊ณ ์์ต๋๋ค.
Home | Oh My Posh
A prompt theme engine for any shell.
ohmyposh.dev
Oh My Posh๋ Windows์์ ๊ณต์์ ์ผ๋ก ์ ๊ณตํ๋ ํจํค์ง ๋งค๋์ ์ธ winget์ ์ด์ฉํด์ ์ค์นํ ์ ์์ต๋๋ค.
> winget install JanDeDobbeleer.OhMyPosh -s winget
> oh-my-posh.exe
Windows Terminal์ ์ข ๋ฃํ ๋ค ์ฌ์คํํ๊ณ , ์ ๋ช ๋ น์ด๋ฅผ ์ณค์ ๋ ์๋์ ํ๋ฉด์ด ๋์ค๋ฉด ์ค์น๊ฐ ์ ๋๋ ๊ฒ์ ๋๋ค.
์ด์ ์ค์น๊ฐ ๋๋ฌ์ผ๋ ํ ๋ง๋ฅผ ์ ํํ๋๋ก ํ๊ฒ ์ต๋๋ค.
https://ohmyposh.dev/docs/themes
Themes | Oh My Posh
Oh My Posh comes with many themes included out-of-the-box. Below are some screenshots of the more common themes.
ohmyposh.dev
Oh My Posh์์ ์ ๊ณตํ๋ ํ ๋ง๋ ์ ์ฌ์ดํธ์์ ๋ณด์ค ์ ์์ต๋๋ค.
์ ๋ ์ฌ๊ธฐ์ iTerm2 ํ ๋ง๋ฅผ ์ ์ฉํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
> oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\iterm2.omp.json" | Invoke-Expression
POSH_THEMES_PATH ๊ฒฝ๋ก ๋ค์ชฝ์ ์์ ์ด ์ํ๋ ํ ๋ง ์ด๋ฆ์ ์ง์ ํ๋ฉด ๋ฉ๋๋ค.
๊ทธ๋ฐ๋ฐ... ์ด๋ผ? ๊ธ์๊ฐ ๊นจ์ ธ ๋ณด์ด๋ค์.. ใ ใ
Oh my posh๋ฅผ ์๋ฒฝํ๊ฒ ์ฌ์ฉํ๋ ค๋ฉด Nerd Font๊ฐ ํ์ํฉ๋๋ค. ๋ฐ๋ผ์ ์ฐ๋ฆฌ๋ Nerd font๋ฅผ ์ค์นํด์ผ ํฉ๋๋ค.
> oh-my-posh font install
oh my posh ๋ช ๋ น์ด๋ก font install์ ์งํํฉ๋๋ค.
ํค๋ณด๋ ์ํ ํค๋ฅผ ์ด์ฉํด ์ํ๋ ํฐํธ ์ค ํ๋๋ฅผ ์ ํํฉ๋๋ค.
(์ด ๋๋ถํฐ๋ Terminal์ด ๊ด๋ฆฌ์ ๋ชจ๋๋ก ์คํ๋์ด์ผ ํฉ๋๋ค!)
ํฐํธ ์ค์น๊ฐ ๋๋ฌ์ผ๋ฉด Ctrl + Shift + , ๋จ์ถํค๋ฅผ ๋๋ฆ ๋๋ค. ๊ทธ๋ฌ๋ฉด settings.json ํ์ผ์ด ํธ์ง๊ธฐ๋ก ์คํ๋๋๋ฐ, 38๋ฒ ์ค์ ์๋ default์ ์ฐ๋ฆฌ๊ฐ ์ค์นํ ํฐํธ๋ฅผ ๋ฃ์ด์ค๋๋ค.
๊ทธ๋ฌ๋ฉด ๊นจ์ง ๊ธ์๊ฐ ์์ด์ฝ์ผ๋ก ๋ณํฉ๋๋ค.
์ฌ๊ธฐ์ ์ฐ๋ฆฌ๋ ํ ๋ง๋ฅผ ์์ง ์๋ฒฝํ๊ฒ ์ ์ฉํ ๊ฒ์ด ์๋๋๋ค. ๊ทธ์ ํด๋น ์์์๋ง ํ ๋ง๋ฅผ ์ ์ฉํ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ ๋ค์์ ๋ค์ ์์ ์คํํ์ ๋๋ ํด๋น ํ ๋ง๋ก ์คํํ ์ ์๋๋ก ํ๋กํ์ ์ ์ฅํด์ผ ํฉ๋๋ค.
ํ์ฌ ํ ๋ง๊ฐ ๋ง์์ ๋ ๋ค๋ฉด ๋ค์ ๊ณผ์ ์ผ๋ก ๊ณ์ ์งํํ๊ณ , ํ ๋ง๋ฅผ ๋ฐ๊พธ๊ณ ์ถ๋ค๋ฉด oh-my-posh init ๋ช ๋ น์ด๋ก ๋์๊ฐ๋๋ค.
> notepad.exe $PROFILE
๋ฉ๋ชจ์ฅ์ผ๋ก Powershell ํ๋กํ์ ๋ถ๋ฌ์ต๋๋ค.
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\iterm2.omp.json" | Invoke-Expression
ํ ๋ง๋ฅผ ์ง์ ํ๋ ๋ช ๋ น์ด๋ฅผ ํ๋กํ์ ์ถ๊ฐํฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ Windows Terminal์ ์คํํ๋ฉด ์ด์ ํด๋น ํ ๋ง๋ก Powershell์ด ์คํ๋ฉ๋๋ค.
Terminal-Icons
Powershell์์๋ ls ํน์ Get-Items ๋ช ๋ น์ด๋ก ํ์ฌ ๋๋ ํฐ๋ฆฌ์ ์๋ ํ์ผ์ ํ์ํ ์ ์์ต๋๋ค.
ํ์ง๋ง ๋๋ ํฐ๋ฆฌ์ ํ์ผ ๊ตฌ๋ถ์ด ์ด๋ ต์ต๋๋ค. ์ด๋ฅผ ์ํด Terminal Icons๋ฅผ ์ด์ฉํ๋ฉด ์ข ๋ ๊น๋ํ๊ฒ ํ์ผ์ ํ์ํด ๋ณผ ์ ์์ต๋๋ค.
> Install-Module -Name Terminal-Icons -Repository PSGallery
Nuget์ผ๋ก Terminal-Icons๋ฅผ Github Repository์์ ๋ค์ด๋ก๋ ๋ฐ์ต๋๋ค.
> Import-Module -Name Terminal-Icons
๊ทธ๋ฐ ๋ค์ Import-Module๋ก ์์ด์ฝ์ Importํฉ๋๋ค.
๊ทธ๋ฌ๋ฉด ์ข ๋ ๊น๋ํ ls ๋ช ๋ น์ด๋ก ๋ฐ๋๋๋ค.
๋ง์น๋ฉฐ...
์ค๋๋ง์ Windows ํฌ์คํ ์ ์ฌ๋ฆฌ๊ฒ ๋์์ต๋๋ค. PowerShell์ ๊พธ๋ฉฐ์ ์ด์ง๋ ๊ฝค ๋์ง๋ง ๋น์์ Windows Terminal์ด ์์ง Preview ๋ฒ์ ์ด์๊ธฐ์ ํฌ์คํ ์ ์กฐ๊ธ ๊บผ๋ คํ์์ต๋๋ค.
์ด์ ์ ์ ๋ฒ์ ์ด๊ณ , Windows CLI ํ๊ฒฝ๋ ๋ฐ์ ํด๋๊ฐ๋ ์ถ์ธ๋ ์กฐ๊ธ์ ์ง์ผ๋ณผ๋งํ ์ปจํ ์ธ ๊ฐ ๋ ๊ฑฐ ๊ฐ์ต๋๋ค.