Search code examples
windowscmdpipetortoisehg

Is there a way to sort the output in the Tortoisehg console window?


I can run hg commands in the TortoiseHg console window. Sometimes I want to pipe to another command to filter output or sort. Not really sure how to do this in TortoiseHg (although I know I can run hg commands in the 'Cmd' window and pipe to another command like a normal batch file).

I've tried both Unix and Windows CMD versions of piping the output. As a simple example (to illustrate the issue, but not necessarily the limits of what I could try...):

Unix:  hg branches | grep -i inactive 
CMD:   hg branches | findstr /I inactive

Neither of these will work in the TortoiseHg "Console" window. I would find it more convenient to run commands in the console window than in the CMD shell as my typed commands would be shown chronologically with other commands executed via the GUI (that normally show in the Console window).


Solution

    1. Even if your host OS is Windows, you can have (now) 2 shells in command-prompt (directly or as Terminal Window in THG): classic CMD and PowerShell. Defining which type you use will be better for faster understanding of a problem
    2. Same shell as command-prompt or Terminal will produce absolutely the same result

    Your cmd-sample "just work", can't see any troubles here (win32chcp is local extension for console outputs, irrelevant to tasks)

    Terminal THG

    THG\hg-git>hg branches | findstr /I inactive
    [win32chcp] switching your console encoding into cp1251
    1.0.x                       2155:ae8b3247c149 (inactive)
    0.10.x                      2118:4a18ab4b2fed (inactive)
    
    THG\hg-git>
    

    CMD-window

    Microsoft Windows [Version 10.0.19043.1766]
    (c) Microsoft Corporation. All rights reserved.
    
    THG\hg-git>hg branches | findstr /I inactive
    [win32chcp] switching your console encoding into cp1251
    1.0.x                       2155:ae8b3247c149 (inactive)
    0.10.x                      2118:4a18ab4b2fed (inactive)
    
    THG\hg-git>