inshellisense

repository·main·Indexed 27 days ago

https://github.com/microsoft/inshellisense

IDE-style command line autocomplete supporting over 600 tools across Windows, Linux, and macOS. It provides shell integration for bash, zsh, fish, pwsh, powershell, xonsh, and nu. The tool includes a CLI for installation management (init, reinit, uninstall), health checks (doctor), and configuration via TOML for keybindings and appearance.

Tokens
2.9K
Snippets
9
Records
30
Agent score
95%

What's inside inshellisense

  1. Configure inshellisense Shell Plugins

    main

    To automatically start inshellisense whenever you open a new shell session, run the initialization command for your specific shell and append the output to your shell's configuration file.

    Important: Ensure the inshellisense plugin is the last command in your shell configuration file to prevent breaking your shell setup (e.g., initializing a shell plugin manager after inshellisense may cause issues).

    # bash
    is init bash >> ~/.bashrc
    
    # zsh
    is init zsh >> ~/.zshrc
    
    # fish
    is init fish >> ~/.config/fish/config.fish
    
    # pwsh
    is init pwsh | Add-Content $profile
    
    # powershell
    is init powershell | Add-Content $profile
    
    # xonsh
    is init xonsh >> ~/.xonshrc
    
    # nushell
    is init nu | save $nu.env-path --append
  2. Install inshellisense

    main

    You can install inshellisense using npm (recommended) or Homebrew on macOS/Linux. After installation, you must run is init to complete the setup.

    # npm (recommended)
    npm install -g @microsoft/inshellisense
    is init
    
    # homebrew (macOS/linux)
    brew tap microsoft/inshellisense https://github.com/microsoft/inshellisense
    brew install inshellisense
    is init
  3. Report issues and get help with inshellisense

    main
    To report bugs or request new features, use GitHub Issues. It is recommended to search existing issues before filing a new one to prevent duplicates. For general questions or help regarding the use of the project, use GitHub Discussions.
  4. Customize inshellisense keybindings

    main

    You can customize the keybindings by adding a [bindings] section to your TOML configuration file. Key names must match Node.js keypress events. The shift and ctrl options are optional and default to false.

    [bindings.acceptSuggestion]
    key = "tab"
    shift = false
    ctrl = false
    
    [bindings.nextSuggestion]
    key = "down"
    
    [bindings.previousSuggestion]
    key = "up"
    
    [bindings.dismissSuggestions]
    key = "escape"
  5. Configure inshellisense appearance and behavior

    main

    Use the following keys in your TOML configuration file to adjust inshellisense behavior:

    • useAliases = true: Enables alias expansion for bash/zsh shells.
    • useNerdFont = true: Enables support for NerdFont patched fonts.
    • maxSuggestions = <number>: Sets the maximum number of suggestions displayed in the autocomplete list at once.
    useAliases = true
    useNerdFont = true
    maxSuggestions = 10
  6. Use inshellisense commands and keybindings

    main
    Once inside an inshellisense session, use the following commands and keybindings to manage the session and navigate suggestions. Keybindings only capture input when suggestions are visible; otherwise, they are passed through to the shell.
  7. Identify shells requiring prompt rewrites

    main

    Some shells rewrite the prompt after every keystroke or command acceptance, which can cause issues with UI synchronization. Use getShellPromptRewrites(shell) to check if a shell requires special handling.

    Returns true for:

    • Nushell
    • Xonsh
    export const getShellPromptRewrites = (shell: Shell) => shell == Shell.Nushell || shell == Shell.Xonsh;
  8. Locate Git Bash executable on Windows

    main

    The gitBashPath() function searches for a valid Git Bash executable on Windows systems. It checks common installation directories, including:

    • Standard Git installation paths (derived from git.exe location).
    • ProgramFiles and ProgramFiles(X86).
    • LocalAppData\Program.
    • Scoop installation paths (~/scoop/apps/git/current/bin/bash.exe).

    It throws an error if no valid Git Bash executable is found.