Skip to content

mateconpizza/gurl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

96 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— gurl

Cheer gopher logo
πŸ’™ Gopher image by Takuya Ueda

GitHub go.mod Go version Linux

gurl is a golang >= v1.24 program that reads URLs and other common identifiers from standard input (STDIN)

It is designed to work with any terminal that can pipe visible text to external programs, such as st, alacritty, kitty, wezterm, or similar.

The primary use case is piping the currently visible terminal output into gurl. I'm using st terminal with externalpipe patch to read/pipe current visible text to this program.

Features

  • Read input from STDIN
  • Extract URLs and other identifiers
  • Remove duplicate results
  • Support custom regular expressions
  • Optional index prefix for results
  • Optional extractor-based prefixes
  • Limit number of items

Built-in Extractors

Name Description
email Email addresses
hash Short hexadecimal identifiers (7–12 chars)
hexcolor HEX colors (CSS/Web)
ipv4 IPv4 addresses
ipv6 IPv6 addresses
domain Domain names
mac MAC addresses
path File paths (absolute, relative, file://)
raw Raw input lines
sha SHA-1 or SHA-256 hashes
url Web URLs (http, https, ftp, www)
uuid UUIDs

Installation

go install github.com/mateconpizza/gurl@latest

Usage

$ gurl -h
Extract URLs from STDIN

Usage:
  gurl [options]

Options:
  -t, --type STR            Comma-separated extractor types (default: url)
  -E, --regex NAME=REGEX    Register a custom extractor
  -l, --list                List built-in extractors
  -n, --lines               Limit number of results
  -p, --prefix              Prefix results with extractor name
  -i, --index               Prefix results with index number
  -V, --version             Show version and exit
  -v, --verbose             Enable verbose logging
  -h, --help                Show this help message

Examples

$ gurl --prefix --type hash,sha,url,uuid,ipv4,mac < input.txt
hash:865ed41
sha:abb9a11544fbd3d2a283ced39c4400cd66daf3f5
url:https://github.com/mateconpizza/gm
uuid:3510b822-56f4-4f6d-a773-05efc0baa7e2
ipv4:1.1.1.1
mac:ff:ff:ff:ff:ff:ff
...

# Extract short commit hash
$ git log --oneline | fzf --multi | gurl -t hash
46c4bb9
4dada2e
865ed41
...

Using -E|--regex Flag

The flag -E|--regex can be use for custom extractor.

# list existing remotes
$ gurl -t jira -E jira='^PROJ-\d+$' < data/jira.txt
PROJ-1
PROJ-12
PROJ-123
PROJ-0001
PROJ-99999
...

Tip

To enable case-insensitive matching in your custom regex, use the (?i) gurl -t jira -E jira='(?i)^proj-\d+$' < data/jira.txt

Regex Syntax

Custom extractors use Go RE2 syntax.

⭐ Related Projects

  • urlscan - Designed to integrate with the "mutt" mailreader
  • urlview - Extract URLs from a text file and allow the user to select via a menu

About

πŸ”— Extract URLs from STDIN

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published