IF Commons GitHub

shell/snippet

Written to: 2 requirements: 1 proved, 0 partly, 0 failing, 1 with no test recorded. 0003-host FR-017, 0003-host FR-027

The shell snippet (commons 0003-host FR-017, FR-018): what ergonex shell print <bash|zsh|fish|pwsh|nu> prints on standard output. It does four things and no more: exports ERGONEX_HOME where it is not set, adds <home>/.ergonex/tools/bin to the PATH (once) so that ergonex-* modules and the pinned tools resolve, defines the completions of ergonex, and defines one function, wcd, that changes to a repository of the workspace by its name; and, besides, the token of the person's sign-in and the short name enx (FR-027), an alias of ergonex that is defined only where no other program, alias or function of that name is found. An alias exists only in an interactive shell that sourced the snippet: a script, a hook and an agent use ergonex.

Pure: the snippet is text made from the shell's name, the root (the default, $HOME/workspaces, or a path a run named) and the modules to complete. It holds no secret and no command that runs anything but find, cd and the shell's own builtins. It never edits a file; block.ts is what ergonex shell install writes and removes. A path is quoted for its shell, so that a root with a space or a quote in it is one word.

Source: commons/ergonex/src/shell/snippet.ts

4 of 4 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

rcFileForfunction
function rcFileFor(shell: Shell, f: RcFacts): string

The start-up file a shell reads, which ergonex shell install writes one block into: ~/.bashrc, ~/.zshrc (under $ZDOTDIR where it is set), ~/.config/fish/conf.d/ergonex.fish, PowerShell's profile and Nushell's config.nu. A run that names --rc uses that file instead; this is the default, as a path with / between parts (the host gives it its native separators).

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

SHELLSconst
const SHELLS: readonly Shell[]

All the shells, in the order ergonex shell names them.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

Shelltype
type Shell = "bash" | "zsh" | "fish" | "pwsh" | "nu";

The shells ergonex shell knows.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

snippetForfunction
function snippetFor(shell: Shell, facts: SnippetFacts): string

The snippet for a shell, ending in one newline.

Imported by 10 tests of the run (10 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.