Created
August 20, 2019 13:14
-
-
Save aizatto/cd4b09a889b5febf43b3df36b476a425 to your computer and use it in GitHub Desktop.
How I setup my iterm2 workspace for working on deep thought
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# https://www.iterm2.com/python-api/ | |
# https://www.iterm2.com/documentation-variables.html | |
# https://github.com/gnachman/iTerm2/tree/master/api/library/python/iterm2/iterm2 | |
# https://github.com/gnachman/iTerm2/blob/master/api/library/python/iterm2/docs/examples/set_title_forever.rst | |
# https://github.com/gnachman/iTerm2/blob/master/api/library/python/iterm2/docs/examples/movetab.rst | |
import iterm2 | |
import time | |
async def async_split_pane_send_text(first_session, name, text): | |
await first_session.async_activate() | |
session = await first_session.async_split_pane(True, True) | |
await session.async_send_text(text) | |
await session.async_set_name(name) | |
async def main(connection): | |
app = await iterm2.async_get_app(connection) | |
window = app.current_terminal_window | |
if window is None: | |
print("No current window") | |
return | |
await window.async_set_title("deepthought") | |
await window.current_tab.async_set_title("deepthought") | |
tab = await window.async_create_tab() | |
await tab.async_set_title("dt: docker & proxy") | |
docker_session = tab.current_session | |
await docker_session.async_set_name("docker") | |
await docker_session.async_send_text("docker-compose up\n", True) | |
proxy_session = await docker_session.async_split_pane(True) | |
await proxy_session.async_set_name("proxy") | |
await proxy_session.async_send_text("cd packages/deepthoughtapp.com && yarn run start\n", True) | |
tab = await window.async_create_tab() | |
await tab.async_set_title("dt: www-assets & www-server") | |
# I do this to keep the following commands the same | |
first_session = tab.current_session | |
await async_split_pane_send_text(first_session, "www-assets", "cd packages/www-assets/ && yarn run start\n") | |
await async_split_pane_send_text(first_session, "www-assets", "cd packages/www-assets/\n") | |
await async_split_pane_send_text(first_session, "www-server", "cd packages/www-server/ && sleep 30 && yarn run start\n") | |
await async_split_pane_send_text(first_session, "www-server", "cd packages/www-server/\n") | |
await first_session.async_close() | |
iterm2.run_until_complete(main, True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment