DEV Community

Kananek T.
Kananek T.

Posted on

1

เรียนภาษาใหม่ก็สนุกดี นะ เหมือน bash+powershell

fnm for Nushell
การเรียนภาษาใหม่ก็สนุกดีนะ โดยเฉพาะเมื่อเปรียบเทียบกับ Bash และ Powershell ที่เราเคยใช้กันอยู่ วันนี้เราจะมาพูดถึง Nushell และวิธีการจัดการกับ environment variables ด้วย fnm (Fast Node Manager) ซึ่งเป็นเครื่องมือที่ช่วยในการจัดการ Node.js เวอร์ชันต่างๆ ได้อย่างสะดวก

การตั้งค่า environment variables ใน Nushell นั้นไม่ยากเลย เราสามารถใช้คำสั่งต่อไปนี้:

load-env (fnm env --shell bash | lines | str replace 'export ' '' | str replace -a '"' '' | split column "=" | rename name value | where name != "FNM_ARCH" and name != "PATH" | reduce -f {} {|it, acc| $acc | upsert $it.name $it.value })
$env.PATH = ($env.PATH | prepend $"($env.FNM_MULTISHELL_PATH)")
Enter fullscreen mode Exit fullscreen mode

คำสั่งนี้จะช่วยเราดึงค่าต่างๆ จาก environment ของ fnm มาสร้างเป็น environment variables ใหม่ใน Nushell ซึ่งทำให้เราสามารถใช้งาน Node.js ได้อย่างราบรื่น

การเรียนรู้ภาษาใหม่ๆ ช่วยให้เราเปิดมุมมองและเรียนรู้วิธีการทำงานที่แตกต่างกันไป ลองเปิดใจและสำรวจ Nushell ดูสิ แล้วคุณจะพบว่ามันสนุกและมีประโยชน์มากทีเดียว!

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more