---
title: "shell | Today I Learned | OOZOU"
description: "โน้ตสั้นใช้ได้จริงเกี่ยวกับ shell จากทีม OOZOU"
canonical: https://oozou.com/th/til-topics/shell
locale: th
---

# shell | Today I Learned

> โน้ตสั้นใช้ได้จริงเกี่ยวกับ shell จากทีม OOZOU

- [รันคำสั่งแบบ incognito/ส่วนตัวสำหรับ Bash และ Zsh](https://oozou.com/th/til/run-incognito-private-commands-for-bash-and-zsh-112) ([markdown](https://oozou.com/th/til/run-incognito-private-commands-for-bash-and-zsh-112.md)) (2020-12-08): แค่ใส่ space ไว้หน้าคำสั่ง คำสั่งนั้นก็จะไม่ถูกบันทึกลง ~/.bash\_history เช่น  qrencode -o out.png "Some secret text"
- [อัปเกรดฐานข้อมูล postgres ด้วย homebrew](https://oozou.com/th/til/upgrade-postgres-database-with-homebrew-76) ([markdown](https://oozou.com/th/til/upgrade-postgres-database-with-homebrew-76.md)) (2020-10-22): การอัปเกรด postgres ทำได้โดยรัน
- [คัดลอกไฟล์ด้วย Amazon AWS S3 CLI พร้อมกำหนดสิทธิ์](https://oozou.com/th/til/amazon-aws-s3-cli-copy-with-set-perms-14) ([markdown](https://oozou.com/th/til/amazon-aws-s3-cli-copy-with-set-perms-14.md)) (2020-10-13): เปิด term (หรือโปรแกรมที่คล้ายกัน) แล้ววางคำสั่งต่อไปนี้:
- [ล้าง Docker แบบถอนรากถอนโคน](https://oozou.com/th/til/angry-docker-purge-72) ([markdown](https://oozou.com/th/til/angry-docker-purge-72.md)) (2020-10-13): ถ้าคุณเจอ error No Space left บน Docker นี่คือวิธีแก้แบบ brute force:
- [แบ็กอัปไฟล์ด้วยชื่อเดิม + ส่วนต่อท้าย](https://oozou.com/th/til/back-up-a-file-with-same-name-prefix-42) ([markdown](https://oozou.com/th/til/back-up-a-file-with-same-name-prefix-42.md)) (2020-10-13): หมายเหตุ: จริง ๆ แล้วคุณใช้ !#:1 ได้กับทุกคำสั่ง เพราะมันคือ argument สุดท้ายที่ส่งให้คำสั่งนั้น
- [Bash alias และเวทมนตร์เล็ก ๆ](https://oozou.com/th/til/bash-aliases-and-magic-46) ([markdown](https://oozou.com/th/til/bash-aliases-and-magic-46.md)) (2020-10-13): เรามีไฟล์แยกต่างหากในโฟลเดอร์ผู้ใช้ชื่อ ~/.aliases ใช้เก็บ bash alias ทั้งหมด เราใช้ alias บ่อยและเพิ่ม alias ใหม่อยู่เป็นประจำ เลยสร้างฟังก์ชัน bash สำหรับเพิ่ม alias ใหม่…
- [เช็กว่าสินค้า IKEA มีของหรือยัง](https://oozou.com/th/til/check-for-ikea-item-availability-70) ([markdown](https://oozou.com/th/til/check-for-ikea-item-availability-70.md)) (2020-10-13): ถ้าคุณกำลังรอสินค้า IKEA มาเติมสต็อก นี่คือวิธีที่ใช้ได้จริงในการติดตามสถานะแบบอัตโนมัติ บทความนี้จะอธิบายวิธีใช้ shell script เช็กสต็อกของ IKEA และรับ…
- [เช็กว่ามีคำสั่งอยู่หรือไม่ด้วย shell script](https://oozou.com/th/til/check-if-command-exists-with-shell-script-52) ([markdown](https://oozou.com/th/til/check-if-command-exists-with-shell-script-52.md)) (2020-10-13): เช็กว่ามีคำสั่งอยู่หรือไม่ด้วย shell script
- [สร้างคำสั่ง git ของคุณเอง (aliases)](https://oozou.com/th/til/create-your-own-git-commands-aliases-15) ([markdown](https://oozou.com/th/til/create-your-own-git-commands-aliases-15.md)) (2020-10-13): เคยอยากย่อคำสั่ง git ให้สั้นลงไหม? จะใช้ shell alias ก็ได้ แต่ต้องคอยใส่บริบทกำกับไว้ จะได้ไม่ลืมว่า alias แต่ละตัวย่อมาจากอะไร จริง ๆ แล้วคุณสร้างคำสั่งของตัวเอง…
- [ลบ branch ที่ merge ไปแล้วใน Git](https://oozou.com/th/til/delete-already-merged-branchs-in-git-36) ([markdown](https://oozou.com/th/til/delete-already-merged-branchs-in-git-36.md)) (2020-10-13): อยากกัน branch ไหนไว้ไม่ให้ถูกลบ ก็เพิ่มชื่อลงใน egrep -v 'master|develop|foo|bar' ได้เลย
- [ลบ git branch ที่ merge ไปแล้ว](https://oozou.com/th/til/delete-merged-git-branches-51) ([markdown](https://oozou.com/th/til/delete-merged-git-branches-51.md)) (2020-10-13): คำสั่ง git สุดสะดวกสำหรับลบ local git branch ทั้งหมดที่ merge ไปแล้ว git branch --merged | egrep -v "(^\\|master|dev)" | xargs git branch -d*
- [เทียบ diff ไฟล์ local กับเวอร์ชันบน remote ใน Git](https://oozou.com/th/til/diff-a-local-file-with-remote-version-in-git-35) ([markdown](https://oozou.com/th/til/diff-a-local-file-with-remote-version-in-git-35.md)) (2020-10-13): แค่รันคำสั่งด้านล่างก็ได้ diff เทียบกับเวอร์ชันบน remote แล้ว
- [หา branch จาก commit](https://oozou.com/th/til/find-a-branch-based-on-a-commit-53) ([markdown](https://oozou.com/th/til/find-a-branch-based-on-a-commit-53.md)) (2020-10-13): c198bb715 Make default expired description logic pretty `
- [Force push commit ก่อนหน้าขึ้น repo](https://oozou.com/th/til/force-push-previous-commit-to-repo-44) ([markdown](https://oozou.com/th/til/force-push-previous-commit-to-repo-44.md)) (2020-10-13): ถ้า push โค้ดไปแล้วและอยากจะ force push commit ก่อนหน้า ทำได้ด้วย shell git push origin +commit\sha^:branch\name
- [ดูชื่อ branch ปัจจุบันของ git](https://oozou.com/th/til/get-current-git-branch-name-43) ([markdown](https://oozou.com/th/til/get-current-git-branch-name-43.md)) (2020-10-13): ดูชื่อ branch ปัจจุบันของ git
- [ย้อนดู Git history ของไฟล์ (GUI)](https://oozou.com/th/til/go-through-a-file-git-history-gui-67) ([markdown](https://oozou.com/th/til/go-through-a-file-git-history-gui-67.md)) (2020-10-13): ย้อนดู Git history ของไฟล์ (GUI)
- [Kill rails ที่ค้าง](https://oozou.com/th/til/kill-rails-that-got-stuck-63) ([markdown](https://oozou.com/th/til/kill-rails-that-got-stuck-63.md)) (2020-10-13): อยาก kill rails ที่รันอยู่บน port ที่ต้องการ (เครื่องรัน rails server อยู่หลายตัว)
- [Kill SSH session ที่ไม่ตอบสนอง](https://oozou.com/th/til/kill-unresponsive-ssh-session-65) ([markdown](https://oozou.com/th/til/kill-unresponsive-ssh-session-65.md)) (2020-10-13): บางครั้ง SSH session ก็ไม่ตอบสนอง ซึ่งถ้าพักเครื่องแล้วปลุกขึ้นมา อาการนี้จะเกิดค่อนข้างบ่อย แทนที่จะปิด tab ทิ้ง เราใช้ SSH Escape Characters เพื่อ kill session ได้
- [แสดงโครงสร้าง directory โดยยกเว้นบาง dir](https://oozou.com/th/til/list-directory-structure-except-one-or-more-dirs-24) ([markdown](https://oozou.com/th/til/list-directory-structure-except-one-or-more-dirs-24.md)) (2020-10-13): เคยอยากแสดงโครงสร้างของ directory ปัจจุบันโดยยกเว้นสักหนึ่งหรือสอง directory ไหม?
- [สร้าง pr จาก command line ด้วย hub](https://oozou.com/th/til/make-a-pr-from-command-line-using-hub-3) ([markdown](https://oozou.com/th/til/make-a-pr-from-command-line-using-hub-3.md)) (2020-10-13): ติดตั้ง hub ด้วย brew ก่อน: brew install hub จากนั้นใช้คำสั่งง่าย ๆ ตามตัวอย่างด้านล่าง: hub pull-request -m "best pr ever" -b oozou:develop -h feature/awesome-improvements
- [ลบ commit ที่ไม่ต้องการออกจาก branch](https://oozou.com/th/til/remove-unwanted-commit-from-your-branch-34) ([markdown](https://oozou.com/th/til/remove-unwanted-commit-from-your-branch-34.md)) (2020-10-13): ลบ commit ที่ไม่ต้องการออกจาก branch
- [กู้คืนไฟล์ที่ถูกลบใน Git](https://oozou.com/th/til/restore-a-deleted-file-in-git-5) ([markdown](https://oozou.com/th/til/restore-a-deleted-file-in-git-5.md)) (2020-10-13): กู้คืนไฟล์ที่ถูกลบใน Git
- [รันคำสั่งเดิมกับ input ที่แตกต่างกัน](https://oozou.com/th/til/run-same-command-on-different-input-inputs-71) ([markdown](https://oozou.com/th/til/run-same-command-on-different-input-inputs-71.md)) (2020-10-13): ถ้าคุณต้องรันคำสั่งเดิมซ้ำ ๆ กับ input ที่แตกต่างกัน
- [ดูไฟล์ที่ถูกลบใน commit ก่อนหน้า [git]](https://oozou.com/th/til/see-deleted-files-in-previous-commits-git-60) ([markdown](https://oozou.com/th/til/see-deleted-files-in-previous-commits-git-60.md)) (2020-10-13): ดูไฟล์ที่ถูกลบใน commit ก่อนหน้า [git]
- [ส่งข้อความไปยัง Slack ด้วย cURL](https://oozou.com/th/til/send-messages-to-slack-using-curl-26) ([markdown](https://oozou.com/th/til/send-messages-to-slack-using-curl-26.md)) (2020-10-13): Slack ให้คุณส่งข้อความผ่านบริการ Webhooks ได้
- [Shallow clone repo เก่า](https://oozou.com/th/til/shallow-clone-a-old-repo-2) ([markdown](https://oozou.com/th/til/shallow-clone-a-old-repo-2.md)) (2020-10-13): ถ้าไม่ต้องการประวัติ git ทั้งหมดของ repo ที่จะทำงานด้วย ให้ระบุ depth ตอน clone เพื่อดึงมาแค่ x revision
- [ใช้ `host` เพื่อดูข้อมูลเพิ่มเติมเกี่ยวกับโดเมน](https://oozou.com/th/til/use-host-to-get-more-information-about-domains-20) ([markdown](https://oozou.com/th/til/use-host-to-get-more-information-about-domains-20.md)) (2020-10-13): คุณอาจใช้ dig เพื่อหา record ประเภท A/CNAME/MX และอื่น ๆ ของโดเมนจาก DNS server แต่ถ้าแค่อยากได้ภาพรวมแบบเร็ว ๆ ให้ใช้ host:
- [ใช้ฟีเจอร์ alias ของ Git](https://oozou.com/th/til/using-git-s-aliases-feature-61) ([markdown](https://oozou.com/th/til/using-git-s-aliases-feature-61.md)) (2020-10-13): Git ให้คุณสร้าง alias ได้ในตัวผ่าน config โดย config แบบ global ควรอยู่ที่ ~/.gitconfig
- [เฝ้าดูสถานะ CI บน Github](https://oozou.com/th/til/watch-ci-status-on-github-47) ([markdown](https://oozou.com/th/til/watch-ci-status-on-github-47.md)) (2020-10-13): ถ้าติดตั้ง hub ของ Github ไว้แล้ว ดู ci-status ของ branch ปัจจุบันได้แบบนี้:
- [ฟังก์ชัน Zsh สำหรับแสดง file tree](https://oozou.com/th/til/zsh-function-to-list-file-tree-17) ([markdown](https://oozou.com/th/til/zsh-function-to-list-file-tree-17.md)) (2020-10-13): เวลาทำงานกับ Directory บน command line ถ้าเห็นโครงสร้าง Directory และ Directory ย่อยเป็นแบบ "tree" จะช่วยได้มาก มีเครื่องมือให้เลือกเยอะ เช่น...

All notes: [Today I Learned](https://oozou.com/th/til) ([markdown](https://oozou.com/th/til.md)).

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/th/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
