question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PSReadline interferes with doskey macros

See original GitHub issue

I’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, Dictionary2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
HerbMcommented, Jan 7, 2018

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. 😃 )

1reaction
rkeithhillcommented, Jul 13, 2016

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:

# Copy the current path to the clipboard
Set-PSReadlineKeyHandler -Key Alt+c `
                         -BriefDescription CopyCurrentPathToClipboard `
                         -LongDescription "Copy the current path to the clipboard" `
                         -ScriptBlock {
    param($key, $arg)

    Add-Type -Assembly System.Windows.Forms
    [System.Windows.Forms.Clipboard]::SetText($pwd.Path, 'Text')
}

For more of these check out my PSReadline_config.ps1 file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PSReadline interferes with doskey macros · Issue #353
I have no plans to support doskey macros. There are replacements in PowerShell and/or PSReadline (PowerShell functions or custom PSReadline ...
Read more >
`doskey /macros:all` produces quoted string I can't get rid of
The answer here shows how to make doskey.exe work nonetheless, if you so choose - at the expense of losing much of PowerShell's...
Read more >
Getting doskey macros to work in PowerShell
Some of you may be thinking “sure you can use doskey macros, but you should take advantage of PowerShell's unique alias and function...
Read more >
Create permanent DOSKEY in Windows cmd
doskey command will list all current macro definitions into d:\bat\macros.doskey file. A sample macro definition file could be as follows (note ...
Read more >
The amount of times I have accidentally done this...
Mine was crashing randomly every couple day (or more) on one pc while using neovim in wsl. I've worked around the problem but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found