Thanks for sharing! Inspired by your code, I developed the Wolfram-terminal-image package to display Wolfram Mathematica graphics in the vscode terminal and emacs org-mode (dynamic plots can be interacted via Wolfram Player).
For vscode, both formulas and plots are converted into .png
files and shown in terminal using imgcat
.
Demo: Test-vscode-terminal-wolfram-mathematica.gif

For emacs org-mode, formulas are converted into LaTeX fragments by default, making it easy to paste them into Microsoft Word or LaTeX. You can place the cursor on a formula and press C-c C-x C-l
to toggle it preview.
Print["\\begin{equation*}\n" <> ToString[TeXForm[expr]] <> "\n\\end{equation*}"];
Demo: Test-emacs-jupyter-wolfram-mathematica.gif
