Readit News logoReadit News
Posted by u/cpendery 2 years ago
Show HN: Inshellisense – IDE style shell autocompletegithub.com/microsoft/insh...
I built this terminal native runtime for Fig's autocomplete to support Windows and Linux. Would appreciate any feedback on it!
dolmen · 2 years ago
The implementation has obviously never been run on a Unix/Linux:

* shell config is created with CRLF https://github.com/microsoft/inshellisense/issues/8

* changing directory doesn't work https://github.com/microsoft/inshellisense/issues/5

suavesito · 2 years ago
It doesn't work on Windows either... at least by a comment in the issue. I don't have Windows.

Dead Comment

theusus · 2 years ago
Not up to the mark with https://github.com/marlonrichert/zsh-autocomplete which works contextually.
monkellipse · 2 years ago
Great idea! Also terrifying :) Given how often I accidentally commit the wrong text in vscode, I shudder to think of the damage I could do with this on my shell, hah! What safety measures are there/could there be?
graypegg · 2 years ago
I don't know how painful it would be, but I think I could adapt to a short delay of maybe 50-100ms where the shell won't respond to Return presses, only after accepting a completion. Just long enough ideally to make me re-read what I entered.
biellls · 2 years ago
A simple approach might be that if the resulting exit code is not 0 it won't be used to complete in the future.
Eavolution · 2 years ago
That'd have the problem of tools like grep returning nothing, having an exit code of 1, but being a perfectly valid thing to suggest in the future.
starttoaster · 2 years ago
When you're writing, building, and executing code, I would not expect a 0 exit code every time.
KRAKRISMOTT · 2 years ago
The fish approach
owlstuffing · 2 years ago
Generally, a destructive shell command prompts for approval. But I suppose overfumbly fingers could still cause grief.

Type/command aware tooling is a night and day difference.

mksybr · 2 years ago
Generally? Do you have examples in mind? The ones I think of are destroy first and ask questions only if told to do so: mv cp rm redirection tee
tombert · 2 years ago
I feel like I've trashed millions of files I shouldn't have with `rm` and trying to be clever with regular expressions.
Too · 2 years ago
This is cool.

What is sad is that it has to rely on a library of completion specs. It shows what kind of stone age foundations we are building on top of. The world would have been a much better place if CLIs themselves defined strict interfaces using standard data structures. Not only for auto completion, also gives much more accurate error checking of bash scripts. Same goes for data piped in and out of command.

delta_p_delta_x · 2 years ago
To do this, you'd have to have some sort of common runtime, and nearly all command-line utilities would have to be compiled with said runtime, so that the parameters, names, and types of parameters for said utilities could be returned, parsed, and verified as a data structure, without having to manually parse the output of some `command --help` invocation.

It would thoroughly dispense with the whole argument parsing routine in the first place, which could now be done in a standardised manner; arguments could be defined as strict types with possible values limited to a set, and best of all, they wouldn't just be a dictionary/hash-map of strings to strings—the arguments could actually be named variables with values, in the context of the called utility.

It would certainly be quite a powerful shell, and I'm sure something similar has already been done. I just can't think of an example..... A Powerful shell, running on some Common Language Runtime; I wonder what it could be.

erezsh · 2 years ago
It's sad. If the world of software had better coordination and cooperation, we would be able to get so much more done. Instead we're constantly dumping and re-parsing the same data, re-implementing the same protocols and algorithms in dozens of different languages, each time with different quirks. Fixing the same bugs again and again.
Eisenstein · 2 years ago
All we need is something that will tell us who is right and then impose that vision on everyone.
runeks · 2 years ago
> The world would have been a much better place if CLIs themselves defined strict interfaces using standard data structures.

Well it's not too late just yet.

How about if all CLI exes had an option, say --dump-cli-options, that wrote out a spec of the supported commands/flags/options?

Something like e.g. Python's argparse should be able to effortlessly spit out this info (and the same for other similar argument parsing libraries).

runeks · 2 years ago
And we would also need an options that does CLI argument parsing only, and either returns an error related to parsing one or more options or "ok".

This could be used to do "form validation" of CLI args as they're typed in the shell.

hahn-kev · 2 years ago
Lots do it's called help. But then they would all have to use the same spec, which we know would never happen.
pests · 2 years ago
Like PowerShell?
efitz · 2 years ago
So I have to take a shell dependency on Node.js?

Hard pass

creatonez · 2 years ago
I don't mind it, it's just another runtime that works on Linux and BSD. I have my neovim infected with extensions made in Node.js, Python, Lua, my weechat is infected with extensions made in Python, Perl, Node.js, and my zsh is infected with extensions with components made in Rust, C, and Python. Just make sure to pay attention to shell start times and RAM usage.
preciousoo · 2 years ago
Maybe the users don’t care about their devices
pelagicAustral · 2 years ago
Haha, I though the same...

> npm install

NEXT!

ilc · 2 years ago
For those who haven't read the code:

This reuses Fig.io's internal completion engine to actually get the job done.

Because of that, it forces the language choice of Typescript, and the heavy lift is done by Fig's engine.

I hope the OP continues with the work and improves it. I was looking forward to trying Fig on Linux. This sounds like a step towards that.

hiAndrewQuinn · 2 years ago
Alternatively, if you simply wish to occasionally bring Copilot into your shell, you should know that Ctrl+X Ctrl+E (on bash) / Alt+E (on fish) will open your current shell line up in $EDITOR, which you may set to Vim or Neovim.

From there, :wq will drop the text back into your command line. If you have Copilot set up in either of those, then it will also work here.

I know from working on https://github.com/hiAndrewQuinn/shell-bling-ubuntu that Neovim's LazyVim setup now supports Copilot out of the box now. I never had much trouble setting up the Vim plugin either. YMMV.

lloeki · 2 years ago
If using bash in vi mode instead of emacs mode: ESC v.

zsh starts minimal, so one needs the following for such a feature to be operational:

    # enable
    autoload edit-command-line
    zle -N edit-command-line

    # bash-like emacs mode shortcut
    bindkey "^X^E" edit-command-line
    # bash-like vi mode shortcut
    bindkey -M vicmd v edit-command-line

mschrage · 2 years ago
Co-founder of Fig here! Just want to say that I think this is awesome.

It’s really cool to see alternative implementations of IDE-style autocomplete in the terminal. Nice work!

trey-jones · 2 years ago
I'm pretty sure this is just a wrapper for Fig.
alexlur · 2 years ago
A wrapper for Fig that doesn’t require me to create an account in order to use my terminal. I’d say it’s a good thing.
arjvik · 2 years ago
Fig autocomplete is really cool! With the Fig aquisition, what do you forsee happening to Fig's autocomplete offering in the long and short term? My impression is that Amazon was interested more in the other parts of your tech, with the scripts and automation capabilities.
curiousgal · 2 years ago
Looking at the main author's gorhub profile, they forker Fig's repo.
shrimpx · 2 years ago
Btw if you don't mind me asking, how will Fig make money? Will it be integrations with stuff like AWS, GCP, etc.? Nice work on Fig!
st0le · 2 years ago
IIRC They were acquired by Amazon. They have a paid offering for shared team environments.

Deleted Comment