Woo*_*193 7 git powershell conda
我为 Powershell 安装了 Posh-Git 模块,最近我还安装了 Anaconda 并执行了conda init
. 显然,这profile.ps1
通过添加以下代码来修改文件:
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
(& "{User}\anaconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression
#endregion
Run Code Online (Sandbox Code Playgroud)
这确实让我看到了我正在使用的 conda 环境,但它也隐藏了我正在使用的 Git 分支。我该如何修改它以便我可以看到两者?
Fau*_*ter 11
posh-git文档声明 posh-git 不会修改自定义提示。因此,当您Import-Module posh-git
在 conda 初始化后运行时,您不会看到任何变化。解决方案是将文件Import-Module posh-git
中的 conda 初始化块放在前面,$Profile.CurrentUserAllHosts
如下所示:
Import-Module posh-git
#region conda initialize
# !! Contents within this block are managed by 'conda init' !!
(& "{User}\anaconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression
#endregion
Run Code Online (Sandbox Code Playgroud)
还值得注意的是,当您运行时Add-PoshGitToProfile
,它会将该Import-Module posh-git
行添加到您的$Profile.CurrentUserCurrentHost
文件中。由于此命令在 后 $Profile.CurrentUserAllHosts
执行,因此该命令不会产生任何明显的效果。
归档时间: |
|
查看次数: |
495 次 |
最近记录: |