unixorn/tumult.plugin.zsh

View on GitHub
bin/chrome-tabs

Summary

Maintainability
Test Coverage
#!/bin/bash
#
# Originally by @philsnow on the xooglers slack

if [[ "$(uname -s)" != 'Darwin' ]]; then
  echo 'Sorry, this script only works on macOS'
  exit 1
fi

ts () {
  date +'%Fz%T'
}

chrome_tabs () {
  # shellcheck disable=SC2046
  for win in $(seq 0 $(osascript -e 'tell application "Chrome" to get count every window'))
  do
    for tab in $(seq 0 $(osascript -e "tell application \"Chrome\" to get count every tab of window ${win}"))
    do
      echo -n "win $win tab $tab: "
      osascript -e "tell application \"Chrome\" to get URL of tab $tab of window $win"
    done
  done
}

chrome_tabs