Skip to content

Instantly share code, notes, and snippets.

@dpiponi
Created July 21, 2021 15:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpiponi/3abef1f9d18f7d648aed2480969fe148 to your computer and use it in GitHub Desktop.
Save dpiponi/3abef1f9d18f7d648aed2480969fe148 to your computer and use it in GitHub Desktop.
(** User Mathematica initialization file **)
(** See https://reference.wolfram.com/language/tutorial/ConfigurationFiles.html for info on instaling this file **)
(** Display graphics inline in iTerm2. I don't know an easy way to test if we're running in iTerm2 without looking at the process table. **)
imgcat[image_Graphics]:=(
WriteString[$Output, "\033]1337;File=inline=1:"<>ExportString[ExportString[image,"PNG"],"Base64"]<>"\007"];
Null
)
(** `ListAnimate` seems to work but `Animate` doesn't. **)
imgcat[image_Manipulate]:=(
WriteString[$Output, "\033]1337;File=inline=1:"<>ExportString[ExportString[image,"GIF"],"Base64"]<>"\007"];
Null
)
imgcat[other_]:=other
$Post=imgcat
@dpiponi
Copy link
Author

dpiponi commented Jul 21, 2021

This allows Mathematica to inline images when Wolframscript is used from the iTerm2 terminal on macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment