Open manast opened 11 months ago
I thought this was a feature of bash that all commands got for free, maybe something in bun is preventing this default behaviour?
No. Bash completions need to be written manually, so Bun will need to create their own.
Ah ok. I think bun does actually have its own, and that's why it is not working as expected. For example, if I type bun
and press TAB, I get something like:
-- scripts --
dev start
-- command --
add -- Add a dependency to package.json
bun -- Generate a bundle
create -- Create a new project
dev -- Start a dev server
help -- Show command help
install -- Install packages from package.json
pm -- Manage local packages
remove -- Remove a dependency from package.json
run -- Run a script or package bin
upgrade -- Upgrade to the latest version of bun
x -- Run a command from a local or remote NPM package
-- files --
But if I type bun sr
and the press TAB it does not autocomplete to the src
directory, whereas if I just type any other unix command or even an unexisting command, it will autocomplete the directory and let me navigate in the files by tabbing.
I don't think you're supposed to call bun example.js
to directly run a file. Don't you mean bun run example.js
?
Aha. Using "bun run" the autocomplete actually works. But you can use bun without run and it works the same (besides autocomplete), for example:
bun --watch src/index.ts
I see. I've never used a program that could put keywords/commands and file paths in the same field before, so I wouldn't know if this is a Bun problem or a bash-completion
problem.
For reference, Bash completions are just shell scripts. If you're at all familiar with Bash scripting, maybe you'd want to take a look at Bun's completions script to see if you can narrow down the issue.
Autocompletion works with bun run ...
, not with bun ...
(bun@1.1.6
).
bun's bash autocomplete works badly actually, like it behaves completely differently than any other Unix command... I am surprised nobody seems to care 🤷♂️
What is the problem this feature would solve?
Since Bun's early days, I have been annoyed by this missing feature: bash autocomplete does not work! https://sourabhbajaj.com/mac-setup/BashCompletion/ On all Unix commands, I expect bash autocompletion to work, this is specially annoying if you want to use bun to execute a script that is inside a nested directory. Not sure why it is not working on bun, I thought this was a feature of bash that all commands got for free, maybe something in bun is preventing this default behaviour?
What is the feature you are proposing to solve the problem?
Fix bun so that autocompletion works.
What alternatives have you considered?
None.