Windows Terminal เป็นการรวมแทนที่ของ command line และ Windows PowerShell ของ Microsoft ให้คุณรันคำสั่งและเครื่องมือการจัดการที่ทรงพลังมากกว่าที่จะทำได้จาก graphical user interface
แทนที่จะสลับเครื่องมือไปมา Windows Terminal ใหม่รวมเครื่องมือเหล่านี้ไว้ด้วยกัน คุณสามารถรัน Windows bash scripts, เชื่อมต่อ Azure virtual machines, และเปิด Windows Subsystem for Linux terminal – ทั้งหมดภายในหน้าต่างเดียว
ติดตั้ง Windows Terminal ใหม่
แอป Windows Terminal ใหม่อยู่ในช่วงพัฒนาอย่างต่อเนื่อง แทนที่จะทดสอบภายใน Microsoft ได้ปล่อย "preview" release ให้ดาวน์โหลดใน Microsoft Store
มีการรองรับ tabbed windows, การแสดงข้อความที่ดีขึ้น, และ advanced configuration ให้คุณปรับแต่ง user profiles สำหรับแอปต่างๆ ยังเป็น open-source หมายความว่าคุณสามารถเข้าไปดูและมีส่วนร่วมพัฒนาได้
คุณยังดาวน์โหลดและ compile latest release เองจาก Github repository ได้ แต่เพื่อโอกาสความเสถียรที่ดีที่สุด ควรใช้ pre-built version ของ Microsoft ยังอยู่ในช่วงทดสอบ อาจยังมีบั๊กบ้าง
- เริ่มต้น: ไปที่ Windows Terminal (Preview) listing บน Microsoft Store website คลิก Get ถ้าใช้ Chrome ให้เปิด Microsoft Store โดยคลิก Open Microsoft Store ใน pop-up หรือค้นหา Windows Terminal ใน Microsoft Store app โดยตรง
- ทำตามขั้นตอนเดียวกันใน Microsoft Store app คลิก Get เพื่อ link แอปกับ Microsoft account แล้ว Install เริ่มติดตั้ง
- ติดตั้งเสร็จ คลิก Launch หรือเข้าถึงจาก Windows Start menu
ใช้งาน Windows Terminal ใหม่
Interface ของแอป Windows Terminal ใหม่ง่ายมาก โดย default จะคล้ายหน้าต่าง Windows PowerShell ปกติ
เพราะ default แท็บแรกที่เปิดจะเป็น PowerShell terminal คุณสามารถใช้ Windows PowerShell ทำ system administration tasks ได้ พร้อมข้อได้เปรียบที่เปิด multiple PowerShell tabs ในหน้าต่างเดียว
นี่คือประโยชน์จริงของ Windows Terminal ใหม่ ให้สลับระหว่างแอปและ terminal shells ต่างๆ ภายในหน้าต่างเดียว คุณสามารถเปิด command line แบบเก่าในแท็บที่สอง และ Azure Cloud Shell จัดการ Azure virtual machines แบบ remote
ถ้าติดตั้ง Windows Subsystem for Linux distributions แล้ว จะแสดงให้เลือก ทำให้เข้าถึง Linux terminal ใน Windows ได้ง่าย
- เปิด PowerShell ใหม่: คลิก plus button ข้างแท็บสุดท้าย เพื่อเปิด tab ประเภทอื่น คลิก downward arrow button เลือกจากรายการตัวเลือกที่มี
เตรียมการกำหนดค่า Windows Terminal
Windows Terminal ใหม่ปรับแต่งได้มาก คุณเปลี่ยน appearance ได้ รวมถึง background, สีข้อความ และ font Microsoft มี pre-set themes ให้สลับ แต่คุณสร้างเองได้ด้วย JSON configuration file
คุณสร้าง custom settings สำหรับแต่ละประเภทของ terminals และแอปที่ Windows Terminal รองรับได้
- แก้ไข JSON file ด้วย Notepad ได้ แต่แนะนำใช้ Notepad++ แอป Windows ของบุคคลที่สาม ที่จัดรูปแบบ JSON ให้ดีกว่า ทำให้แก้ไขง่าย ดาวน์โหลดและติดตั้ง Notepad++ ก่อนเริ่ม
ติดตั้ง Notepad++ แล้ว ต้องตั้งค่า Windows ให้เปิด JSON files ด้วย Notepad++
- ไปที่ default Windows Terminal settings folder เปิด Windows File Explorer พิมพ์ %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState โฟลเดอร์ควรมีไฟล์ profiles.json คลิกขวาไฟล์ แล้ว Open with
- ในเมนูเลือกแอป คลิก More apps แล้ว Look for another app on this PC
- ใน dialog box เลือกแอป ไปที่ default installation location ของ Notepad++ ส่วนใหญ่คือ C:\Program Files (x86)\Notepad++ เลือก Notepad++.exe แล้ว Open
หลังจากนี้ ไฟล์ config profiles.json จะเปิดใน Notepad++ เสมอ คุณเริ่มปรับแต่งประสบการณ์ Windows Terminal ได้จากตรงนี้
ไฟล์การกำหนดค่า Windows Terminal
JSON files ค่อนข้างซับซ้อน แต่ profiles.json ทำงานได้ง่าย ด้วย Notepad++ ที่ตั้งค่าเปิด JSON files อัตโนมัติ คุณเข้าถึง settings file ใน Windows Terminal ได้ตลอด
- เปิด settings file: คลิก downward arrow button ถัดจากแท็บ Windows Terminal แล้วคลิก Settings จะเปิด profiles.json ให้แก้ไข
JSON file มี sections "profiles" แยกกัน ให้แก้ไข profiles สำหรับแต่ละประเภทของแอปและ terminal shell ถ้าอยากเปลี่ยนลักษณะ Windows Terminal ใน PowerShell app ตัวอย่างเช่น หา section PowerShell ใช้บรรทัด "name" หรือ "commandline" หาแต่ละ profile
เพิ่มพื้นหลัง Windows Terminal แบบกำหนดเอง
ถ้าอยากเพิ่ม custom background คัดลอก PNG, JPEG หรือ GIF ที่เหมาะสมไปที่ settings folder ก่อน
- เปิด settings file และภายใต้แต่ละ profile section เพิ่มบรรทัดต่อไปนี้ใต้บรรทัด "commandline":
"backgroundImage" : "ms-appdata:///local/yourimagefile.jpg",
"backgroundImageOpacity" : 0.7,
"backgroundImageStretchMode" : "fill",
- แทนที่ "yourimagefile.jpg" ด้วยชื่อไฟล์รูปของคุณ กด Ctrl + S บันทึก คุณยังปรับ "backgroundImageOpacity" และ "backgroundImageStretchMode" ตามต้องการได้
- บันทึกแล้ว Windows Terminal background จะเปลี่ยนทันทีให้ตรงกับรูปที่ระบุ
เปลี่ยน Color Scheme ของ Windows Terminal ใหม่
เพื่อให้เปลี่ยน color scheme ได้เร็ว มี default themes 5 อัน วิธีการคล้ายวิธีเปลี่ยน background ข้างต้น
- เริ่มด้วยการเปิด settings file และภายใต้แต่ละ profile section เพิ่มบรรทัด:
"colorScheme" : "Campbell",
- กด Ctrl + S บันทึก Windows Terminal จะอัปเดตแสดง scheme ใหม่ทันที
นี่จะเปลี่ยน color scheme สำหรับ app profile ที่เลือกเป็น "Campbell" color scheme ที่มาจาก Microsoft Console Colortool สามารถเปลี่ยนเป็น "One Half Dark", "One Half Light", "Solarized Dark" หรือ "Solarized Light" ได้
สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ Windows Terminal configuration file ดู documentation file ที่ Github repository