Site icon TechHype.io

Purr – A CLI tool for viewing and searching through Android logcat output

purr is a zsh CLI tool for viewing and searching through Android logcat output. It leverages fzf to provide a simple yet powerful user interface, fuzzy-finding capabilities, and much more.

Motivation

While Android Studio’s logcat viewer is sufficient for most app development, it breaks down when exposed to situations such as terminal-only access or when multiple devices need to be accessed quickly. When performing development on the Android operating system itself, developers revert to using raw adb logcat in shell.

This is sub-optimal and wastes a lot of time on writing grep statements and rooting through uncolored, unfiltered text with poor user experience. purr is meant as a solution to this; a powerful logcat viewer running entirely on the shell, capable of going through millions of logs quickly, while leveraging other shell-based solutions for common problems.

Dependencies

purr currently functions on Ubuntu Linux and Mac on zsh. It will attempt to source an fzf version locally if possible, but requires version 0.40.0 or higher.

If you do not have fzf 0.40.0 or higher locally, purr will use bundled fzf versions for linux_x86_64darwin_arm64 or darwin_amd64 if applicable. If you have a different operating system, you need to download a 0.40.0 or higher fzf binary manually.

Support for Windows may be provided in future, but is not a current priority.

Installation

  1. Clone the repo
  2. Add the scripts directory to your path
  3. Run using purr

purr comes with two bundled programs:

Guide

purr includes a simple tool to help select the device serial from adb devices, or can read from the $ANDROID_SERIAL environment variable if set. Otherwise, purr has six command-line parameters:

Any other command-line parameters will print the help dialog.

Note that both -a and -f are read without validation; there is no guarantee that setting either parameter will not break purr.

Binds

The following hotkeys can be used:

General

Stream Modes

Preview Window

Navigation

ADB Shorthands

Misc

History

purr saves a query string to history once it has not been changed for more than 3.5 seconds. You can use the following hotkeys to access history:

When scrolling through history with alt-shift-up or alt-shift-down, your position in the history will reset once a string has been in the query for 3.5 seconds.

Editor

When you select a single line and press Ctrl-V, purr will open the selected line and surrounding context in a text editor. You can specify the text editor through the $EDITOR or $EDITOR_PURR environment variables; if no text editor is specified, purr will use vim.

Note that logcat uses ANSI color codes to display color, so an editor that supports these codes is recommended; for example, AnsiEsc for Vim.

If multiple lines are selected, only those selected lines will be opened in the text editor.

Development

  1. Clone the repo
  2. Open in your favorite IDE/editor

Dependencies

Support

If you’ve found an error, please file an issue:

https://github.com/google/purr/issues

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.

Purr on GitHub: https://github.com/google/purr
Platform: Android
⭐️: 81
Exit mobile version