[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TerminalView position and text of prompt


On Tue, 16 Apr 2024 at 13:28, Gianluigi <gradobag@xxxxxxxxxxx> wrote:

> Il 16/04/24 13:31, Bruce Steers ha scritto:
> > Is there a simple way to find where the prompt begins in a terminal and
> > what it is?
>
> I know you want answers only from gurus and I don't know your project,
> but if you emulate bash, you can read here:
>
> https://stackoverflow.com/questions/22322879/how-to-print-current-bash-prompt
>
> Regards
> Gianluigi

Cheers GL but im a bit past all that.
The project already sets PS1 and has an option to show either the full path
or just the dir name
So to find the prompt i search for an instance of the text according to
PS1.

But i think the text search is "an assumption" I have found the prompt.
Maybe there is some text in the command that matches the prompt then the
search will fail.
Also a user can set their own PS1 at any time then my code will also fail.
i'd have to write a complete PS1 decoder :(

So i just need to know reliably where exactly the PS1 prompt ends and the
command begins.

If possible, If somewhere in the terminalview code this place is known?
Or if from the codes perspective that position is all handled by the
running shell so it's irrelevant/unknown.

Respects
BruceS

Follow-Ups:
Re: TerminalView position and text of promptBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
References:
TerminalView position and text of promptBruce Steers <bsteers4@xxxxxxxxx>
Re: TerminalView position and text of promptGianluigi <gradobag@xxxxxxxxxxx>