mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
fix: pwsh version <7 and removed cnf
This commit is contained in:
parent
c20a46666c
commit
cfe8a1e1ba
2 changed files with 32 additions and 25 deletions
|
|
@ -61,12 +61,12 @@ Please follow the instruction for your shell:
|
||||||
|
|
||||||
> Append the following output to your profile:
|
> Append the following output to your profile:
|
||||||
> ```pwsh
|
> ```pwsh
|
||||||
> pay-respects pwsh --alias [<alias>] [--nocnf]
|
> pay-respects pwsh --alias [<alias>]
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
> Or directly pipe the output to your profile:
|
> Or directly pipe the output to your profile:
|
||||||
> ```pwsh
|
> ```pwsh
|
||||||
> pay-respects pwsh --alias [<alias>] [--nocnf] >> $PROFILE
|
> pay-respects pwsh --alias [<alias>] >> $PROFILE
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
|
||||||
|
|
@ -538,7 +538,12 @@ def --env {} [] {{
|
||||||
# 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;
|
if ($PSVersionTable.PSVersion.Major -ge 7) {{
|
||||||
|
$err = Get-Error;
|
||||||
|
if ($env:_PR_LAST_COMMAND -eq $err.InvocationInfo.Line) {{
|
||||||
|
$env:_PR_ERROR_MSG = $err.Exception.Message
|
||||||
|
}}
|
||||||
|
}}
|
||||||
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
|
||||||
}}
|
}}
|
||||||
|
|
@ -638,28 +643,30 @@ end
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
"pwsh" => {
|
"pwsh" => {
|
||||||
initialize = format!(
|
// usage with pwsh is limited as we cannot get arguments
|
||||||
r#"{}
|
// furthermore there is recursion
|
||||||
$ExecutionContext.InvokeCommand.CommandNotFoundAction =
|
// initialize = format!(
|
||||||
{{
|
// r#"{}
|
||||||
param(
|
// $ExecutionContext.InvokeCommand.CommandNotFoundAction =
|
||||||
[string]
|
// {{
|
||||||
$commandName,
|
// param(
|
||||||
[System.Management.Automation.CommandLookupEventArgs]
|
// [string]
|
||||||
$eventArgs
|
// $commandName,
|
||||||
)
|
// [System.Management.Automation.CommandLookupEventArgs]
|
||||||
# powershell does not support run command with specific environment variables
|
// $eventArgs
|
||||||
# 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;
|
// # powershell does not support run command with specific environment variables
|
||||||
$env:_PR_MODE='cnf';
|
// # but you must set global variables. so we are memorizing the current mode and the alias function will reset it later.
|
||||||
# powershell may search command with prefix 'get-' or '.\' first when this hook is hit, strip them
|
// $env:_PR_PWSH_ORIGIN_MODE=$env:_PR_MODE;
|
||||||
$env:_PR_LAST_COMMAND=$commandName -replace '^get-|\.\\','';
|
// $env:_PR_MODE='cnf';
|
||||||
$eventArgs.Command = (Get-Command {});
|
// # powershell may search command with prefix 'get-' or '.\' first when this hook is hit, strip them
|
||||||
$eventArgs.StopSearch = $True;
|
// $env:_PR_LAST_COMMAND=$commandName -replace '^get-|\.\\','';
|
||||||
}}
|
// $eventArgs.Command = (Get-Command {});
|
||||||
"#,
|
// $eventArgs.StopSearch = $True;
|
||||||
initialize, alias
|
// }}
|
||||||
)
|
// "#,
|
||||||
|
// initialize, alias
|
||||||
|
// )
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
println!("Unsupported shell: {}", shell);
|
println!("Unsupported shell: {}", shell);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue