Open yavko opened 1 year ago
The current implementation parses /proc
to determine the most likely
terminal, but it does so through the /proc/PID/comm
file which we
have no way of saniziting.
$TERM
has proven to be unreliable at detecting the real terminal
being used (anyone can for example set the variable to xterm
and
that would then be reflected in macchina).
$TERMINFO
is new to me, I've never had to directly interact with it.
I believe we're better off returning the relevant terminfo description directly.
The current implementation parses
/proc
to determine the most likely terminal, but it does so through the/proc/PID/comm
file which we have no way of saniziting.
Ah makes sense
$TERM
has proven to be unreliable at detecting the real terminal being used (anyone can for example set the variable toxterm
and that would then be reflected in macchina).
Thats true, I have seen that done a lot
$TERMINFO
is new to me, I've never had to directly interact with it.I believe we're better off returning the relevant terminfo description directly.
Yeah, I agree, idk if this helps but I found a crate that could aid in this https://crates.io/crates/terminfo
Yeah, I agree, idk if this helps but I found a crate that could aid in this https://crates.io/crates/terminfo
Yeah it looks like it will, I was never really a fan of our little procfs hack.
Yeah, I agree, idk if this helps but I found a crate that could aid in this crates.io/crates/terminfo
Yeah it looks like it will, I was never really a fan of our little procfs hack.
Oh yeah definitely seems pretty hacky
@grtcdr If you'd like I can write up something with this, just wanna know in case someone has already started on this.
Absolutely, go ahead!
I await the improvements your pull request will bring :)
Absolutely, go ahead!
I await the improvements your pull request will bring :)
After implementing terminfo, it seem futile, same issue as with $TERM
with terminfo name:
with description:
I found this result on stackoverflow that uses ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$)
to get the term name, which results in something like this
could the path then be stripped to only get exec name, as this method seems to use the exact exec name
You'll have to manually traverse /proc
and compare the values of /proc/<TERMPID>/comm
and /proc/<TERMPID>/cmdline
.
cmdline
should hopefully show you an output like the one returned by the ps
command you mentioned.
If it does, and you think the output of cmdline
is more consistent, I'd be happy to include the change.
Okay, so it sorta works. I mean it does, but when its in a nix-shell it says rc
, which happens to be the exec name of nix shells. I'm quite sad, because I kept getting rc
, and was very confused until i just ran ps, and it also said rc
I'll make the pr now
I've made a PR now! https://github.com/Macchina-CLI/libmacchina/pull/130
Thank you, I'll review it as soon as possible :)
Describe the bug On NixOS under home-manager the terminal app name starts with a
My proposal is to try parsing the
.
and ends with-wrapped
, I know this is because home-manager creates a kitty script which then calls an executable with the name.kitty-wrapped
as seen below ↓$TERM
or$TERMINFO
environment variables if possibleTo Reproduce Steps to reproduce the behavior:
Expected behavior Terminal appears as
kitty
Screenshots![image](https://user-images.githubusercontent.com/15178513/213966130-70d46f0b-e617-477d-a924-620c79affae8.png)
System Information You don't have to provide this information if you're not comfortable doing so, but it'll help us solve the issue a lot faster.