List the tabs on your Android device

Use fzf on Linux to list and close tabs on your USB connected Android device


File under: android linux terminal .

Android debug bridge is exposing Chrome tabs; which is very nice because now we can use that information.

This script conveniently lists your tabs, enter will open it locally using xdg-open, del will close it on the connected Android phone or tablet. Have fun with it!

cat ~/bin/android-tabs
#!/bin/sh

adb forward tcp:9222 localabstract:chrome_devtools_remote && \
curl -s http://localhost:9222/json/list | \
jq -r '.[] | "\(.title | gsub("[\n\r]"; " ")) \t \(.url) \t \(.id)"' | \
fzf --delimiter='\t' --with-nth=1 --preview='echo {2}' \
  --bind 'enter:execute-silent(xdg-open {2})' \
  --bind 'del:execute-silent(curl -s -X POST http://localhost:9222/json/close/{3})+reload(curl -s http://localhost:9222/json/list | jq -r ".[] | \"\(.title | gsub(\"[\n\r]\"; \" \")) \t \(.url) \t \(.id)\"")' && \
adb forward --remove tcp:9222