using sed and pstree to display the type of terminal being used
I've been trying to display the type of terminal being used as the name
only. For instance if I was using konsole it would display konsole. So far
I've been using this command.
pstree -A -s $$
That outputs this.
systemd---konsole---bash---pstree
I have the following that can extract konsole from that line
pstree -A -s $$ | sed 's/systemd---//g;s/---.*//g' | head -1
and that outputs konsole properly. But some people have output from just
the pstree command that can look like this.
systemd---kdeinit4---terminator---bash---pstree
or this
systemd---kdeinit4---lxterminal---bash---pstree
and then when I add the sed command it extracts kdeinit4 instead of
terminator. I can think of a couple scenarios to extract the type of
terminal but none that don't contain conditional statements to check for
specific types of terminals. The problem I'm having is I can't accurately
predict how many non or non-relative things may be infront or behind of
the terminal name or what they will be nor can I accurately predict what
the terminal name will be. Does anyone have any ideas on a solution to
this?
No comments:
Post a Comment