Replies: 1 comment
-
|
Current workaround: #!/usr/bin/env -S bun --no-warnings
import { $ as bun$ } from 'bun'
// Bun’s shell does not currently have a built‑in “trace”/verbose mode like Bash’s set -x, so there is no $.verbose(true) option for now.
// We can create a Proxy around it to log the commands being run.
// @see https://github.com/oven-sh/bun/discussions/13054
const $ = new Proxy(bun$, {
apply(target, thisArg, args) {
const [strings, ...values] = args as [TemplateStringsArray, ...unknown[]]
// Build a readable version of the command.
// (This is for logging; Bun still does its own escaping/execution.) [web:8]
const cmd = strings
.map((s, i) => s + (i < values.length ? String(values[i]) : ''))
.join('')
.trim()
console.error(`\x1b[2m\x1b[90m$ ${cmd}\x1b[0m`)
return Reflect.apply(target, thisArg, args)
},
}) as typeof bun$
$`echo "Hello World"` |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Basically this https://stackoverflow.com/questions/2853803/how-to-echo-shell-commands-as-they-are-executed but for bun shell.
Similar I can think of is setting the env var
BUN_CONFIG_VERBOSE_FETCH=curlto showfetchas curl. That's a fabulous idea I love and helps a lot for debugging and quick prototyping.Could we get something similar for Bun shell? Either a
$.verbose(true)or aBUN_CONFIG_VERBOSE_SHELL?Beta Was this translation helpful? Give feedback.
All reactions