Open brian6932 opened 2 years ago
Same issue here. I think it's because pwsh
doesn't work with Doskey
while cmd does, Powershell works with PSReadLine
.
Doskey apart from being incompatible with PSReadLine see: https://github.com/PowerShell/PSReadLine/issues/353 Doskey doesn't work with pwsh, it also will not be supported by the devs as linked before so it should be replaced with PSReadLine completely.
this is the file that should be changed in any case to make it work with PSReadline instead: https://github.com/dduan/tre/blob/a813038b1c0e52cbc6ce44a28bc828476f161585/src/output.rs#L126
One solution, instead of using doskey to create the aliases, is to generate a PowerShell module containing functions named e<NUM>
and then import that module using the tre.ps1 file.
I'm testing out a patch that does that currently.
The difference is we:
.psm1
suffixFunction e<index> { <editor> $args "<path>"}
for each entryExport-ModuleMember -Function *
to the endThis yields the following aliases file for me when invoked on the tre/src
directory:
Function e0 { nvim.exe $args "src"}
Function e1 { nvim.exe $args "src/cli.rs"}
Function e2 { nvim.exe $args "src/diagram_formatting.rs"}
Function e3 { nvim.exe $args "src/file_tree.rs"}
Function e4 { nvim.exe $args "src/json_formatting.rs"}
Function e5 { nvim.exe $args "src/main.rs"}
Function e6 { nvim.exe $args "src/output.rs"}
Function e7 { nvim.exe $args "src/path_finders.rs"}
Function e8 { nvim.exe $args "src/tre.rs"}
Export-ModuleMember -Function *
In the new tre.ps1
script file we:
tre.exe
tre.exe
as normaltre.exe
New tre.ps1
script:
# Remove the tre.exe aliases module created by the previous invocation
# if it exists
if (Get-Module tre_aliases_$env:USERNAME)
{
Remove-Module -Force tre_aliases_$env:USERNAME
}
# Call tre.exe with the args passed to this script and the editor flag
tre.exe $args -e
# Import the new aliases module created by tre.exe
Import-Module $Env:TEMP\tre_aliases_$env:USERNAME.psm1
I can then type e5
to open src/main.rs
assuming $EDITOR=nvim.exe
.
Did you run into any issues with your patch @jman4747
I used the script from the readme:
Shell: PowerShell 7.3.0-preview.6 tre: tre-command 0.4.0
Same thing occurs on Windows' system PowerShell (5.1)