mirror of
https://github.com/jessebot/dot_files.git
synced 2025-10-01 01:48:43 +00:00
40 lines
1.2 KiB
Python
Executable file
40 lines
1.2 KiB
Python
Executable file
#!/usr/bin/env python3.11
|
|
"""
|
|
Name: w3m-splits
|
|
AUTHOR: https://github.com/jessebot
|
|
DESCRIPTION: quick script to run w3m with images from neomutt in iterm2
|
|
you'll still need something like sixel and w3m locally
|
|
LICENSE: GNU AFFERO GENERAL PUBLIC LICENSE Version 3
|
|
"""
|
|
|
|
import iterm2
|
|
import argparse
|
|
|
|
# parse args
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("html_file",
|
|
help="html or website to view in w3m in an iterm2 split")
|
|
args = parser.parse_args()
|
|
print()
|
|
|
|
|
|
async def main(connection):
|
|
"""
|
|
Create split pane to the right, make the right pane active, and send a
|
|
command to the newly created split
|
|
"""
|
|
|
|
app = await iterm2.async_get_app(connection)
|
|
|
|
# Create split pane to the right and make the right one active
|
|
left_pane = app.current_terminal_window.current_tab.current_session
|
|
right_pane = await left_pane.async_split_pane(vertical=True)
|
|
|
|
# send the command to the newly created split
|
|
w3m = ("w3m -sixel -o auto_image=TRUE -o display_image=1 -T text/html"
|
|
f" -F {args.html_file} && exit \n")
|
|
await right_pane.async_send_text(w3m)
|
|
|
|
|
|
# run the iterm2 stuff
|
|
iterm2.run_until_complete(main)
|