microsoft / inshellisense

IDE style command line auto complete
MIT License
8.21k stars 179 forks source link

Initialize on startup of shell #194

Closed naquiroz closed 3 months ago

naquiroz commented 3 months ago

Is your feature request related to a problem? Please describe. I want to open a terminal and have the inshellisense already running. Currently if I add is to my bashrc, I can exit from the terminal twice, because is generates a new shell.

Describe the solution you'd like A command to silently start in the same shell, the ishellisense.

Describe alternatives you've considered I've tried adding is to the ~/.zshrc, but it doesn't work in an optimal way.

Additional context Add any other context or screenshots about the feature request here.

selfagency commented 3 months ago

for what it's worth, you can achieve this with a custom profile in your terminal:

image

naquiroz commented 3 months ago

I already tried that. It generates a session within a session of the terminal. You can exit twice.

selfagency commented 3 months ago

guess it depends on the terminal emulator. mine closes on the first exit.

cpendery commented 3 months ago

@naquiroz Would you be interested in contributing the feature?

I think we could add something like a flag --parent-term-exit that will update the exit code to terminate the parent ppid which is either another shell or worst case the terminal emulator of the shell.

naquiroz commented 3 months ago

I would love to but I lack skills on such low level coding. I'll look at the code and see if I can manage.

naquiroz commented 3 months ago

Ok, I think I can do it. But how would I get the parent (if any) id?

naquiroz commented 3 months ago

Would something like this work?

  term.onExit(({ exitCode }) => {
    if (process.ppid) {
      process.kill(process.ppid);
    }
    process.exit(exitCode);
  });
cpendery commented 3 months ago

Would something like this work?

  term.onExit(({ exitCode }) => {
    if (process.ppid) {
      process.kill(process.ppid);
    }
    process.exit(exitCode);
  });

This is looking great so far! Why don't we check for a commander flag instead of if the ppid exists (since for our use case we know it will always exist), because we want users to be able to opt in for this.

You could add the option to the type here and add the flag itself here like we for the other options

Then we could update the above code to be

  term.onExit(({ exitCode }) => {
    if (parentTermExit) {
      process.kill(process.ppid);
    }
    process.exit(exitCode);
  });
naquiroz commented 3 months ago

Done! (I think)

naquiroz commented 3 months ago

Is it release automatically?

cpendery commented 3 months ago

No I have to create a manual release. I'll most likely be Monday with a fix for #205