PSReadline interferes with doskey macros
See original GitHub issueI’ll include the error details that I had, but first I’ll provide a way to repro what I see, though the below repro is not what gave the error.
[Example, with PS> starting lines you type] Open powershell.exe PS> doskey /exename=powershell.exe hello=Write-Host “hello world” PS> hello hello : The term ‘hello’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
- hello
-
- CategoryInfo : ObjectNotFound: (hello:String) [], CommandNotFoundException - FullyQualifiedErrorId : CommandNotFoundException
PS> Remove-Module PSReadline PS> hello hello world
Error that made me realize something was going wrong with PSReadline:
Oops, something went wrong. Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
Last 31 Keys: s . Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace d a a Enter Enter Enter c a b n s g Enter w e
Exception: System.IO.IOException: The handle is invalid.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Console.SetCursorPosition(Int32 left, Int32 top)
at Microsoft.PowerShell.PSConsoleReadLine.PlaceCursor(Int32 x, Int32& y)
at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender()
at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary
2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
Issue Analytics
- State:
- Created 8 years ago
- Comments:17 (9 by maintainers)
I was WRONG – PSReadline is BETTER than Doskey in the long run but is going to take some effort to build the functions/commands.
It is (should be?) easy to produce PSReadline functions that mimic and exceed those in DosKey and I’ve been working to parse DosKey to automatically do that (still want to share DosKey with CMD.exe).
I’ve been switched to PSReadline for some time now, but still want the functionality of DosKey – and simplicity.
Anyway, anyone (still?) delaying PSReadline, we can have PSreadline with all the doskey goodness and more. (There are probably 3 or 4 people somewhere on the Internet who still care. 😃 )
I would recommend the push to PowerShell. PSReadline makes the line editing (and history recall) much nicer than what CMD supports. I just love being able to press <kbd>Ctrl+a</kbd>, <kbd>ctrl+c</kbd> to copy the current command line to the clipboard. I love that I can search my command history not based on the beginning part of the command but with any text in the command using <kbd>Ctrl+r</kbd>. And the multiline editing is pretty nice too.
And I love it that I can write custom handlers for keyboard shortcuts of my own choosing. Here is one of my favs lately:
For more of these check out my PSReadline_config.ps1 file.