/grepath

Extract paths effortlessly from your command outputs with grepath

Primary LanguageRustMIT LicenseMIT

grepath

grepath is a command-line utility to effortlessly extract file paths from command outputs. It's especially useful in pipelines for processing compiler or lint tool outputs.

Features

  • Extract file paths from a given text.
  • Optionally extract full paths including line and column numbers.
  • Remove duplicate paths.

Installation

Install prebuilt binaries via Homebrew

brew install kqito/tap/grepath

Install prebuilt binaries via shell script

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/kqito/grepath/releases/latest/download/grepath-installer.sh | sh

Or download directly from releases.

Usage

When we run grepath <file>, it reads the file and outputs the paths from the text.

For example, if you want to open error files in VSCode, you can use the following command:

grepath error.log | xargs -o code

Pipe from a command

You can use grepath in command-line pipelines to filter paths from the output of other commands. Here is an example usage:

cat error.log | grepath | xargs -o code

Command Line Options

grepath --help
Usage: grepath [<file>] [-d] [-l] [-u]

Args

Positional Arguments:
  file              file

Options:
  -d, --debug       help
  -u, --unique      unique Omit duplicate paths
  --help            display usage information

TODO

  • Support for windows paths
  • Support for custom regex patterns

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.

License