feat: add parent-term-exit option to help close parent terminal

* Update inshellisense commands and options

* fix: PR suggestions
This commit is contained in:
Nicolás Quiroz
2024-03-13 19:10:09 -07:00
committed by GitHub
parent 4556428ee8
commit 10c1a85e69
4 changed files with 13 additions and 7 deletions
+6 -5
View File
@@ -22,11 +22,12 @@ After completing the installation, you can run `is` to start the autocomplete se
### Usage
| Action | Command |
| ------------------------------------- | ------- |
| Start | `is` |
| Stop | `exit` |
| Check If Inside Inshellisense Session | `is -c` |
| Action | Command | Description |
| ------------------------------------- | --------------------------------- | ------------------------------------------------ |
| Start | `is` | Start inshellisense session on the current shell |
| Stop | `exit` | Stop inshellisense session on the current shell |
| Check If Inside Inshellisense Session | `is -c` | Check if shell inside inshellisense session |
#### Keybindings
+2 -1
View File
@@ -15,6 +15,7 @@ type RootCommandOptions = {
verbose: boolean | undefined;
check: boolean | undefined;
test: boolean | undefined;
parentTermExit: boolean | undefined;
};
export const action = (program: Command) => async (options: RootCommandOptions) => {
@@ -40,5 +41,5 @@ export const action = (program: Command) => async (options: RootCommandOptions)
} else if (shell == Shell.Bash) {
await setupBashPreExec();
}
await render(shell, options.test ?? false);
await render(shell, options.test ?? false, options.parentTermExit ?? false);
};
+1
View File
@@ -27,6 +27,7 @@ program
.action(action(program))
.option("-s, --shell <shell>", `shell to use for command execution, supported shells: ${supportedShells}`)
.option("-c, --check", `check if shell is in an inshellisense session`)
.option("--parent-term-exit", `when inshellisense is closed, kill the parent process`)
.addOption(hiddenOption("-T, --test", "used to make e2e tests reproducible across machines"))
.option("-V, --verbose", `enable verbose logging`)
.showHelpAfterError("(add --help for additional information)");
+4 -1
View File
@@ -16,7 +16,7 @@ export const renderConfirmation = (live: boolean): string => {
return `inshellisense session [${statusMessage}]\n`;
};
export const render = async (shell: Shell, underTest: boolean) => {
export const render = async (shell: Shell, underTest: boolean, parentTermExit: boolean) => {
const term = await isterm.spawn({ shell, rows: process.stdout.rows, cols: process.stdout.columns, underTest });
const suggestionManager = new SuggestionManager(term, shell);
let hasActiveSuggestions = false;
@@ -140,6 +140,9 @@ export const render = async (shell: Shell, underTest: boolean) => {
});
term.onExit(({ exitCode }) => {
if (parentTermExit && process.ppid) {
process.kill(process.ppid);
}
process.exit(exitCode);
});
process.stdout.on("resize", () => {