Skip to content

Instantly share code, notes, and snippets.

@fxn
Created March 15, 2025 12:35
Show Gist options
  • Save fxn/ae193eab1db2402eaea5c72e8ff01305 to your computer and use it in GitHub Desktop.
Save fxn/ae193eab1db2402eaea5c72e8ff01305 to your computer and use it in GitHub Desktop.
import iterm2
import sys
async def main(connection):
app = await iterm2.async_get_app(connection)
session = app.current_terminal_window.current_tab.current_session
change = iterm2.LocalWriteOnlyProfile()
change.set_background_image_location("")
await session.async_set_profile_properties(change)
iterm2.run_until_complete(main)
import iterm2
import sys
async def main(connection):
app = await iterm2.async_get_app(connection)
session = app.current_terminal_window.current_tab.current_session
change = iterm2.LocalWriteOnlyProfile()
change.set_background_image_location(sys.argv[1])
# ASPECT_FIT is "Scale to fit the space, adding letterboxes or pillarboxes if needed. Does not distort."
change.set_background_image_mode(iterm2.BackgroundImageMode.ASPECT_FIT)
change.set_blur(False)
change.set_blend(1)
await session.async_set_profile_properties(change)
iterm2.run_until_complete(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment