The Bash Shell
Bash Shell (Bourne Again Shell) = UNIX shell และ command language เขียนโดย Brian Fox สำหรับ GNU Project แทน Bourne Shell (sh) เปิดตัว 1989 เป็น default shell ในหลาย Linux distros (Kali ใช้ Zsh)
Bash เป็นโปรแกรมแรกที่ Linus Torvalds port ไป Linux
Bash ยังเป็น programming language ด้วย:
#!/bin/bash
echo "Hello World"
Key points about Bash
- ผู้ใช้ส่วนใหญ่ใช้ Bash (default shell)
- ไม่มี inline wildcard expression (wildcards:
*,?,[]) - ไม่สามารถ auto-change directory name ได้
#เป็น comment ใน scripting- มี
shoptsettings - Prompt ใช้ backslash escapes
- User config ใน
.bashrc
The Z Shell (Zsh)
Zsh = UNIX shell คล้าย Bash มาก สคริปต์และใช้เป็น command interpreter ได้ เป็น extension ของ Bourne shell พร้อม improvements มากมาย เปิดตัว 1990 โดย Paul Falstad มี features ร่วมกับ Bash, Korn Shell, C Shell
macOS ใช้ Zsh เป็น default
Key points about Zsh
- Autocompletion: กด Tab ไม่แค่ autocomplete แต่มี dropdown แสดงไฟล์/ไดเรกทอรีที่เป็นไปได้
- รองรับ inline wildcard expressions
- Configurable มากกว่า Bash มาก
- รองรับ plugins และ themes
Frameworks สำหรับ Zsh: Oh My Zsh - community-driven open-source framework จัดการ Zsh config (ผมใช้ Oh My Zsh 😄) Oh My Zsh ≠ Zsh (Oh My Zsh จัดการ config ไม่ใช่ shell เอง)
The Fish Shell
Fish = UNIX shell เน้น interactivity และ usability ไม่เช่น Zsh ที่ให้ user config เอง Fish ให้ interactivity by default
สร้างโดย Axel Liljencrantz 2005 ถือว่า "exotic shell" เพราะไม่ compliant กับ POSIX shell standards
Key points about Fish
- Search-as-you-type suggestions: แสดงคำแนะนำจาก command history และ current directory โดยอัตโนมัติ History search เปิดอยู่ตลอด
- ชอบ features เป็น commands มากกว่า syntax ทำให้ features มองเห็นได้ มี options และ help texts
- Default มาพร้อม configs เยอะ เริ่มต้นง่ายกว่า Zsh สำหรับมือใหม่
- Scripting language ต่างจาก Zsh/Bash: Zsh ใช้ aliases มาก Fish หลีกเลี่ยง aliases
คำสั่งพื้นฐาน (cd, cp, vim, ssh) ไม่ต่างกันใน Fish และ Bash ความต่างใหญ่คือการ capture output:
Bash: todays_date=$(date)
Fish: set date (date)
สรุป
Bash, Zsh, Fish ทุกตัวมีจุดเด่น คล้ายคลึงบ้าง
- อยาก configurable มาก -> Zsh (หรือ Oh My Zsh)
- อยาก interactive terminal ไม่ต้อง config มาก -> Fish
- อยาก classic feel -> Bash
ขึ้นอยู่กับ preference ของคุณในฐานะ developer - เลือก shell ที่เหมาะสมที่สุด