jnoortheen / xontrib-cmd-durations

Show long running commands durations in prompt with option to send notification when terminal is not focused.
MIT License
16 stars 4 forks source link

PyCharm: Environment variable $TERM_PROGRAM is unset. #13

Closed anki-code closed 1 year ago

anki-code commented 1 year ago

Hi! Thank you for the awesome xontrib!

I've faced with this in PyCharm Community Edition terminal:

xontrib load cmd_done
sleep 6
# WARNING:root:Environment variable $TERM_PROGRAM is unset. 
# It should be set by the terminal application on shell startup. Not able to find active window.

Because:

env | grep TERM
#TERM=xterm-256color
#TERMINAL_EMULATOR=JetBrains-JediTerm
#TERM_SESSION_ID=77455237-439e-4631-87d5-0c33757ebcdf

And the notification will be appear no matter for the terminal is focused or not.

What is the right way to solve this?

Thanks!

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

jnoortheen commented 1 year ago

Could you post the OS and what shell backend is used by the pycharm terminal? I think one solution would be to set $TERM_PROGRAM manually.

anki-code commented 1 year ago

It's MacOS. I see in the documentation:

PyCharm includes an embedded terminal emulator for working with your command-line shell from inside the IDE.

I can set $TERM_PROGRAM manually to avoid warning but this is not the solution for window focus detection.

jnoortheen commented 1 year ago

Yes the feature doesn't work on Windows as noted. I don't use Windows but happy to accept any fixes.

anki-code commented 1 year ago

This is on PyCharm in MacOS

jnoortheen commented 1 year ago

Yes I understand, in that case I suggested setting the environment variable. You haven't answered the shell it is using, I guess it to be zsh (the default on MacOS). Please check why it is not setting the terminal program variable.