mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
fix(python): disable Python prompt hijacking by default
This commit is contained in:
parent
75a6fa7a60
commit
4af814f3a5
|
@ -6,6 +6,10 @@ export POSH_SESSION_ID=::SESSION_ID::
|
|||
export CONDA_PROMPT_MODIFIER=false
|
||||
export OSTYPE=$OSTYPE
|
||||
|
||||
# disable all known python virtual environment prompts
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
|
||||
|
||||
# global variables
|
||||
_omp_start_time=''
|
||||
_omp_stack_count=0
|
||||
|
|
|
@ -4,6 +4,10 @@ set-env POSH_SHELL elvish
|
|||
set-env POSH_SHELL_VERSION $version
|
||||
set-env POWERLINE_COMMAND oh-my-posh
|
||||
|
||||
# disable all known python virtual environment prompts
|
||||
set-env VIRTUAL_ENV_DISABLE_PROMPT 1
|
||||
set-env PYENV_VIRTUALENV_DISABLE_PROMPT 1
|
||||
|
||||
var _omp_executable = (external ::OMP::)
|
||||
var _omp_status = 0
|
||||
var _omp_no_status = 1
|
||||
|
|
|
@ -13,6 +13,10 @@ set --global _omp_ftcs_marks 0
|
|||
set --global _omp_transient_prompt 0
|
||||
set --global _omp_prompt_mark 0
|
||||
|
||||
# disable all known python virtual environment prompts
|
||||
set --global VIRTUAL_ENV_DISABLE_PROMPT 1
|
||||
set --global PYENV_VIRTUALENV_DISABLE_PROMPT 1
|
||||
|
||||
# We use this to avoid unnecessary CLI calls for prompt repaint.
|
||||
set --global _omp_new_prompt 1
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
os.setenv('POSH_SESSION_ID', '::SESSION_ID::')
|
||||
os.setenv('POSH_SHELL', 'cmd')
|
||||
|
||||
-- disable all known python virtual environment prompts
|
||||
os.setenv('VIRTUAL_ENV_DISABLE_PROMPT', '1')
|
||||
os.setenv('PYENV_VIRTUALENV_DISABLE_PROMPT', '1')
|
||||
|
||||
-- Helper functions
|
||||
|
||||
local function get_priority_number(name, default)
|
||||
|
|
|
@ -10,6 +10,10 @@ $env.POSH_SESSION_ID = (echo ::SESSION_ID::)
|
|||
$env.POSH_SHELL = "nu"
|
||||
$env.POSH_SHELL_VERSION = (version | get version)
|
||||
|
||||
# disable all known python virtual environment prompts
|
||||
$env.VIRTUAL_ENV_DISABLE_PROMPT = 1
|
||||
$env.PYENV_VIRTUALENV_DISABLE_PROMPT = 1
|
||||
|
||||
let _omp_executable: string = (echo ::OMP::)
|
||||
|
||||
# PROMPTS
|
||||
|
|
|
@ -3,6 +3,10 @@ if ($null -ne (Get-Module -Name "oh-my-posh-core")) {
|
|||
Remove-Module -Name "oh-my-posh-core" -Force
|
||||
}
|
||||
|
||||
# disable all known python virtual environment prompts
|
||||
$env:VIRTUAL_ENV_DISABLE_PROMPT = 1
|
||||
$env:PYENV_VIRTUALENV_DISABLE_PROMPT = 1
|
||||
|
||||
# Helper functions which need to be defined before the module is loaded
|
||||
# See https://github.com/JanDeDobbeleer/oh-my-posh/discussions/2300
|
||||
function global:Get-PoshStackCount {
|
||||
|
@ -66,7 +70,8 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
# ref-1: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.argumentlist?view=net-6.0
|
||||
# ref-2: https://docs.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.2#net-framework-vs-net-core
|
||||
$Arguments | ForEach-Object -Process { $StartInfo.ArgumentList.Add($_) }
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
# escape arguments manually in lower versions, refer to https://docs.microsoft.com/en-us/previous-versions/17w5ykft(v=vs.85)
|
||||
$escapedArgs = $Arguments | ForEach-Object {
|
||||
# escape N consecutive backslash(es), which are followed by a double quote, to 2N consecutive ones
|
||||
|
@ -154,7 +159,8 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
$script:TransientPrompt = $true
|
||||
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
[Console]::OutputEncoding = $previousOutputEncoding
|
||||
}
|
||||
}
|
||||
|
@ -184,14 +190,16 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
if ($global:_ompAzure) {
|
||||
try {
|
||||
$env:POSH_AZURE_SUBSCRIPTION = Get-AzContext | ConvertTo-Json
|
||||
} catch {}
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
|
||||
if ($global:_ompPoshGit) {
|
||||
try {
|
||||
$global:GitStatus = Get-GitStatus
|
||||
$env:POSH_GIT_STATUS = $global:GitStatus | ConvertTo-Json
|
||||
} catch {}
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +224,8 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
$invocationInfo = try {
|
||||
# retrieve info of the most recent error
|
||||
$global:Error[0] | Where-Object { $_ -ne $null } | Select-Object -ExpandProperty InvocationInfo
|
||||
} catch { $null }
|
||||
}
|
||||
catch { $null }
|
||||
|
||||
# check if the last command caused the last error
|
||||
if ($null -ne $invocationInfo -and $lastHistory.CommandLine -eq $invocationInfo.Line) {
|
||||
|
@ -260,7 +269,8 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
if ($global:NVS_ORIGINAL_LASTEXECUTIONSTATUS -is [bool]) {
|
||||
# make it compatible with NVS auto-switching, if enabled
|
||||
$script:OriginalLastExecutionStatus = $global:NVS_ORIGINAL_LASTEXECUTIONSTATUS
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$script:OriginalLastExecutionStatus = $?
|
||||
}
|
||||
# store the orignal last exit code
|
||||
|
@ -346,7 +356,8 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
# Workaround to prevent the text after cursor from disappearing when the tooltip is printed.
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::Insert(' ')
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::Undo()
|
||||
} finally {}
|
||||
}
|
||||
finally {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,7 +375,8 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
$script:TooltipCommand = ''
|
||||
Set-TransientPrompt
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
|
||||
if ($global:_ompFTCSMarks -and $executingCommand) {
|
||||
# Write FTCS_COMMAND_EXECUTED after accepting the input - it should still happen before execution
|
||||
|
@ -382,7 +394,8 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
$script:TooltipCommand = ''
|
||||
Set-TransientPrompt
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::CopyOrCancelLine()
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +492,8 @@ New-Module -Name "oh-my-posh-core" -ScriptBlock {
|
|||
$themes = Get-ChildItem -Path "$Path/*" -Include '*.omp.json' | Sort-Object Name
|
||||
if ($List -eq $true) {
|
||||
$themes | Select-Object @{ Name = 'hyperlink'; Expression = { Get-FileHyperlink -Uri $_.FullName } } | Format-Table -HideTableHeaders
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$nonFSWD = Get-NonFSWD
|
||||
$stackCount = Get-PoshStackCount
|
||||
$terminalWidth = Get-TerminalWidth
|
||||
|
|
|
@ -5,6 +5,10 @@ setenv POSH_SHELL_VERSION "$tcsh";
|
|||
setenv POSH_SESSION_ID ::SESSION_ID::;
|
||||
setenv OSTYPE "$OSTYPE";
|
||||
|
||||
# disable all known python virtual environment prompts
|
||||
setenv VIRTUAL_ENV_DISABLE_PROMPT 1;
|
||||
setenv PYENV_VIRTUALENV_DISABLE_PROMPT 1;
|
||||
|
||||
if ( ! $?_omp_enabled ) alias precmd '
|
||||
set _omp_status = $status;
|
||||
set _omp_execution_time = -1;
|
||||
|
|
|
@ -4,6 +4,10 @@ $POSH_SESSION_ID = ::SESSION_ID::
|
|||
$POSH_SHELL = "xonsh"
|
||||
$POSH_SHELL_VERSION = $XONSH_VERSION
|
||||
|
||||
# disable all known python virtual environment prompts
|
||||
$VIRTUAL_ENV_DISABLE_PROMPT = 1
|
||||
$PYENV_VIRTUALENV_DISABLE_PROMPT = 1
|
||||
|
||||
_omp_executable = ::OMP::
|
||||
_omp_history_length = 0
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@ export CONDA_PROMPT_MODIFIER=false
|
|||
export ZLE_RPROMPT_INDENT=0
|
||||
export OSTYPE=$OSTYPE
|
||||
|
||||
# disable all known python virtual environment prompts
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
|
||||
|
||||
_omp_executable=::OMP::
|
||||
_omp_tooltip_command=''
|
||||
|
||||
|
|
Loading…
Reference in a new issue