chrome-cli icon indicating copy to clipboard operation
chrome-cli copied to clipboard

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

Open upstageleft opened this issue 9 months ago • 0 comments

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>

upstageleft avatar Apr 01 '25 21:04 upstageleft