From 987bc274ff8e41b55e6d150b591c5e852dec7082 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Jul 2026 12:43:18 +0000 Subject: [PATCH] Add inshellisense IDE-style autocomplete to shared shell profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wire up microsoft/inshellisense across all three shells (bash, zsh, fish). inshellisense auto-starts a session that wraps the interactive shell, so the source line must be the last command in each rc file — it's appended after the profile-override loops in .bashrc, .zshrc, and fish/config.fish. - Gate the block behind is_integrated_terminal so it's skipped in VS Code / Neovim / Emacs / Zed terminals, mirroring auto_start_tmux. - Source ~/.inshellisense/init//init. only if it exists, so shells are unaffected until `is init` is run and the non-interactive CI startup-time harness stays inert (inshellisense is intentionally not installed in CI, where a wrapping PTY session would hang the measurement). - Declare the `is` binary for macOS in nix-darwin systemPackages; npm install is documented for Ubuntu / remote sandboxes. - Document the integration (must-be-last, editor-terminal gating, provisioning) in the shell README, and cross-reference from the root, fish, and nix-darwin READMEs. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01RKQHwwanmxtTm74iM6SdH7 --- README.md | 1 + shared/.bashrc | 6 ++++ shared/.config/fish/README.md | 1 + shared/.config/fish/config.fish | 6 ++++ shared/.config/nix-darwin/README.md | 2 +- shared/.config/nix-darwin/darwin.nix | 1 + shared/.config/shell/README.md | 41 ++++++++++++++++++++++++++++ shared/.zshrc | 6 ++++ 8 files changed, 63 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 61711468..b030f014 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ See the [ubuntu-server README](ubuntu-server/README.md) for details on the Nix c - Shared configuration modules to eliminate duplication - POSIX-compliant environment setup across all shells - macOS login shell compatibility + - [inshellisense](https://github.com/microsoft/inshellisense) IDE-style inline autocomplete across all three shells (skipped in editor terminals; see [shell README](shared/.config/shell/README.md#inshellisense-ide-style-autocomplete)) - **✏️ Editors**: - **Neovim (Kickstart)** - Default, mapped to `nvim`/`vim` commands - **Neovim (AstroVim)** - Available via `astrovim` alias diff --git a/shared/.bashrc b/shared/.bashrc index 49b2417a..8076aa58 100644 --- a/shared/.bashrc +++ b/shared/.bashrc @@ -66,3 +66,9 @@ for config_file in "$HOME/.bashrc.d/"*.sh; do done eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)" + +# inshellisense autocomplete — MUST be the last command (it wraps the shell in a +# child session; keep new startup logic above this). Setup: .config/shell/README.md +if [ -f "$HOME/.inshellisense/init/bash/init.sh" ] && ! is_integrated_terminal; then + . "$HOME/.inshellisense/init/bash/init.sh" +fi diff --git a/shared/.config/fish/README.md b/shared/.config/fish/README.md index 8bc4bf8c..cb00b4a7 100644 --- a/shared/.config/fish/README.md +++ b/shared/.config/fish/README.md @@ -77,6 +77,7 @@ fisher update - **fzf** - Fuzzy finder - **zoxide** - Smart directory navigation - **fisher** - Plugin manager +- **inshellisense** (`is`) - IDE-style inline autocomplete (optional; run `is init fish` to enable) ## Usage diff --git a/shared/.config/fish/config.fish b/shared/.config/fish/config.fish index 19a98cfc..c97d8974 100644 --- a/shared/.config/fish/config.fish +++ b/shared/.config/fish/config.fish @@ -42,3 +42,9 @@ for config_file in ~/.config/fish/config.*.fish source $config_file end end + +# inshellisense autocomplete — MUST be the last command (it wraps the shell in a +# child session; keep new startup logic above this). Setup: .config/shell/README.md +if status is-interactive; and test -f ~/.inshellisense/init/fish/init.fish; and not is_integrated_terminal + source ~/.inshellisense/init/fish/init.fish +end diff --git a/shared/.config/nix-darwin/README.md b/shared/.config/nix-darwin/README.md index 77aecc61..141fd09c 100644 --- a/shared/.config/nix-darwin/README.md +++ b/shared/.config/nix-darwin/README.md @@ -41,7 +41,7 @@ This configuration manages macOS systems declaratively using Nix, providing: ### Nix Packages (System-wide) - **Development**: `neovim`, `gh`, `lazygit`, `ripgrep`, `fd` -- **Shell**: `fish`, `zellij`, `tmux`, `fzf`, `zoxide`, `atuin` +- **Shell**: `fish`, `zellij`, `tmux`, `fzf`, `zoxide`, `atuin`, `inshellisense` - **Tools**: `stow`, `oh-my-posh`, `volta`, `asdf-vm` - **AI**: `claude-code`, `codex` diff --git a/shared/.config/nix-darwin/darwin.nix b/shared/.config/nix-darwin/darwin.nix index 81efd846..0e8ea535 100644 --- a/shared/.config/nix-darwin/darwin.nix +++ b/shared/.config/nix-darwin/darwin.nix @@ -42,6 +42,7 @@ git gofumpt gum + inshellisense lazygit neovim nil diff --git a/shared/.config/shell/README.md b/shared/.config/shell/README.md index f619125a..bfc1309e 100644 --- a/shared/.config/shell/README.md +++ b/shared/.config/shell/README.md @@ -101,6 +101,47 @@ The `shared/` profile establishes each `.d/` directory (with a `.gitkeep`). The This complements the existing `.config/shell/` pattern (`aliases.*.sh`, `exports.*.sh`, `functions.*.sh`) for cases where profile-specific logic needs to live in the root init files rather than the shared shell config directory. +## inshellisense (IDE-style autocomplete) + +[inshellisense](https://github.com/microsoft/inshellisense) provides fig-like, +IDE-style inline command autocompletion for all three shells. It works by +auto-starting a session that *wraps* the interactive shell, so the integration +has a few non-obvious requirements that are baked into this repo: + +- **Must be the last command.** The source line is appended to the very end of + `.bashrc`, `.zshrc`, and `fish/config.fish` (after the profile `.d/` and + `config.*.fish` loops). inshellisense recurses into a child shell guarded by + the `ISTERM` env var, so anything after it in the rc file would not run in the + outer shell. If you add new startup logic, keep it *above* this block. +- **Skipped in IDE/editor terminals.** The block is gated behind + `is_integrated_terminal`, mirroring `auto_start_tmux`, so it stays out of + VS Code / Neovim / Emacs / Zed terminals where a nested PTY is unwanted. +- **No-op until provisioned.** Each shell sources + `~/.inshellisense/init//init.` only if that file exists. The file + is created by `is init` (see below), so shells on un-provisioned machines and + the non-interactive CI startup-time harness are unaffected. + +### Installing / enabling + +The `is` binary is declared for macOS in +`shared/.config/nix-darwin/darwin.nix` (`environment.systemPackages`). On +Ubuntu / remote sandboxes install it via npm: + +```sh +npm install -g @microsoft/inshellisense +``` + +Then generate the per-shell init files once (regenerate after upgrades): + +```sh +is init # detects the current shell, or pass bash|zsh|fish +``` + +`is init` writes `~/.inshellisense/init//init.`, which the rc files +already source. No changes to the rc files themselves are needed — do **not** +run `is init >> ~/.rc` (the upstream instructions), as that would +duplicate the source line this repo already manages. Run `is doctor` to verify. + ## Benefits 1. **No duplication**: Shared configuration is centralized diff --git a/shared/.zshrc b/shared/.zshrc index 30985344..245b1a6e 100644 --- a/shared/.zshrc +++ b/shared/.zshrc @@ -204,3 +204,9 @@ for config_file in "$HOME/.zshrc.d/"*.sh; do . "$config_file" fi done + +# inshellisense autocomplete — MUST be the last command (it wraps the shell in a +# child session; keep new startup logic above this). Setup: .config/shell/README.md +if [[ -f "$HOME/.inshellisense/init/zsh/init.zsh" ]] && ! is_integrated_terminal; then + . "$HOME/.inshellisense/init/zsh/init.zsh" +fi