Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iTerm2のステータスバーのコンポーネントを自作する (たぶんPython初心者でもできる)

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for takezyou takezyou
June 15, 2019
640

iTerm2のステータスバーのコンポーネントを自作する (たぶんPython初心者でもできる)

Avatar for takezyou

takezyou

June 15, 2019
Tweet

Transcript

  1. ίϯϙʔωϯτͷ࡞Γํ • Python API • Status Bar Component • Python

    RuntimeΛΠϯετʔϧ
 Scripts > Manage > Install Python Runtime • Scripts > Manage > New Python Script
  2. ίϯϙʔωϯτͷ࡞Γํ #!/usr/bin/env python3.7 import asyncio import iterm2 # This script

    was created with the "basic" environment which does not support adding dependencies # with pip. async def main(connection): # This is an example of using an asyncio context manager to register a custom control # sequence. You can send a custom control sequence by issuing this command in a # terminal session in iTerm2 while this script is running: # # printf "\033]1337;Custom=id=%s:%s\a" "shared-secret" "create-window" async with iterm2.CustomControlSequenceMonitor(connection, "shared-secret", r'^create-window$') as mon: while True: match = await mon.async_get() await iterm2.Window.async_create(connection) # This instructs the script to run the "main" coroutine and to keep running even after it returns. iterm2.run_forever(main)
  3. ίϯϙʔωϯτͷ࡞Γํ • εΫϦϓτͷঢ়گ͸ Scripts > Manage > Console ͔Β֬ೝͰ͖Δ •

    ~/Library/ApplicationSupport/iTerm2/ Scripts/Autolaunch/ҎԼʹ഑ஔ͢Δ͜ͱͰࣗ ಈͰεΫϦϓτΛಡΈࠐΜͰ͘ΕΔ