Skip to content

Conversation

@Tyriar
Copy link
Member

@Tyriar Tyriar commented Jan 1, 2026

Fixes #276716

Verified:

  • Windows/pwsh 5
  • Windows/pwsh 7
  • mac/zsh 5.9
  • mac/bash 3.2.57
  • mac/fish 3.7.1

@Tyriar Tyriar added this to the December / January 2026 milestone Jan 1, 2026
@Tyriar Tyriar self-assigned this Jan 1, 2026
Copilot AI review requested due to automatic review settings January 1, 2026 23:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new preventShellHistory feature to prevent AI-executed terminal commands from being saved in the user's shell history. The implementation prefixes commands with a space and configures shells to ignore space-prefixed commands.

Key Changes

  • Adds a new PreventShellHistory configuration setting (default: true) that controls whether commands executed by the terminal tool are excluded from shell history
  • Implements space-prefixing of commands across all execution strategies and the background terminal execution
  • Adds shell integration script modifications to configure bash, zsh, fish, and PowerShell to ignore space-prefixed commands

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
terminalChatAgentToolsConfiguration.ts Adds the PreventShellHistory configuration setting with markdown description
runInTerminalTool.ts Adds preventShellHistory parameter to BackgroundTerminalExecution and prefixes commands with space when enabled
toolTerminalCreator.ts Sets VSCODE_EXCLUDE_FROM_HISTORY environment variable for supported shells when feature is enabled
richExecuteStrategy.ts Reads configuration and prefixes commands with space before execution
noneExecuteStrategy.ts Reads configuration and prefixes commands with space before execution
basicExecuteStrategy.ts Reads configuration and prefixes commands with space before execution
shellIntegration.ps1 Configures PSReadLine's AddToHistoryHandler to ignore space-prefixed commands
shellIntegration.fish Enables fish_private_mode when VSCODE_EXCLUDE_FROM_HISTORY is set
shellIntegration-rc.zsh Sets HIST_IGNORE_SPACE option when VSCODE_EXCLUDE_FROM_HISTORY is set
shellIntegration-bash.sh Sets HISTCONTROL=ignorespace when VSCODE_EXCLUDE_FROM_HISTORY is set

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

@Tyriar Tyriar marked this pull request as ready for review January 2, 2026 18:54
@Tyriar Tyriar enabled auto-merge January 2, 2026 18:54
@anthonykim1
Copy link
Contributor

this is pretty cool 🚀

@Tyriar Tyriar merged commit ae06bf1 into main Jan 2, 2026
28 checks passed
@Tyriar Tyriar deleted the tyriar/276716_history branch January 2, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explore preventing Copilot commands from entering shell history

3 participants