chore: format & endline white spaces

This commit is contained in:
iff 2024-11-27 19:35:57 +01:00
parent b463071088
commit df221299d9

View file

@ -208,25 +208,25 @@ def --env {} [] {{
), ),
"pwsh" | "powershell" => format!( "pwsh" | "powershell" => format!(
r#"& {{ r#"& {{
try {{ try {{
# fetch command and error from session history only when not in cnf mode # fetch command and error from session history only when not in cnf mode
if ($env:_PR_MODE -ne 'cnf') {{ if ($env:_PR_MODE -ne 'cnf') {{
$env:_PR_LAST_COMMAND = ({}); $env:_PR_LAST_COMMAND = ({});
$err = Get-Error; $err = Get-Error;
if ($env:_PR_LAST_COMMAND -eq $err.InvocationInfo.Line) {{ if ($env:_PR_LAST_COMMAND -eq $err.InvocationInfo.Line) {{
$env:_PR_ERROR_MSG = $err.Exception.Message $env:_PR_ERROR_MSG = $err.Exception.Message
}} }}
}} }}
$env:_PR_SHELL = '{}'; $env:_PR_SHELL = '{}';
&'{}'; &'{}';
}} }}
finally {{ finally {{
# restore mode from cnf # restore mode from cnf
if ($env:_PR_MODE -eq 'cnf') {{ if ($env:_PR_MODE -eq 'cnf') {{
$env:_PR_MODE = $env:_PR_PWSH_ORIGIN_MODE; $env:_PR_MODE = $env:_PR_PWSH_ORIGIN_MODE;
$env:_PR_PWSH_ORIGIN_MODE = $null; $env:_PR_PWSH_ORIGIN_MODE = $null;
}} }}
}} }}
}} }}
"#, "#,
last_command, shell, binary_path last_command, shell, binary_path
@ -311,20 +311,20 @@ end
r#"{} r#"{}
$ExecutionContext.InvokeCommand.CommandNotFoundAction = $ExecutionContext.InvokeCommand.CommandNotFoundAction =
{{ {{
param( param(
[string] [string]
$commandName, $commandName,
[System.Management.Automation.CommandLookupEventArgs] [System.Management.Automation.CommandLookupEventArgs]
$eventArgs $eventArgs
) )
# powershell does not support run command with specific environment variables # powershell does not support run command with specific environment variables
# but you must set global variables. so we are memorizing the current mode and the alias function will reset it later. # but you must set global variables. so we are memorizing the current mode and the alias function will reset it later.
$env:_PR_PWSH_ORIGIN_MODE=$env:_PR_MODE; $env:_PR_PWSH_ORIGIN_MODE=$env:_PR_MODE;
$env:_PR_MODE='cnf'; $env:_PR_MODE='cnf';
# powershell may search command with prefix 'get-' or '.\' first when this hook is hit, strip them # powershell may search command with prefix 'get-' or '.\' first when this hook is hit, strip them
$env:_PR_LAST_COMMAND=$commandName -replace '^get-|\.\\',''; $env:_PR_LAST_COMMAND=$commandName -replace '^get-|\.\\','';
$eventArgs.Command = (Get-Command {}); $eventArgs.Command = (Get-Command {});
$eventArgs.StopSearch = $True; $eventArgs.StopSearch = $True;
}} }}
"#, "#,
init, auto_alias init, auto_alias