Пример #1
0
async def main(connection):
    app = await iterm2.async_get_app(connection)
    window = app.current_terminal_window
    timeout = 3
    if window is not None:
        # Run ryanair service
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session
        await session.async_send_text('cd ~/code/indie-ryanair-service\nys\n')
        time.sleep(timeout)
        change = iterm2.LocalWriteOnlyProfile()
        color = iterm2.Color(204, 0, 126)
        change.set_tab_color(color)
        change.set_use_tab_color(True)
        await session.async_set_profile_properties(change)
        await session.async_set_name("ryanair serv")

        # Run ryanair frontend
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session
        await session.async_send_text('cd ~/code/indie-ryanair-frontend\nys\n')
        time.sleep(timeout)
        change = iterm2.LocalWriteOnlyProfile()
        color = iterm2.Color(0, 140, 240)
        change.set_tab_color(color)
        change.set_use_tab_color(True)
        await session.async_set_profile_properties(change)
        await session.async_set_name("ryanair front")

    else:
        # You can view this message in the script console.
        print("No current window")
Пример #2
0
async def main(connection):
    app = await iterm2.async_get_app(connection)
    session = app.current_terminal_window.current_tab.current_session
    change = iterm2.LocalWriteOnlyProfile()
    tab_color = iterm2.Color(255, 153, 51)
    background_color = iterm2.Color(100, 0, 0)
    change.set_tab_color(tab_color)
    change.set_use_tab_color(True)
    change.set_background_color(background_color)
    await session.async_set_profile_properties(change)
async def main(connection):

    app = await iterm2.async_get_app(connection)

    session = app.current_terminal_window.current_tab.current_session

    profile = iterm2.LocalWriteOnlyProfile()

    set_color = {
        'Foreground Color': profile.set_foreground_color,
        'Background Color': profile.set_background_color,
        'Bold Color': profile.set_bold_color,
        'Link Color': profile.set_link_color,
        'Selection Color': profile.set_selection_color,
        'Selected Text Color': profile.set_selected_text_color,
        'Cursor Color': profile.set_cursor_color,
        'Cursor Text Color': profile.set_cursor_text_color,
        'Cursor Guide Color': profile.set_cursor_guide_color,
        'Badge Color': profile.set_badge_color,
        'Tab Color': profile.set_tab_color,
        'Underline Color': profile.set_underline_color,
        'Ansi 0 Color': profile.set_ansi_0_color,
        'Ansi 1 Color': profile.set_ansi_1_color,
        'Ansi 2 Color': profile.set_ansi_2_color,
        'Ansi 3 Color': profile.set_ansi_3_color,
        'Ansi 4 Color': profile.set_ansi_4_color,
        'Ansi 5 Color': profile.set_ansi_5_color,
        'Ansi 6 Color': profile.set_ansi_6_color,
        'Ansi 7 Color': profile.set_ansi_7_color,
        'Ansi 8 Color': profile.set_ansi_8_color,
        'Ansi 9 Color': profile.set_ansi_9_color,
        'Ansi 10 Color': profile.set_ansi_10_color,
        'Ansi 11 Color': profile.set_ansi_11_color,
        'Ansi 12 Color': profile.set_ansi_12_color,
        'Ansi 13 Color': profile.set_ansi_13_color,
        'Ansi 14 Color': profile.set_ansi_14_color,
        'Ansi 15 Color': profile.set_ansi_15_color,
    }

    def interp(x):
        return int(round(x * 255))

    for key in root.keys():
        red = interp(root[key]['Red Component'])
        green = interp(root[key]['Green Component'])
        blue = interp(root[key]['Blue Component'])
        try:
            alpha = interp(root[key]['Alpha Component'])
        except KeyError:
            alpha = 255
        set_color[key](iterm2.Color(red, green, blue, alpha))

    if not args.quiet:
        for key in set(set_color.keys()) - set(root.keys()):
            print(f'Warning: Missing key \'{key}\' in {args.file}')

    await session.async_set_profile_properties(profile)
Пример #4
0
 async def __update_tab_color(session, red, green, blue):
     profile = await session.async_get_profile()
     # session = app.current_terminal_window.current_tab.current_session
     # change = iterm2.LocalWriteOnlyProfile()
     change = profile
     # color = iterm2.Color(255, 128, 128)
     color = iterm2.Color(red, green, blue)
     await change.async_set_tab_color(color)
     await change.async_set_use_tab_color(True)
Пример #5
0
async def main(connection):
    app = await iterm2.async_get_app(connection)
    session = app.current_terminal_window.current_tab.current_session
    window = app.current_window
    #    if window is not None:
    #        await window.async_create_tab()
    #    else:
    #        print("No current window")

    change = iterm2.LocalWriteOnlyProfile()
    color = iterm2.Color(rand_color(), rand_color(), rand_color())

    change.set_tab_color(color)
    change.set_use_tab_color(True)
    await session.async_set_profile_properties(change)
Пример #6
0
async def main(connection):
    instant = False
    enabled = True

    triggers = [
        iterm2.AlertTrigger("^AlertTrigger", "Lorem ipsum", instant, enabled),
        iterm2.AnnotateTrigger("^AnnotateTrigger", "Lorem ipsum", instant,
                               enabled),
        iterm2.BellTrigger("^BellTrigger", instant, enabled),
        iterm2.BounceTrigger(
            "^BounceTrigger",
            iterm2.BounceTrigger.Action.BOUNCE_UNTIL_ACTIVATED, instant,
            enabled),
        iterm2.CaptureTrigger("^CaptureTrigger", "/bin/true", instant,
                              enabled),
        iterm2.CoprocessTrigger("^CoprocessTrigger", "/bin/true", instant,
                                enabled),
        iterm2.HighlightLineTrigger("^HighlightLineTrigger",
                                    iterm2.Color(255, 0, 0),
                                    iterm2.Color(0, 255, 0), instant, enabled),
        iterm2.HighlightTrigger("^HighlightTrigger", iterm2.Color(255, 0, 0),
                                iterm2.Color(0, 255, 0), instant, enabled),
        iterm2.HyperlinkTrigger("^HyperlinkTrigger", "https://google.com/",
                                instant, enabled),
        iterm2.InjectTrigger("^InjectTrigger", "xxx", instant, enabled),
        iterm2.MarkTrigger("^MarkTrigger", True, instant, enabled),
        iterm2.MuteCoprocessTrigger("^MuteCoprocessTrigger", "/bin/true",
                                    instant, enabled),
        iterm2.PasswordTrigger("^PasswordTrigger", "Dreamhost", "gnachman",
                               instant, enabled),
        iterm2.RPCTrigger("^RPCTrigger", "foo()", instant, enabled),
        iterm2.RunCommandTrigger("^RunCommandTrigger", "/bin/true", instant,
                                 enabled),
        iterm2.SendTextTrigger("^SendTextTrigger", "lorem ipsum", instant,
                               enabled),
        iterm2.SetDirectoryTrigger("^SetDirectoryTrigger", "/etc", instant,
                                   enabled),
        iterm2.SetHostnameTrigger("^SetHostnameTrigger", "example.com",
                                  instant, enabled),
        iterm2.SetTitleTrigger("^SetTitleTrigger", "lorem ipsum", instant,
                               enabled),
        iterm2.SetUserVariableTrigger("^SetUserVariableTrigger", "hello",
                                      '"world"', instant, enabled),
        iterm2.ShellPromptTrigger("^ShellPromptTrigger", instant, enabled),
        iterm2.StopTrigger("^StopTrigger", instant, enabled),
        iterm2.UserNotificationTrigger("^UserNotificationTrigger",
                                       "lorem ipsum", instant, enabled),
    ]

    all_profiles = await iterm2.Profile.async_get(connection)
    profile = all_profiles[0]
    trigger_dicts = list(map(lambda t: t.encode, triggers))
    await profile.async_set_triggers(trigger_dicts)

    all_profiles = await iterm2.Profile.async_get(connection)
    profile = all_profiles[0]
    trigger_dicts = profile.triggers
    triggers2 = list(map(iterm2.decode_trigger, trigger_dicts))
    for (lhs, rhs) in zip(triggers, triggers2):
        print(lhs)
        print(rhs)
        assert (lhs == rhs)
        print("")
Пример #7
0
async def main(connection):
    app = await iterm2.async_get_app(connection)
    window = app.current_terminal_window
    timeout = 3
    if window is not None:
        # Run Ariana
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session

        await session.async_send_text('cd ~/code/indie-ariana-service\nys\n')
        time.sleep(timeout)
        change = iterm2.LocalWriteOnlyProfile()
        color = iterm2.Color(255, 128, 128)
        change.set_tab_color(color)
        change.set_use_tab_color(True)
        await session.async_set_profile_properties(change)
        await session.async_set_name("ariana")

        # Run Rita-Ora
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session
        await session.async_send_text('cd ~/code/indie-rita-ora\nys\n')
        time.sleep(timeout)
        change = iterm2.LocalWriteOnlyProfile()
        color = iterm2.Color(245, 193, 7)
        change.set_tab_color(color)
        change.set_use_tab_color(True)
        await session.async_set_profile_properties(change)
        await session.async_set_name("rita")

        # Run Billie-Eilish
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session
        await session.async_send_text('cd ~/code/indie-billie-eilish\nys\n')
        time.sleep(timeout)
        change = iterm2.LocalWriteOnlyProfile()
        color = iterm2.Color(0, 204, 143)
        change.set_tab_color(color)
        change.set_use_tab_color(True)
        await session.async_set_profile_properties(change)
        await session.async_set_name("billie")

        # Run Fka-twigs
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session
        await session.async_send_text('cd ~/code/indie-fka-twigs\nys\n')
        time.sleep(timeout)
        change = iterm2.LocalWriteOnlyProfile()
        color = iterm2.Color(105, 0, 204)
        change.set_tab_color(color)
        change.set_use_tab_color(True)
        await session.async_set_profile_properties(change)
        await session.async_set_name("fka")

        # Run Shakira
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session
        await session.async_send_text('cd ~/code/indie-shakira\nys\n')
        time.sleep(timeout)
        change = iterm2.LocalWriteOnlyProfile()
        color = iterm2.Color(252, 252, 28)
        change.set_tab_color(color)
        change.set_use_tab_color(True)
        await session.async_set_profile_properties(change)
        await session.async_set_name("shakira")

        # Run Back Office graph
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session
        await session.async_send_text('cd ~/code/backoffice-graphql-server\nys\n')
        time.sleep(timeout)
        change = iterm2.LocalWriteOnlyProfile()
        color = iterm2.Color(204, 0, 126)
        change.set_tab_color(color)
        change.set_use_tab_color(True)
        await session.async_set_profile_properties(change)
        await session.async_set_name("bo graph")

        # Run Back Office frontend
        await window.async_create_tab()
        session = app.current_terminal_window.current_tab.current_session
        await session.async_send_text('cd ~/code/backoffice-frontend\nys\n')
        time.sleep(timeout)
        change = iterm2.LocalWriteOnlyProfile()
        color = iterm2.Color(0, 140, 240)
        change.set_tab_color(color)
        change.set_use_tab_color(True)
        await session.async_set_profile_properties(change)
        await session.async_set_name("bo front")

    else:
        # You can view this message in the script console.
        print("No current window")
Пример #8
0
def get_ansi_8_color(is_dark):
    """Return a colour for ANSI 8 to match the dark or light colour preset."""
    if is_dark:
        return iterm2.Color(59, 109, 124)
    else:
        return iterm2.Color(114, 114, 124)
Пример #9
0
 def __init__(self, name: str, host: str, r: int, g: int, b: int):
     self.name = name
     self.host = host
     self.color = iterm2.Color(r, g, b)
Пример #10
0
async def main(connection):
    app = await iterm2.async_get_app(connection)
    tabLeft = app.current_terminal_window.current_tab.current_session

    # Change color tab to BLUE
    change = iterm2.LocalWriteOnlyProfile()
    color = iterm2.Color(0, 0, 255)
    change.set_tab_color(color)
    change.set_use_tab_color(True)
    await tabLeft.async_set_profile_properties(change)

    # Start Docker
    os.system('open --background -a Docker')
    isDockerRunning = 0
    while (not isDockerRunning):
        proc1 = subprocess.Popen(['docker', 'version'], stdout=subprocess.PIPE)
        proc2 = subprocess.Popen(['grep', 'Server: Docker Engine'],
                                 stdin=proc1.stdout,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
        out, err = proc2.communicate()
        isDockerRunning = len(out)
        if isDockerRunning > 0:
            print("Docker is running")
        else:
            print("Docker isn't running")
            sleep(10)

    # Start Container
    os.system('cd %s && docker-compose start' % PROJECT_MYSQL_PATH)
    isContainerRunning = -1
    while (isContainerRunning == -1):
        print('Checking if MySql container is running')
        container = subprocess.run(['docker ps | grep mysql57'],
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.STDOUT,
                                   shell=True)
        isContainerRunning = container.stdout.decode('utf-8').find('mysql57')
        if isContainerRunning != -1:
            print("MySql container is running")
        else:
            print("MySql container isn't running")
            sleep(5)

    # Open Visual Studio Code
    open_vs_code = """osascript -e 'tell application "Visual Studio Code"
    activate
    delay 5
    tell application "System Events"
        keystroke "f" using {control down, command down}
    end tell
    end tell'"""
    os.system(open_vs_code)

    # Open Github Desktop
    open_github_desktop = """osascript -e 'delay 10
    tell application "GitHub Desktop"
    activate
    delay 5
    tell application "System Events"
        keystroke "f" using {control down, command down}
    end tell
    end tell'"""
    os.system(open_github_desktop)

    # Create new tab in the right
    tabRight = await tabLeft.async_split_pane(vertical=True)
    color = iterm2.Color(0, 255, 0)
    change.set_tab_color(color)
    change.set_use_tab_color(True)
    await tabRight.async_set_profile_properties(change)

    # Start server
    await tabRight.async_send_text("cd %s && npm start \n" %
                                   PROJECT_SERVER_PATH)

    # Create tab at bottom
    tabLeftBottom = await tabLeft.async_split_pane()
    color = iterm2.Color(255, 0, 0)
    change.set_tab_color(color)
    change.set_use_tab_color(True)
    await tabLeftBottom.async_set_profile_properties(change)

    # Start client
    await tabLeftBottom.async_send_text("cd %s && npm start \n" %
                                        PROJECT_CLIENT_PATH)
Пример #11
0
import iterm2

default_tab_color = iterm2.Color(100, 149, 237)
config_file_name = __file__.replace('settings.py', 'server_config.json')