公开
版本 1.0
Powershell 配置文件备份
描述
"C:\Users\dxt98\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" 这个文件的备份,现在可以在vscode中切换anaconda环境,以及有终端的美化
提示词内容
# PowerShell Profile Script
# VS Code Specific Initializations
if ($env:TERM_PROGRAM -eq "vscode") {
# 1. VS Code Shell Integration (让它在这里,因为它也只针对VS Code)
. "$(code --locate-shell-integration-path pwsh)"
# 2. Conda Initialization (现在也只在VS Code中运行)
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
If (Test-Path "D:\Anaconda\Scripts\conda.exe") { # <-- 确保这是你正确的Anaconda路径
Write-Verbose "Attempting to initialize Conda for VS Code PowerShell terminal..." -Verbose
(& "D:\Anaconda\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | ?{$_} | Invoke-Expression
Write-Verbose "Conda initialization complete (if successful)." -Verbose
} Else {
Write-Warning "Conda executable not found at D:\Anaconda\Scripts\conda.exe. Conda will not be initialized."
}
#endregion
}
# 你可以在这里放其他希望在所有 PowerShell 会话中都运行的脚本
# 例如:
# Set-Alias subl "C:\Program Files\Sublime Text\subl.exe"
# Write-Host "General PowerShell profile loaded."
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
oh-my-posh init pwsh --eval | Invoke-Expression