Created
April 18, 2025 16:14
-
-
Save ariel-co/2e43c3152a8d3380a3a26ca5fb6886fd to your computer and use it in GitHub Desktop.
Powershell / Bash: use a separate history file for VS Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # $Profile has the profile location | |
| # Detect VS Code environment and change the history path | |
| if ( $env:TERM_PROGRAM -eq "vscode" ) { | |
| Set-PSReadLineOption -HistorySavePath ((Get-PSReadLineOption).HistorySavePath + "_vscode") | |
| } | |
| # Or, to preserve the file extension: | |
| if ( $env:TERM_PROGRAM -eq "vscode" ) { | |
| $h = (Get-PSReadLineOption).HistorySavePath | |
| $a = @{ Path=(Split-Path -Parent $h) | |
| ChildPath=((Split-Path -LeafBase $h) + "_vscode" + (Split-Path -Extension $h)) } | |
| Set-PSReadLineOption -HistorySavePath (Join-Path @a) | |
| } | |
| # https://github.com/PowerShell/PSReadLine/issues/2698#issuecomment-2746033314 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # For Bash, change the environment variable HISTFILE. Append to ~/.bashrc: | |
| if [ "${TERM_PROGRAM:-}" == vscode ]; then | |
| HISTFILE=${HISTFILE}_vscode | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment