<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>~iany/ Dev Environment</title><link>https://blog.iany.me/tags/dev-environment/</link><description>Recent content in Dev Environment «~iany/»</description><language>en-US</language><managingEditor>me@iany.me (Ian Yang)</managingEditor><webMaster>me@iany.me (Ian Yang)</webMaster><copyright>CC-BY-SA 4.0</copyright><lastBuildDate>Sat, 07 Feb 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://blog.iany.me/tags/dev-environment/index.xml" rel="self" type="application/rss+xml"/><item><title>Use Bun for Shell Scripts</title><link>https://blog.iany.me/2026/02/use-bun-for-shell-scripts/</link><pubDate>Sat, 07 Feb 2026 00:00:00 +0800</pubDate><author>me@iany.me (Ian Yang)</author><guid>https://blog.iany.me/2026/02/use-bun-for-shell-scripts/</guid><description>&lt;p&gt;I&amp;rsquo;ve moved most of my small scripts to Bun. It sidesteps Windows&amp;rsquo; lack of shebang support and the Git-for-Windows/WSL bash dance, and gives you one runtime for both ad-hoc shell-style commands and full scripts.&lt;/p&gt;
&lt;h2 id="problems-bun-solves"&gt;Problems Bun solves&lt;/h2&gt;
&lt;p&gt;Windows doesn&amp;rsquo;t execute &lt;code&gt;#!/usr/bin/env python3&lt;/code&gt; or &lt;code&gt;#!/bin/bash&lt;/code&gt;, so scripts written for Linux or macOS usually need a separate PowerShell version. Bun compiles JavaScript to native executables, so a single script can run cross-platform without shebangs.&lt;/p&gt;
&lt;p&gt;Mise &lt;a href="https://mise.jdx.dev/tasks/file-tasks.html"&gt;file tasks&lt;/a&gt; have started to support shebangs on Windows in the latest release, but they rely on system &lt;code&gt;bash.exe&lt;/code&gt;, which often points at WSL. Bun does not. You run &lt;code&gt;bun ./script.js&lt;/code&gt; and embed shell commands via &lt;code&gt;Bun.$&lt;/code&gt;; the script uses Bun&amp;rsquo;s bundled bash environment.&lt;/p&gt;
&lt;h2 id="why-bun-for-shell-scripts"&gt;Why Bun for shell scripts&lt;/h2&gt;
&lt;p&gt;The command &lt;code&gt;bun build ./script.ts --compile --outfile script&lt;/code&gt; &lt;a href="https://bun.com/docs/bundler/executables"&gt;produces a single binary&lt;/a&gt;, so no shebang or interpreter is needed on Windows. The &lt;code&gt;Bun.build&lt;/code&gt; API is available too; I use a &lt;code&gt;build.js&lt;/code&gt; script to walk a directory and compile all executables. Pre-built binaries start quickly—Bun&amp;rsquo;s docs cite ~5ms vs Node&amp;rsquo;s ~25ms for a simple script, which helps for small, frequently run scripts.&lt;/p&gt;
&lt;p&gt;Bun has strong support for shell-style scripting. &lt;a href="https://bun.com/docs/runtime/shell"&gt;Bun Shell&lt;/a&gt; runs bash commands; the main entry point is &lt;code&gt;Bun.$&lt;/code&gt;, which constructs shell commands from template literals for safe interpolation, similar to &lt;a href="https://github.com/google/zx"&gt;google/zx&lt;/a&gt;. On Windows, Bun ships with MSYS, so you get a consistent bash environment and common Linux CLI tools without extra setup.&lt;/p&gt;
&lt;p&gt;Other useful features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Bun.secrets&lt;/code&gt;—Securely store and retrieve secrets using the OS keystore (Windows Credential Manager, macOS Keychain, Linux libsecret). &lt;a href="https://bun.com/docs/api/secrets"&gt;Secrets - Bun&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Built-in support for glob patterns, YAML parsing, ANSI colors, and more. &lt;a href="https://bun.com/docs/runtime"&gt;Bun Runtime&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="short-example"&gt;Short example&lt;/h2&gt;
&lt;pre&gt;&lt;code class="language-javascript"&gt;import { $ } from &amp;quot;bun&amp;quot;;
const out = await $`echo hello`.text();
console.log(out); // hello
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run it with &lt;code&gt;bun run script.js&lt;/code&gt; or &lt;code&gt;bun ./script.js&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="obsidian-notes"&gt;Obsidian Notes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kb.iany.me/para/lets/d/Development&amp;#43;Environment/JavaScript&amp;#43;Shell&amp;#43;Scripting"&gt;JavaScript Shell Scripting&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><category domain="https://blog.iany.me/post/">Posts</category><category domain="https://blog.iany.me/tags/bun/">Bun</category><category domain="https://blog.iany.me/tags/javascript/">JavaScript</category><category domain="https://blog.iany.me/tags/script/">Script</category><category domain="https://blog.iany.me/tags/windows/">Windows</category><category domain="https://blog.iany.me/tags/dev-environment/">Dev Environment</category></item><item><title>My Windows Environment Setup</title><link>https://blog.iany.me/2020/05/my-windows-environment-setup/</link><pubDate>Sun, 03 May 2020 22:03:22 +0800</pubDate><author>me@iany.me (Ian Yang)</author><guid>https://blog.iany.me/2020/05/my-windows-environment-setup/</guid><description>&lt;p&gt;I have only one Windows device, the Surface Go. I work on it occasionally, especially on short trips. I prefer Surface Go because of handwriting. I have a simple setup to meet my work requirements.&lt;/p&gt;
&lt;p&gt;I spend the most time on a computer in three apps: terminal, text editor and web browser. I use Windows Terminal, Visual Studio Code and Chrome in Windows.&lt;/p&gt;
&lt;p&gt;I use &lt;a href="https://github.com/microsoft/terminal/tree/master/src/tools/ColorTool"&gt;ColorTool&lt;/a&gt; to convert my favorite theme &lt;a href="https://github.com/aseom/dotfiles/blob/master/osx/iterm2/papercolor-light.itermcolors"&gt;PaperColor&lt;/a&gt; into Windows Terminal schema. &lt;a href="https://gist.github.com/doitian/4677ce2da2eca2eccbb1637ef804bed1"&gt;This&lt;/a&gt; is my full Windows Terminal config file.&lt;/p&gt;
&lt;p&gt;Since I don&amp;rsquo;t do heavy development locally, I use PowerShell as default in the Windows Terminal. The command &lt;code&gt;echo $profile&lt;/code&gt; will print the PowerShell config file path. The essential PowerShell config is enabling the Emacs style keybinding (full version &lt;a href="https://gist.github.com/doitian/db79d2dbfaa24093534c7411b0a926bd"&gt;here&lt;/a&gt;).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Set-PSReadLineOption -EditMode emacs
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="https://scoop.sh/"&gt;Scoop&lt;/a&gt; is very handy to install essential command line utilities, for example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;scoop install mingit ripgrep
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I use the OpenSSH Client component in Windows, which can be enabled in &amp;ldquo;Settings / Apps / Manage optional features&amp;rdquo;. I used to set an SSH passphrase, but the ssh agent service is disabled. It can be enabled in PowerShell ran as admin:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Run once as admin
Get-Service ssh-agent | Set-Service -StartupType manual
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I have set the startup type to manual, so if I want to load the key, I have to start the service first:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Start-Service ssh-agent
ssh-add
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, the git installed by scoop uses its own bundled ssh client by default. It is easy to fix it by setting an environment variable &lt;code&gt;GIT_SSH&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Run once as logged in user
$SSHPath = (Get-Command -Name 'ssh.exe').Source
[Environment]::SetEnvironmentVariable('GIT_SSH', $SSHPath, 'User')
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Restart Windows Terminal and now git will use the key in ssh agent.&lt;/p&gt;
&lt;p&gt;Git has the same issue with GPG. Use &lt;code&gt;git config&lt;/code&gt; to tell where the GPG program is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git config --global gpg.program (Get-Command -Name 'gpg.exe').Source
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Following is a list of other apps I used in Windows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;XMind: Mindmap tool.&lt;/li&gt;
&lt;li&gt;Drawboard PDF: PDF reading and annotation.&lt;/li&gt;
&lt;li&gt;Leonardo: an infinite canvas painting app.&lt;/li&gt;
&lt;li&gt;Nebo: Handwriting notebook.&lt;/li&gt;
&lt;li&gt;Clash for Windows&lt;/li&gt;
&lt;li&gt;OneDrive and Google Keep for quickly synchronize data with other devices.&lt;/li&gt;
&lt;/ul&gt;</description><category domain="https://blog.iany.me/post/">Posts</category><category domain="https://blog.iany.me/tags/dev-environment/">Dev Environment</category><category domain="https://blog.iany.me/tags/windows/">Windows</category></item></channel></rss>