สิ่งที่ต้องมีก่อน
- Windows Terminal
- Git for Windows
- Powerline font โดยให้ทำการติดตั้ง Cascadia Code PL หรือ Cascadia Mono PL
เริ่มการติดตั้ง
- ใช้ PowerShell เพื่อติดตั้ง Posh-Git และ Oh-My-Posh
Install-Module posh-git -Scope CurrentUser Install-Module oh-my-posh -Scope CurrentUser
- ทำการอนุญาตให้รัน script ที่เพิ่งติดตั้งลงไปได้
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
- สร้าง PowerShell profile เอาไว้รันทุกครั้งที่เริ่มการใช้งาน โดยใช้คำสั่ง
notepad $PROFILE
แล้วเพิ่มข้อความตามนี้
Import-Module posh-git Import-Module oh-my-posh Set-Theme Paradox
- เปลี่ยน font เป็น Cascadia Code PL หรือ Cascadia Mono PL ใน Setting ของ Windows Terminal โดยเพิ่ม
fontFace
{ // Make changes here to the powershell.exe profile. "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "name": "Windows PowerShell", "commandline": "powershell.exe", "fontFace": "Cascadia Code PL", "fontSize": 14, "hidden": false },
หรือจะกำหนดที่ default เพื่อให้ใช้งาน font เดียวกันทั้งหมดก็ได้
"defaults": { "fontFace": "Cascadia Code PL", "fontSize": 14 },
- ทดสอบโดยการเปิด Windows terminal ใหม่อีกรอบ
ใช้ Dracula Dark theme
(Download)[https://draculatheme.com/windows-terminal/]
ติดตั้งโดยการแก้ไขที่ Setting ของ Windows Terminal โดยการเพิ่ม schemes ใหม่ลงไป ซึ่งให้ไป copy จาก dracula.json จาก zip ไฟล์ที่โหลดมา ตัวอย่าง
"schemes": [ { "name": "Dracula", "cursorColor": "#F8F8F2", "selectionBackground": "#44475A", "background": "#282A36", "foreground": "#F8F8F2", "black": "#21222C", "blue": "#BD93F9", "cyan": "#8BE9FD", "green": "#50FA7B", "purple": "#FF79C6", "red": "#FF5555", "white": "#F8F8F2", "yellow": "#F1FA8C", "brightBlack": "#6272A4", "brightBlue": "#D6ACFF", "brightCyan": "#A4FFFF", "brightGreen": "#69FF94", "brightPurple": "#FF92DF", "brightRed": "#FF6E6E", "brightWhite": "#FFFFFF", "brightYellow": "#FFFFA5" } ]
- เปิดใช้งาน โดยการระบุ
colorScheme
ที่profiles
"profiles": { "defaults": { "colorScheme" : "Dracula" } }
เปลี่ยน Directory เริ่มต้น เมื่อเปิด PowerShell
จะต้องไปแก้ไข PowerShell profile โดยใช้คำสั่ง notepad $PROFILE
แล้วเพิ่มข้อความนี้ Set-Location C:\your-start-dir
ลงไป
Import-Module posh-git Import-Module oh-my-posh Set-Theme Paradox Set-Location D:\workspaces
เสร็จแล้วจะได้ออกมาแบบนี้
ใช้งาน PowerShell ใน Visual Studio Code
- ให้แก้ไขการตั้งค่าใน settings.json โดยเพิ่มการตั้งค่า ดังนี้
{ "terminal.integrated.fontFamily": "Cascadia Code PL", "terminal.integrated.fontSize": 14, "terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "terminal.external.windowsExec": "C:\\Users\\sompr\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe", }
เรียบร้อย 🎉🎉🎉
Top comments (3)
ควรจะบอก หรือใส่ Tag นะ ว่า for PowerShell.
ขอบคุณครับที่แนะนำ
MesloLGS NF ที่ใช้ใน Powerlevel10k ใช้ได้มั้ย
พอดีมี WSL ด้วย