jktr / matplotlib-backend-kitty

show matplotlib plots directly in your kitty terminal
Creative Commons Zero v1.0 Universal
137 stars 16 forks source link

Update the interactive repl heuristic #13

Closed ayorgo closed 11 months ago

ayorgo commented 1 year ago

This addresses #12 by using sys.ps1 as a heuristic for interactive shell according to the table below (courtesy of this SO answer). image

jktr commented 11 months ago

I definitely prefer having a way to automatically detect an interactive environment, mainly because the current heuristic makes it really easy to forget the -i during startup. I didn't really expect that people would use this in combination with ipython's console, but adding support this way seems like a good idea.

The docs for sys.ps1 say that existence of these attributes implies an interactive environment. Because I'm not sure that the absence of these attributes also implies a non-interactive environment, I'm likely going to retain the current heuristic as a fallback in case sys.ps1 isn't defined.

jktr commented 11 months ago

Changes from the PR were merged into cbe4fe231d758b945c73ab89aee458acb12255d3.