/** One candidate, with what it is for, where the shell can show that. */ export interface Candidate { value: string; description?: string | undefined; } /** What to offer for the word being completed. */ export interface Completion { candidates: Candidate[]; /** Complete file names instead — the shell does that better than we would. */ files: boolean; } /** * What to offer for `current`, the word under the cursor, after `words` — the * words before it, not counting the program's own name. */ export declare function complete(words: string[], current: string): Promise; /** * Answer a shell's request. `argv` is what follows `bundle __complete`: * * --shell fish -- words as the shell split them * --shell bash [ ] * bash's `complete -C`, whose real * input is COMP_LINE and COMP_POINT * --shell zsh, --shell powershell COMP_LINE and COMP_POINT too */ export declare function respond(argv: string[], env?: NodeJS.ProcessEnv): Promise; /** Split a command line the way a shell would, enough for completion: words, and the one being typed. */ export declare function splitLine(line: string, { backslash }?: { backslash?: boolean; }): { words: string[]; current: string; }; /** The shells this sets up. */ export type Shell = 'bash' | 'zsh' | 'fish' | 'powershell'; export declare const SHELLS: readonly Shell[]; /** * How a shell runs this package: by name, for bash, zsh, fish — and for * PowerShell a call expression, with a test that it is there. By name is not * always right in PowerShell: on Windows a `.nzip` runs through its file * association, and output from that cannot be captured, so there it is node * itself, with the archive mounted — what the association runs anyway. */ export interface Program { name: string; /** A PowerShell expression that runs it; arguments follow. */ invoke: string; /** A PowerShell condition that is true when it is there to run. */ present: string; } /** A program run by its name. */ export declare function programNamed(name: string): Program; /** A program run as node with the archive at `archive` mounted, under the name `name`. */ export declare function programAt(name: string, node: string, archive: string): Program; /** What `bundle shell` puts in a shell's startup. */ export interface ShellOptions { /** Tab completion (default: true). */ complete?: boolean | undefined; /** Re-validate installs in interactive shells (default: true). */ validate?: boolean | undefined; /** How often that asks the network (default: '1d'). */ every?: string | undefined; /** How long it may wait for the network (default: '5s'). */ timeout?: string | undefined; } /** * What to load when `shell` starts, meant to be evaluated from its startup * file: Tab completion wired to `bundle __complete`, and — interactive shells * only — a quiet `bundle validate`, so a new warning about something installed * is the first thing a new terminal says. */ export declare function script(shell: string, { complete, validate, every, timeout }?: ShellOptions, run?: string | Program): string; /** The shell this is probably being run from (bash when it cannot tell). */ export declare function currentShell(env?: NodeJS.ProcessEnv): string; /** * The shell this is being run from, if it is one this knows how to set up — * by what the shell is, not what platform it runs on. * * 0. BUNDLE_SHELL, when somebody says which. * 1. The nearest ancestor process that is a shell, where the process tree * can be read (/proc on Linux, `ps` elsewhere off Windows). That is the * honest answer, and the only one that is right for pwsh on Linux, which * inherits SHELL from the login shell. * 2. SHELL: Git Bash on Windows names `/usr/bin/bash`, or a `bash.exe`. * 3. PowerShell on Windows sets no SHELL; it is recognised by the module * directory under the user's home it adds to `PSModulePath`, which a * plain cmd.exe lacks. */ export declare function detectShell(env?: NodeJS.ProcessEnv, ancestors?: string[]): Shell | null; /** * The names of this process's ancestors, nearest first, as far as they can be * read cheaply — /proc on Linux, `ps` on macOS and the BSDs. Empty on Windows, * and wherever neither answers. */ export declare function ancestry(limit?: number): string[]; /** * The file an interactive `shell` reads at start. PowerShell's is asked of * PowerShell itself — `$PROFILE`, wherever Documents has been moved to — with * the conventional place as the fallback; `BUNDLE_POWERSHELL_PROFILE` overrides. */ export declare function startupFile(shell: Shell, env?: NodeJS.ProcessEnv): string; /** The one line that loads `bundle shell` — only when bundle is there to run. */ export declare function hookLine(shell: Shell, run?: string | Program): string; /** Whether `file` already carries the block. */ export declare function hasHook(file: string): boolean; /** Add the block to `shell`'s startup file, unless it is there already. Returns the file. */ export declare function addHook(shell: Shell, env?: NodeJS.ProcessEnv, run?: string | Program): { file: string; added: boolean; }; /** Take the block out of every shell's startup file that carries it. Returns the files changed. */ export declare function removeHooks(env?: NodeJS.ProcessEnv): string[]; //# sourceMappingURL=completion.d.ts.map