microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.55k stars 8.31k forks source link

Please add line numbers. #17490

Open RokeJulianLockhart opened 4 months ago

RokeJulianLockhart commented 4 months ago

Description of the new feature/enhancement

As https://bugs.kde.org/show_bug.cgi?id=485923#c0 describes:

**STEPS TO REPRODUCE** Invoke Konsole, and use a command like [`cat`](https://github.com/coreutils/coreutils/blob/225cb8d7473eadb481a4884e929bf23589d4bd82/src/cat.c#L1) or https://github.com/MicrosoftDocs/PowerShell-Docs/blob/04dac6ae6b2abcb91006b6a515cc26c72219ffd5/reference/7.4/Microsoft.PowerShell.Management/Get-Content.md#example-2-limit-the-number-of-lines-get-content-returns to output the content of a file to the terminal. **OBSERVED RESULT** Without using `cat`'s `-b` or `-n` flags, the content cannot be numbered. For others, like the aforecited `Get-Content`, it's impossible to output line numbers without writing code for every interaction to iterate over the lines.

Konsole has since gained the ability to display line numbers, as https://discuss.kde.org/t/how-to-enable-line-numbers-in-konsole/14435?u=rokejulianlockhart#always-3 depicts:

534f710eb7b924d4c1a4bf1975c79837bdde8379

It's been invaluable for me, when reading long logs via the terminal. Consequently, I propose the same for Windows Terminal.

Proposed technical implementation details (optional)

I'd rather that they be in a permanent separator following the text direction, or on the opposite of the text direction, still separated regardless (to prevent overlap). Specifically, as https://bugs.kde.org/show_bug.cgi?id=485970#c3 describes:

I want it to be like a Konsole/Dolphin panel, so that it can be moved to the left or right. However, I'd like it to work like a plasmoid on a *PlasmaShell* panel does - when a new session is invoked (like when a new tab or window is created) it should be static, and not overlay, like any other panel does. However, I should be able to set a toggle (like PlasmaShell's pin feature) and have it then able to temporarily resize over the session until I pin it again, where it returns to its original size. It should also have a horizontal scrollbar for when the user accidentally sets it shorter than they need at the start of a session. Does that make sense?

I expected that this implementation wouldn't be possible due to wt's apparent lack of comparable "panel" support, but https://github.com/microsoft/terminal/issues/997#issue-448313575 demonstrates otherwise.


relevant notes:

zadjii-msft commented 3 months ago

Why is less -N (or similar) insufficient for this/?

RokeJulianLockhart commented 3 months ago

https://github.com/microsoft/terminal/issues/17490#issuecomment-2234379836

@zadjii-msft, because that's solely usable when piping command output. It doesn't operate retroactively. Additionally, if I run Get-ChildItem -LiteralPath "$HOME", I see coloured highlights for certain directories, whereas if I invoke Get-ChildItem -LiteralPath "$HOME" | less -N on Fedora 40, I don't (so it breaks command output).