Skip to content

Modify activate command to recognise <window_id>:<tab_id> as well as <tab_id> #101

Description

@upstageleft

The actvate command currently uses an id argument to activate a specific tab chrome-cli activate -t <id>, but if the tab_id provided is not in the frontmost window of Chrome, the command silently fails, even if a tab with that id exists in another window.

Since the list tabs command returns a list of ids that either:

  1. Contain colons: [<window_id>:<tab_id>] <Tab_Name> if there is more than one window open, or
  2. Do not contain colons: [<tab_id>] <Tab_Name> if there is only one window open,

the simplest modification to improve/fix this would be to parse the id argument based on whether it contains a colon, and then:

  1. If the id argument contains a colon, activate the tab_id following the colon of the window_id preceding the colon, if a tab with that tab_id exists in a window with that window_id.
    chrome-cli activate -t <window_id>:<tab_id>

  2. If no colon is found, then activate the tab_id in the frontmost window, if a tab with that id exists in that window.
    chrome-cli activate -t <tab_id>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions