Created
January 9, 2022 06:50
-
-
Save kxxoling/ccf7a21a47bc387f5b35e84a43771437 to your computer and use it in GitHub Desktop.
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
// edited from https://superuser.com/a/1535814 | |
function chrome_summary() { | |
local wincount=$(osascript -e 'tell application "Google Chrome" to get number of windows') | |
# [ "$wincount" -eq 0 ] && echo "zero windows!" && return | |
local tabscount=$((0)) | |
# local json="[" | |
for (( i=1; i<=$wincount; i++)); do | |
# json="$json""[" | |
local cmd="osascript -e 'tell application \"Google Chrome\" to get number of tabs in window $i'" | |
local tabcount=$(eval $cmd) | |
echo window $i tabs: $tabcount | |
tabscount=$(($tabscount + $tabcount)) | |
# for (( j=1; j<=$tabcount; j++)); do | |
# local cmd="osascript -e 'tell application \"Google Chrome\" to get URL of tab $j of window $i'" | |
# local url=$(eval $cmd) | |
# # [ $j -eq $tabcount ] && json="$json\"$url\"" || json="$json\"$url\"," | |
# done | |
# [ $i -eq $wincount ] && json="$json]" || json="$json]," | |
done | |
# echo "$json]" | |
echo total $tabscount | |
} | |
chrome_summary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment